当前位置: 首页>>代码示例>>C++>>正文


C++ printerror函数代码示例

本文整理汇总了C++中printerror函数的典型用法代码示例。如果您正苦于以下问题:C++ printerror函数的具体用法?C++ printerror怎么用?C++ printerror使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了printerror函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: scamper_if_getmac

int scamper_if_getmac(const int ifindex, uint8_t *mac)
{
  scamper_fd_t *fd = NULL;
  struct ifreq ifr;

  if(if_indextoname(ifindex, ifr.ifr_name) == NULL)
    {
      printerror(errno, strerror, __func__, "could not if_indextoname");
      goto err;
    }

  if((fd = scamper_fd_ifsock()) == NULL)
    {
      printerror(errno, strerror, __func__, "could not get ifsock");
      goto err;
    }

  if(ioctl(scamper_fd_fd_get(fd), SIOCGIFHWADDR, &ifr) == -1)
    {
      printerror(errno, strerror, __func__, "could not SIOCGIFHWADDR");
      goto err;
    }
  memcpy(mac, ifr.ifr_hwaddr.sa_data, 6);

  scamper_fd_free(fd);
  return 0;

 err:
  if(fd != NULL) scamper_fd_free(fd);
  return -1;
}
开发者ID:mami-project,项目名称:tracebox,代码行数:31,代码来源:scamper_if.c

示例2: minstack_tcp_start

/**
 * \brief Start the minstack_tcp in parameter
 * \param mt the minstack_tcp that have to be started
 * \return 0 if the minstack_tcp stack started correctly
 */
int minstack_tcp_start(minstack_tcp *mt) {
    int retval = 0;
    if (!mt || mt->status != IDLE) {
        printerror("Cannot start while already started\n");
        return -1;
    }
    switch (mt->type) {
    case NONE:
        printwarning("the minstack_tcp is not initialized\n");
        return -1;
    case SERVER:
        retval = minstack_tcp_boot_server(mt);
        break;
    case CLIENT:
        retval = minstack_tcp_boot_client(mt);
        break;
    default:
        printerror("Unknow enum type %d\n",mt->type);
        break;
    }
    if (!retval) {
        mt->status = STARTED;
        printmessage("%s is now started\n",mt->name);
    }
    return retval;
}
开发者ID:phoenix24,项目名称:minstack,代码行数:31,代码来源:tcp.c

示例3: vot_addFieldMeta

int 
vot_addFieldMeta (int handle, fitsfile *fp, int index)
{
    char  *ucd, *utype, *id, keyw[SZ_FNAME];
    int   status = 0;


    if ( (ucd = vot_getAttr (handle, "ucd")) ) {	/* UCD attribute     */
        memset (keyw, 0, SZ_FNAME);
        sprintf (keyw, "TUCD%d", index);
        if (fits_update_key (fp, TSTRING, keyw, ucd, "UCD attribute", &status))
	    printerror ( status );
    }

    if ( (utype = vot_getAttr (handle, "utype")) ) {	/* UTYPE attribute   */
        memset (keyw, 0, SZ_FNAME);
        sprintf (keyw, "TUTYPE%d", index);
        if (fits_update_key (fp, TSTRING, keyw, utype, "UTYPE attribute",
	    &status))
	        printerror ( status );
    }

    if ( (id = vot_getAttr (handle, "id")) ) {		/* ID attribute     */
        memset (keyw, 0, SZ_FNAME);
        sprintf (keyw, "TID%d", index);
        if (fits_update_key (fp, TSTRING, keyw, id, "ID attribute", &status))
	    printerror ( status );
    }

    return (0);
}
开发者ID:RayPlante,项目名称:usvirtualobservatory,代码行数:31,代码来源:zz.c

示例4: scamper_ip4_openraw

int scamper_ip4_openraw(void)
{
    int fd = -1;

#if defined(WITHOUT_PRIVSEP)
    int hdr = 1;
    if((fd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) == -1)
    {
        printerror(errno, strerror, __func__, "could not open socket");
        goto err;
    }

    if(setsockopt(fd, IPPROTO_IP, IP_HDRINCL, (void *)&hdr, sizeof(hdr)) == -1)
    {
        printerror(errno, strerror, __func__, "could not IP_HDRINCL");
        goto err;
    }
#else
    if((fd = scamper_privsep_open_rawip()) == -1)
    {
        printerror(errno, strerror, __func__, "could not open socket");
        goto err;
    }
#endif

    return fd;

err:
    if(fd != -1) scamper_ip4_close(fd);
    return -1;
}
开发者ID:mami-project,项目名称:tracebox,代码行数:31,代码来源:scamper_ip4.c

示例5: mousemoveevent

static void mousemoveevent(int x, int y) {
    char* error;
    if (!luastate_PushFunctionArgumentToMainstate_Double(x)) {
        printerror("Error when pushing func args to blitwizard.onMouseMove");
        fatalscripterror();
        main_Quit(1);
        return;
    }
    if (!luastate_PushFunctionArgumentToMainstate_Double(y)) {
        printerror("Error when pushing func args to blitwizard.onMouseMove");
        fatalscripterror();
        main_Quit(1);
        return;
    }
    if (!luastate_CallFunctionInMainstate("blitwizard.onMouseMove",
    2, 1, 1, &error, NULL, NULL)) {
        luacfuncs_onError("blitwizard.onMouseMove", error);
        if (error) {
            free(error);
        }
    }
#ifdef USE_GRAPHICS
    luacfuncs_objectgraphics_processMouseMove(x, y);
#endif
}
开发者ID:smheidrich,项目名称:Blitwizard,代码行数:25,代码来源:main.c

示例6: main

int main ( int argc, char **argv )
{
	Argvs cmd = ParseCommandLine ( argc, argv );
	if ( cmd.mode == OP_KEYGEN ) {
		if ( keygen ( cmd.t ) != 0 ) {
			printerror ( "Unknown keygen error" );
		}
	} else if ( cmd.mode == OP_CRYPT ) {
		if ( crypt ( cmd.file1, cmd.file2 ) != 0 ) {
			printerror ( "Unknown crypt error" );
		}
		free ( cmd.file1 );
		free ( cmd.file2 );
	} else if ( cmd.mode == OP_INVKEY ) {
		if ( invkey ( cmd.file1 ) != 0 ) {
			printerror ( "unknown invkey error" );
		}
		free ( cmd.file1 );
	} else if ( cmd.mode == OP_HISTO ) {
		if ( histo ( cmd.t, cmd.i, cmd.file1 ) != 0 ) {
			printerror ( "unknown histo error" );
		}
		free ( cmd.file1 );
	} else if ( cmd.mode == OP_SOLVE ) {
		if ( solve ( cmd.l, cmd.file1 ) != 0 ) {
			printerror ( "unknown solve error" );
		}
		free ( cmd.file1 );
	}
	return 0;
}
开发者ID:billgujie,项目名称:cryptography,代码行数:31,代码来源:hw4.c

示例7: rtmsg_dump

static void rtmsg_dump(const uint8_t *buf, size_t len)
{
  char str[80];
  size_t i, off = 0;
  int k = 0;

  for(i=0; i<len; i++)
    {
      if(k == 20)
	{
	  printerror(0, NULL, __func__, "%s", str);
	  k = 0;
	  off = 0;
	}

      if(k != 0 && (k % 4) == 0)
	string_concat(str, sizeof(str), &off, " ");
      string_concat(str, sizeof(str), &off, "%02x", buf[i]);
      k++;
    }

  if(k != 0)
    printerror(0, NULL, __func__, "%s", str);
  return;
}
开发者ID:vbajpai,项目名称:scamper-cvs-20141101,代码行数:25,代码来源:scamper_rtsock.c

示例8: keyboardevent

static void keyboardevent(const char* key, int release) {
    char* error;

    // We handle key up and key down,
    // and for both we ask a hidden (undocumented)
    // event function for the templates whether they
    // want to have the key event.
    //
    // (This will allow for a neat transparent
    // addition of an ingame developer console)
    const char onkeyup[] = "blitwizard.onKeyUp";
    const  char onkeyup_templates[] = "blitwizard._onKeyUp_Templates";
    const char* funcname = "blitwizard.onKeyDown";
    const char* funcname_templates = "blitwizard._onKeyDown_Templates";
    if (release) {
        funcname = onkeyup;
        funcname_templates = onkeyup_templates;
    }

    // Call function template function first:
    int returnboolean = 0;
    if (!luastate_PushFunctionArgumentToMainstate_String(key)) {
        printerror("Error when pushing func args to %s", funcname_templates);
        fatalscripterror();
        main_Quit(1);
    }
    if (!luastate_CallFunctionInMainstate(funcname_templates, 1, 1, 1, &error,
    NULL, &returnboolean)) {
        luacfuncs_onError(funcname_templates, error);
        if (error) {
            free(error);
        }
        return;
    }

    // if the templates event function has returned true, it handles
    // the event and we don't propagate it further:
    if (returnboolean) {
        return;
    }

    // otherwise, call the regular event function now:
    if (!luastate_PushFunctionArgumentToMainstate_String(key)) {
        printerror("Error when pushing func args to %s", funcname);
        fatalscripterror();
        main_Quit(1);
        return;
    }
    if (!luastate_CallFunctionInMainstate(funcname, 1, 1, 1, &error, NULL,
    NULL)) {
        luacfuncs_onError(funcname, error);
        if (error) {
            free(error);
        }
        return;
    }
}
开发者ID:smheidrich,项目名称:Blitwizard,代码行数:57,代码来源:main.c

示例9: printerror

void __fastcall TForm1::BGuardarClick(TObject *Sender)
{
  fitsfile *fptr;       /* pointer to the FITS file, defined in fitsio.h */
  int status;
  AnsiString N;

  ejex = X2;
  ejey = Y2;
  long n = X2*Y2;
  if(SD1->Execute())
  {
    status = 0;
    N = SD1->FileName + ".fit";
    if(ffinit(&fptr, N.c_str(), &status))
    {
      printerror( status );
      status = 0;
      if ( fits_open_file(&fptr, N.c_str(), READWRITE, &status) )
      {
         printerror(status);
        return;
      }
    }
  }
  else
    return;

  long axes[2];
  axes[0] = ejex;
  axes[1] = ejey;
  if(ffcrim(fptr, 16, 2, axes, &status))
  {
    printerror(status);
    return;
  }

  unsigned short *datos;

  datos = new unsigned short [ejex*ejey];
  memset(datos, 0, ejex*ejey*2);
  for(int py = 0; py < ejey; py++)
  {
    for (int px = ejex; px > 0; px--)
    {
      datos[n--] = Foto[py][px];
    }
  }

  status = 0;
  if(fits_write_img(fptr, TSHORT, 1, ejex*ejey, datos, &status))
  {
    printerror( status );
  }
  delete datos;
  return;
}
开发者ID:elcarva57,项目名称:ACOR,代码行数:56,代码来源:APLIC.CPP

示例10: fds_kqueue

static int fds_kqueue(struct timeval *tv)
{
  scamper_fd_t *fdp;
  struct timespec ts, *tsp = NULL;
  struct kevent *kev;
  int fd, i, c;

  if((c = dlist_count(read_fds) + dlist_count(write_fds)) >= kevlistlen)
    {
      c += 8;
      if(realloc_wrap((void **)&kevlist, sizeof(struct kevent) * c) != 0)
	{
	  if(kevlistlen == 0)
	    {
	      printerror(errno, strerror, __func__, "could not alloc kevlist");
	      return -1;
	    }
	}
      else
	{
	  kevlistlen = c;
	}
    }

  if(tv != NULL)
    {
      ts.tv_sec  = tv->tv_sec;
      ts.tv_nsec = tv->tv_usec * 1000;
      tsp = &ts;
    }

  if((c = kevent(kq, NULL, 0, kevlist, kevlistlen, tsp)) == -1)
    {
      printerror(errno, strerror, __func__, "kevent failed");
      return -1;
    }

  for(i=0; i<c; i++)
    {
      kev = &kevlist[i];
      fd = kev->ident;

      if(fd < 0 || fd >= fd_array_s)
	continue;
      if((fdp = fd_array[fd]) == NULL)
	continue;
      if(kev->filter == EVFILT_READ)
	fdp->read.cb(fd, fdp->read.param);
      else if(kev->filter == EVFILT_WRITE)
	fdp->write.cb(fd, fdp->write.param);
    }

  return 0;
}
开发者ID:shinglee,项目名称:test,代码行数:54,代码来源:scamper_fds.c

示例11: printerror

/*  This routine provides simple FITS writer. It uses the routines
 *  provided by the fitsTcl/cfitsio libraries
 *
 *  NOTE : It will fail if the image already exists
 */
int ApogeeAltaManager::saveimage(unsigned short *src_buffer, char *filename, int nx, int ny)
{
	fitsfile *fptr;       /* pointer to the FITS file, defined in fitsio.h */
	long  fpixel, nelements;
	unsigned short *array;
	unsigned short *simg;
	int status;
	/* initialize FITS image parameters */
	int bitpix   =  USHORT_IMG; /* 16-bit unsigned short pixel values       */
	long naxis    =   2;  /* 2-dimensional image                            */
	long naxes[2];

	naxes[0] = nx-bcols;
	naxes[1] = ny;
	array = src_buffer;
	status = 0;         /* initialize status before calling fitsio routines */
	simg = (unsigned short *)CCD_locate_buffer(const_cast<char *>("stemp"),2,nx-bcols,ny,1,1);

	if (fits_create_file(&fptr, filename, &status)) /* create new FITS file */
		printerror( status );           /* call printerror if error occurs */

	/* write the required keywords for the primary array image.     */
	/* Since bitpix = USHORT_IMG, this will cause cfitsio to create */
	/* a FITS image with BITPIX = 16 (signed short integers) with   */
	/* BSCALE = 1.0 and BZERO = 32768.  This is the convention that */
	/* FITS uses to store unsigned integers.  Note that the BSCALE  */
	/* and BZERO keywords will be automatically written by cfitsio  */
	/* in this case.                                                */

	if ( fits_create_img(fptr,  bitpix, naxis, naxes, &status) )
		printerror( status );

	fpixel = 1;                               /* first pixel to write      */
	nelements = naxes[0] * naxes[1];          /* number of pixels to write */

	if (bcols > 0)
	{
		dobiassubtract(src_buffer,simg,naxes[0],naxes[1]);

		/* write the array of unsigned integers to the FITS file */
		if ( fits_write_img(fptr, TUSHORT, fpixel, nelements, simg, &status) )
			printerror( status );
	} else
	{
		/* write the array of unsigned integers to the FITS file */
		if ( fits_write_img(fptr, TUSHORT, fpixel, nelements, src_buffer, &status) )
			printerror( status );
	}

	if ( fits_close_file(fptr, &status) )                /* close the file */
		printerror( status );

	return(status);
}
开发者ID:hungrh,项目名称:chimera,代码行数:59,代码来源:ApogeeAltaManager.cpp

示例12: execute

int execute(char **argv, int argc, char *infile, char*outfile, int bg){
	argv[argc] = NULL;
	int pid;
	int status;
	int saved_out;
	int saved_in;
	int in;
	int out;
	
	if(infile!= NULL){
		saved_in = dup(0);
		in = open(infile, O_RDONLY);
		dup2(in, 0);
		close(in);
	}
	if(outfile){
		saved_out = dup(1);
		out = open(outfile, O_WRONLY | O_TRUNC);
		if(out == -1){
			mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
			creat(outfile,mode);
			out = open(outfile,O_WRONLY | O_TRUNC );
		}
		dup2(out,1);
		close(out);
		
	}

	if((pid = fork()) < 0){
		printerror();
	}				
	else if (pid == 0){//child
		
		if(execvp(*argv,argv) < 0){
			printf("exec\n");
			printerror();
		}
		exit(1);
	}
	else{
		waitpid(-1, &status, 0);
		if (infile){
			close(0);
			dup2(saved_in, 0);
		}
		if (outfile){
			close(1);
			dup2(saved_out,1);
		}
	}	
}
开发者ID:ketki95,项目名称:3-1,代码行数:51,代码来源:shell.c

示例13: addr2mac_add

static int addr2mac_add(const int ifindex, const int type, const void *ipraw,
			const void *macraw, const time_t expire)
{
  const int mt = SCAMPER_ADDR_TYPE_ETHERNET;
  scamper_addr_t *mac = NULL;
  scamper_addr_t *ip  = NULL;
  addr2mac_t *addr2mac = NULL;
  char ipstr[128], macstr[128];

  if((ip = scamper_addrcache_get(addrcache, type, ipraw)) == NULL)
    {
      printerror(errno, strerror, __func__, "could not get ip");
      goto err;
    }

  if((mac = scamper_addrcache_get(addrcache, mt, macraw)) == NULL)
    {
      printerror(errno, strerror, __func__, "could not get mac");
      goto err;
    }

  if((addr2mac = addr2mac_alloc(ifindex, ip, mac, expire)) == NULL)
    {
      goto err;
    }

  scamper_addr_free(ip);  ip  = NULL;
  scamper_addr_free(mac); mac = NULL;

  if(splaytree_insert(tree, addr2mac) == NULL)
    {
      printerror(errno, strerror, __func__, "could not add %s:%s to tree",
		 scamper_addr_tostr(addr2mac->ip, ipstr, sizeof(ipstr)),
		 scamper_addr_tostr(addr2mac->mac, macstr, sizeof(macstr)));
      goto err;
    }

  scamper_debug(__func__, "ifindex %d ip %s mac %s expire %d", ifindex,
		scamper_addr_tostr(addr2mac->ip, ipstr, sizeof(ipstr)),
		scamper_addr_tostr(addr2mac->mac, macstr, sizeof(macstr)),
		expire);
  return 0;

 err:
  if(addr2mac != NULL) addr2mac_free(addr2mac);
  if(mac != NULL) scamper_addr_free(mac);
  if(ip != NULL) scamper_addr_free(ip);
  return -1;
}
开发者ID:shinglee,项目名称:test,代码行数:49,代码来源:scamper_addr2mac.c

示例14: main

int main(int argc, char *argv[])
{
    fitsfile *fptr;       /* pointer to the FITS file, defined in fitsio.h */

    int status, nkeys, keypos, hdutype, ii, jj;
    char filename[FLEN_FILENAME];    /* input FITS file */
    char card[FLEN_CARD];   /* standard string lengths defined in fitsioc.h */

    status = 0;

    if (argc == 1)
        strcpy(filename, "-");  /* no command line name, so assume stdin */
    else
        strcpy(filename, argv[1] );   /* name of file to list */


    if ( fits_open_file(&fptr, filename, READONLY, &status) ) 
         printerror( status );

    /* get the current HDU number */
    fits_get_hdu_num(fptr, &ii);

    /* attempt to move to next HDU, until we get an EOF error */
    for (; !(fits_movabs_hdu(fptr, ii, &hdutype, &status) ); ii++) 
    {
        /* get no. of keywords */
        if (fits_get_hdrpos(fptr, &nkeys, &keypos, &status) )
            printerror( status );

        printf("Header listing for HDU #%d:\n", ii);
        for (jj = 1; jj <= nkeys; jj++)  {
            if ( fits_read_record(fptr, jj, card, &status) )
                 printerror( status );

            printf("%s\n", card); /* print the keyword card */
        }
        printf("END\n\n");  /* terminate listing with END */
    }

    if (status == END_OF_FILE)   /* status values are defined in fitsio.h */
        status = 0;              /* got the expected EOF error; reset = 0  */
    else
       printerror( status );     /* got an unexpected error                */

    if ( fits_close_file(fptr, &status) )
         printerror( status );

    return(0);
}
开发者ID:chopley,项目名称:controlCode,代码行数:49,代码来源:listhead.c

示例15: printerror

Score MAP::set(int x, int y, OBJECT *obj)
{
   Score ret;
   if (x>=w || y >= h)
      printerror("object set out of map bounds");


   if (obj->idx == OBJ_UNDEFINED)
      printerror("undefined object : %s",obj->name);


   for (int i=0;i<MAX_OBJ_PERTILE;i++)
       if (the_map[x][y][i] == obj)
          return ret; // it was already there
          
   for (int i=0;i<MAX_OBJ_PERTILE;i++)
   {
      if (!(the_map[x][y][i]))
      {
         the_map[x][y][i] = obj;
         if (obj)
         {
          obj->mapx = x;
          obj->mapy = y;
         }
         ret = playfield->someone_arrived(x,y,obj);
         
         wakeup(x-1,y);
         wakeup(x+1,y);
         wakeup(x,y-1);
         wakeup(x,y+1);
         wakeup(x,y); // make sure evrybody here is awake too
         
         return ret;
      }
   }


   allegro_exit();

   for (int i=0;i<MAX_OBJ_PERTILE;i++)
       printf("%s\n",the_map[x][y][i]->name);
   printf("tile overfull\n");
   exit(1);
       
   printerror("tile overfull");

   return ret;
}
开发者ID:wziard,项目名称:miner,代码行数:49,代码来源:map.cpp


注:本文中的printerror函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。