您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ unpack函数代码示例

51自学网 2021-06-03 09:11:22
  C++
这篇教程C++ unpack函数代码示例写得很实用,希望能帮到您。

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

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

示例1: while

Variant ZendPack::unpack(CStrRef fmt, CStrRef data) {  const char *format = fmt;  int formatlen = fmt.size();  const char *input = data;  int inputlen = data.size();  int inputpos = 0;  Array ret;  while (formatlen-- > 0) {    char type = *(format++);    char c;    int arg = 1, argb;    const char *name;    int namelen;    int size=0;    /* Handle format arguments if any */    if (formatlen > 0) {      c = *format;      if (c >= '0' && c <= '9') {        arg = atoi(format);        while (formatlen > 0 && *format >= '0' && *format <= '9') {          format++;          formatlen--;        }      } else if (c == '*') {        arg = -1;        format++;        formatlen--;      }    }    /* Get of new value in array */    name = format;    argb = arg;    while (formatlen > 0 && *format != '/') {      formatlen--;      format++;    }    namelen = format - name;    if (namelen > 200)      namelen = 200;    switch ((int) type) {      /* Never use any input */    case 'X':      size = -1;      break;    case '@':      size = 0;      break;    case 'a':    case 'A':      size = arg;      arg = 1;      break;    case 'h':    case 'H':      size = (arg > 0) ? (arg + (arg % 2)) / 2 : arg;      arg = 1;      break;      /* Use 1 byte of input */    case 'c':    case 'C':    case 'x':      size = 1;      break;      /* Use 2 bytes of input */    case 's':    case 'S':    case 'n':    case 'v':      size = 2;      break;      /* Use sizeof(int) bytes of input */    case 'i':    case 'I':      size = sizeof(int);      break;      /* Use 4 bytes of input */    case 'l':    case 'L':    case 'N':    case 'V':      size = 4;      break;      /* Use sizeof(float) bytes of input *///.........这里部分代码省略.........
开发者ID:JustProgrammer,项目名称:hiphop-php,代码行数:101,


示例2: main

//.........这里部分代码省略.........      Loc<2> edge = *pos;      Loc<2> rightCell = edge;  // cell to right is same cell      Loc<2> leftCell = edge - Loc<2>(1,0);      Loc<2> topVert = edge + Loc<2>(0, 1);      Loc<2> bottomVert = edge;      local2(edge) =        local0.read(rightCell) + local0.read(leftCell) +        local1.read(topVert) + local1.read(bottomVert);    }    // This statement is optional, it tries to compress the patch after    // we're done computing on it.  Since I used .read() for the local0 and 1    // they remained in their original state. compress() can be expensive, so    // it may not be worth trying unless space is really important.    compress(local2);  }  tester.out() << "c0" << std::endl << c0 << std::endl;  tester.out() << "c1" << std::endl << c1 << std::endl;  tester.out() << "c2" << std::endl << c2 << std::endl;  //------------------------------------------------------------------  // Interfacing with a c-function:  //  // This example handles the corner cases, where the patches from a  // cell centered field with no guard layers actually contain some  // extra data.  Pooma::blockAndEvaluate();  for (i = 0; i < cb0.numPatchesLocal(); ++i)  {    Patch<CField_t>::Type_t local0 = cb0.patchLocal(i);    Interval<2> physicalDomain = local0.physicalDomain();    double *data;    int size = physicalDomain.size();    if (physicalDomain == local0.totalDomain())    {      uncompress(local0);      data = &local0(physicalDomain.firsts());      nonsense(data, size);    }    else    {      // In this case, the engine has extra storage even though the      // field has the right domain. We copy it to a brick engine,      // call the function and copy it back.  No uncompress is required,      // since the assignment will copy the compressed value into the      // brick.      // arrayView is a work-around.  Array = Field doesn't work at      // the moment.      Array<2, double, Brick> brick(physicalDomain);      Array<2, double, CompressibleBrick> arrayView(local0.engine());      brick = arrayView(physicalDomain);      Pooma::blockAndEvaluate();      data = &brick(Loc<2>(0));      nonsense(data, size);      arrayView(physicalDomain) = brick;      // Note that we don't need a blockAndEvaluate here, since an iterate has      // been spawned to perform the copy.    }    // If you want to try compress(local0) here, you should do blockAndEvaluate    // first in case the local0 = brick hasn't been executed yet.  }        tester.out() << "cb0.all()" << std::endl << cb0 << std::endl;  b2 = positions(b2).comp(0);  RefCountedBlockPtr<double> block = pack(b2);  // The following functions give you access to the raw data from pack.  // Note that the lifetime of the data is managed by the RefCountedBlockPtr,  // so when "block" goes out of scope, the data goes away.  (i.e. Don't write  // a function where you return block.beginPointer().)  double *start = block.beginPointer();  // start of the data  double *end = block.endPointer();      // one past the end  int size = block.size();               // size of the data  tester.out() << Pooma::context() << ":" << block.size() << std::endl;  unpack(b3, block);  tester.out() << "b2" << std::endl << b2 << std::endl;  tester.out() << "b3" << std::endl << b3 << std::endl;  tester.check("pack, unpack", all(b2 == b3));  int ret = tester.results("LocalPatch");  Pooma::finalize();  return ret;}
开发者ID:pathscale,项目名称:freepooma-testsuite,代码行数:101,


示例3: unpack_object

static int unpack_object(scanner_t *s, json_t *root, va_list *ap){    int ret = -1;    int strict = 0;    /* Use a set (emulated by a hashtable) to check that all object       keys are accessed. Checking that the correct number of keys       were accessed is not enough, as the same key can be unpacked       multiple times.    */    hashtable_t key_set;    if(hashtable_init(&key_set)) {        set_error(s, "<internal>", "Out of memory");        return -1;    }    if(root && !json_is_object(root)) {        set_error(s, "<validation>", "Expected object, got %s",                  type_name(root));        goto out;    }    next_token(s);    while(s->token != '}') {        const char *key;        json_t *value;        int opt = 0;        if(strict != 0) {            set_error(s, "<format>", "Expected '}' after '%c', got '%c'",                      (strict == 1 ? '!' : '*'), s->token);            goto out;        }        if(!s->token) {            set_error(s, "<format>", "Unexpected end of format string");            goto out;        }        if(s->token == '!' || s->token == '*') {            strict = (s->token == '!' ? 1 : -1);            next_token(s);            continue;        }        if(s->token != 's') {            set_error(s, "<format>", "Expected format 's', got '%c'", s->token);            goto out;        }        key = va_arg(*ap, const char *);        if(!key) {            set_error(s, "<args>", "NULL object key");            goto out;        }        next_token(s);        if(s->token == '?') {            opt = 1;            next_token(s);        }        if(!root) {            /* skipping */            value = NULL;        }        else {            value = json_object_get(root, key);            if(!value && !opt) {                set_error(s, "<validation>", "Object item not found: %s", key);                goto out;            }        }        if(unpack(s, value, ap))            goto out;        hashtable_set(&key_set, key, 0, json_null());        next_token(s);    }    if(strict == 0 && (s->flags & JSON_STRICT))        strict = 1;    if(root && strict == 1 && key_set.size != json_object_size(root)) {        long diff = (long)json_object_size(root) - (long)key_set.size;        set_error(s, "<validation>", "%li object item(s) left unpacked", diff);        goto out;    }    ret = 0;out:    hashtable_close(&key_set);    return ret;}
开发者ID:mkawick,项目名称:Station04,代码行数:98,


示例4: codec2_decode_3200

void codec2_decode_3200(struct CODEC2 *c2, short speech[], const unsigned char * bits){    MODEL   model[2];    int     lspd_indexes[LPC_ORD];    float   lsps[2][LPC_ORD];    int     Wo_index, e_index;    float   e[2];    float   snr;    float   ak[2][LPC_ORD+1];    int     i,j;    unsigned int nbit = 0;    assert(c2 != NULL);        /* only need to zero these out due to (unused) snr calculation */    for(i=0; i<2; i++)	for(j=1; j<=MAX_AMP; j++)	    model[i].A[j] = 0.0;    /* unpack bits from channel ------------------------------------*/    /* this will partially fill the model params for the 2 x 10ms       frames */    model[0].voiced = unpack(bits, &nbit, 1);    model[1].voiced = unpack(bits, &nbit, 1);    Wo_index = unpack(bits, &nbit, WO_BITS);    model[1].Wo = decode_Wo(Wo_index);    model[1].L  = PI/model[1].Wo;    e_index = unpack(bits, &nbit, E_BITS);    e[1] = decode_energy(e_index);    for(i=0; i<LSPD_SCALAR_INDEXES; i++) {	lspd_indexes[i] = unpack(bits, &nbit, lspd_bits(i));    }    decode_lspds_scalar(&lsps[1][0], lspd_indexes, LPC_ORD);     /* interpolate ------------------------------------------------*/    /* Wo and energy are sampled every 20ms, so we interpolate just 1       10ms frame between 20ms samples */    interp_Wo(&model[0], &c2->prev_model_dec, &model[1]);    e[0] = interp_energy(c2->prev_e_dec, e[1]);     /* LSPs are sampled every 20ms so we interpolate the frame in       between, then recover spectral amplitudes */    interpolate_lsp_ver2(&lsps[0][0], c2->prev_lsps_dec, &lsps[1][0], 0.5);    for(i=0; i<2; i++) {	lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD);	aks_to_M2(c2->fft_fwd_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 0, 0,                   c2->lpc_pf, c2->bass_boost, c2->beta, c2->gamma); 	apply_lpc_correction(&model[i]);    }    /* synthesise ------------------------------------------------*/    for(i=0; i<2; i++)	synthesise_one_frame(c2, &speech[N*i], &model[i], &ak[i][0]);    /* update memories for next frame ----------------------------*/    c2->prev_model_dec = model[1];    c2->prev_e_dec = e[1];    for(i=0; i<LPC_ORD; i++)	c2->prev_lsps_dec[i] = lsps[1][i];}
开发者ID:AhmedObaidi,项目名称:codec2-android,代码行数:71,


示例5: TeleDisk_libLoad_DiskFile

//.........这里部分代码省略.........	CRC16_Init(&CRC16_High,&CRC16_Low,(unsigned char*)crctable,0xA097,0x0000);	ptr=(unsigned char*)td_header;	for(i=0;i<0xA;i++)	{		CRC16_Update(&CRC16_High,&CRC16_Low, ptr[i],(unsigned char*)crctable );	}	if(((td_header->CRC[1]<<8)|td_header->CRC[0])!=((CRC16_High<<8)|CRC16_Low))	{		imgldr_ctx->hxcfe->hxc_printf(MSG_ERROR,"TeleDisk_libLoad_DiskFile : bad header crc !");		free(fileimage);		return HXCFE_BADFILE;	}	imgldr_ctx->hxcfe->hxc_printf(MSG_INFO_1,"TeleDisk_libLoad_DiskFile : Teledisk version : %d",td_header->TDVer);	if((td_header->TDVer>21) || (td_header->TDVer<10))	{		imgldr_ctx->hxcfe->hxc_printf(MSG_ERROR,"TeleDisk_libLoad_DiskFile : Unsupported version !");		free(fileimage);		return HXCFE_BADFILE;	}	Compress=0;	if(((td_header->TXT[0]=='T') && (td_header->TXT[1]=='D')))	{		imgldr_ctx->hxcfe->hxc_printf(MSG_INFO_1,"TeleDisk_libLoad_DiskFile : Normal compression");		Compress=0;	}	if(((td_header->TXT[0]=='t') && (td_header->TXT[1]=='d')))	{		imgldr_ctx->hxcfe->hxc_printf(MSG_INFO_1,"TeleDisk_libLoad_DiskFile : Advanced compression");		fileimage=unpack(fileimage,filesize);		Compress=1;	}	td_header=(TELEDISK_HEADER*)&fileimage[0];	if(td_header->TrkDens&0x80)	{		CRC16_Init(&CRC16_High,&CRC16_Low,(unsigned char*)crctable,0xA097,0x0000);		td_comment=(TELEDISK_COMMENT *)&fileimage[fileimage_buffer_offset];		fileimage_buffer_offset=fileimage_buffer_offset+sizeof(TELEDISK_COMMENT);		//fread( &td_comment, sizeof(td_comment), 1, f );		ptr=(unsigned char*)td_comment;		ptr=ptr+2;		for(i=0;i<sizeof(TELEDISK_COMMENT)-2;i++)		{			CRC16_Update(&CRC16_High,&CRC16_Low, ptr[i],(unsigned char*)crctable );		}		memcpy(&tempdata,&fileimage[fileimage_buffer_offset],td_comment->Len);		fileimage_buffer_offset=fileimage_buffer_offset+td_comment->Len;		ptr=(unsigned char*)&tempdata;		for(i=0;i<td_comment->Len;i++)		{			CRC16_Update(&CRC16_High,&CRC16_Low, ptr[i],(unsigned char*)crctable );		}		imgldr_ctx->hxcfe->hxc_printf(MSG_INFO_1,"TeleDisk_libLoad_DiskFile : Creation date: %.2d/%.2d/%.4d %.2d:%.2d:%.2d",td_comment->bDay,/
开发者ID:christopherkobayashi,项目名称:libhxcfe,代码行数:67,


示例6: main

int main(int carg, char *varg[]){	size_t i;	char *filename;	char *dir;	char *metafile;	pup_mode_t mode;	plugin_t *p;		filename = NULL;	dir = NULL;	metafile = NULL;	mode = NONE;	p = NULL;	for(i = 1; i < carg; i++)	{		if (strcmp(varg[i], "--plugin") == 0)		{			i++;			if ((i < carg) && (strncmp(varg[i], "--", 2) != 0))				p = select_plugin(varg[i]);		}		else if (strcmp(varg[i], "--pack") == 0)		{			mode = PACK;			i++;			if ((i < carg) && (strncmp(varg[i], "--", 2) != 0))				filename = varg[i];			i++;			if ((i < carg) && (strncmp(varg[i], "--", 2) != 0))				dir = varg[i];			i++;			if ((i < carg) && (strncmp(varg[i], "--", 2) != 0))				metafile = varg[i];		}		else if (strcmp(varg[i], "--unpack") == 0)		{			mode = UNPACK;			i++;			if ((i < carg) && (strncmp(varg[i], "--", 2) != 0))				filename = varg[i];			i++;			if ((i < carg) && (strncmp(varg[i], "--", 2) != 0))				dir = varg[i];			i++;			if ((i < carg) && (strncmp(varg[i], "--", 2) != 0))				metafile = varg[i];		}		else if (strcmp(varg[i], "--print") == 0)		{			mode = PRINT;			i++;			if ((i < carg) && (strncmp(varg[i], "--", 2) != 0))				filename = varg[i];		}		else if (strcmp(varg[i], "--savemeta") == 0)		{			mode = SAVEMETA;			i++;			if ((i < carg) && (strncmp(varg[i], "--", 2) != 0))				filename = varg[i];			i++;			if ((i < carg) && (strncmp(varg[i], "--", 2) != 0))				metafile = varg[i];		}		else if (strcmp(varg[i], "--list") == 0)			mode = LIST;		else		{			fprintf(stderr, "Unknown option: %s/n", varg[i]);			return 1;		}	}		if ((filename == NULL) && ((mode == PACK) || (mode == UNPACK) || (mode == PRINT) || (mode == SAVEMETA)))	{		fprintf(stderr, "You must specify filename for this mode./n");		return 2;	}	if ((metafile == NULL) && (mode == SAVEMETA))	{		fprintf(stderr, "You must specify metafile for this mode./n");		return 2;	}		if (mode == LIST)		list_plugins();	else if (mode == PACK)	{		if (pack(p, filename, dir, metafile) == FALSE)			return 3;	}	else if (mode == UNPACK)	{		if (unpack(p, filename, dir, metafile) == FALSE)			return 4;	}	else if (mode == SAVEMETA)	{//.........这里部分代码省略.........
开发者ID:old-games,项目名称:game-utilities,代码行数:101,


示例7: handle_stdin

static voidhandle_stdin(void){	unsigned char header1[4];	off_t usize, gsize;	enum filetype method;	ssize_t bytes_read;#ifndef NO_COMPRESS_SUPPORT	FILE *in;#endif#ifndef SMALL	if (fflag == 0 && lflag == 0 && isatty(STDIN_FILENO)) {		maybe_warnx("standard input is a terminal -- ignoring");		return;	}#endif	if (lflag) {		struct stat isb;		/* XXX could read the whole file, etc. */		if (fstat(STDIN_FILENO, &isb) < 0) {			maybe_warn("fstat");			return;		}		print_list(STDIN_FILENO, isb.st_size, "stdout", isb.st_mtime);		return;	}	bytes_read = read_retry(STDIN_FILENO, header1, sizeof header1);	if (bytes_read == -1) {		maybe_warn("can't read stdin");		return;	} else if (bytes_read != sizeof(header1)) {		maybe_warnx("(stdin): unexpected end of file");		return;	}	method = file_gettype(header1);	switch (method) {	default:#ifndef SMALL		if (fflag == 0) {			maybe_warnx("unknown compression format");			return;		}		usize = cat_fd(header1, sizeof header1, &gsize, STDIN_FILENO);		break;#endif	case FT_GZIP:		usize = gz_uncompress(STDIN_FILENO, STDOUT_FILENO, 			      (char *)header1, sizeof header1, &gsize, "(stdin)");		break;#ifndef NO_BZIP2_SUPPORT	case FT_BZIP2:		usize = unbzip2(STDIN_FILENO, STDOUT_FILENO,				(char *)header1, sizeof header1, &gsize);		break;#endif#ifndef NO_COMPRESS_SUPPORT	case FT_Z:		if ((in = zdopen(STDIN_FILENO)) == NULL) {			maybe_warnx("zopen of stdin");			return;		}		usize = zuncompress(in, stdout, (char *)header1,		    sizeof header1, &gsize);		fclose(in);		break;#endif#ifndef NO_PACK_SUPPORT	case FT_PACK:		usize = unpack(STDIN_FILENO, STDOUT_FILENO,			       (char *)header1, sizeof header1, &gsize);		break;#endif#ifndef NO_XZ_SUPPORT	case FT_XZ:		usize = unxz(STDIN_FILENO, STDOUT_FILENO,			     (char *)header1, sizeof header1, &gsize);		break;#endif	}#ifndef SMALL        if (vflag && !tflag && usize != -1 && gsize != -1)		print_verbage(NULL, NULL, usize, gsize);	if (vflag && tflag)		print_test("(stdin)", usize != -1);#endif }
开发者ID:jamesbjackson,项目名称:src,代码行数:94,


示例8: GameNetworkMessage

RequestGalaxyLoopTimes::RequestGalaxyLoopTimes(Archive::ReadIterator & source) :GameNetworkMessage("RequestGalaxyLoopTimes"){	unpack(source);}
开发者ID:Mesagoppinmypants,项目名称:NGELinux,代码行数:5,


示例9: aes_ecb_decrypt

static void aes_ecb_decrypt(aes *a,BYTE *buff){    int i,j,k;    WORD p[4],q[4],*x,*y,*t;    for (i=j=0; i<NB; i++,j+=4)    {        p[i]=pack((BYTE *)&buff[j]);        p[i]^=a->rkey[i];    }    k=NB;    x=p;    y=q;    /* State alternates between x and y */    for (i=1; i<a->Nr; i++)    {   /* Nr is number of rounds. May be odd. */#ifdef LOTS_OF_MEMORY        y[0]=a->rkey[k]^rtable[(BYTE)x[0]]^             rtable1[(BYTE)(x[3]>>8)]^             rtable2[(BYTE)(x[2]>>16)]^             rtable3[x[1]>>24];        y[1]=a->rkey[k+1]^rtable[(BYTE)x[1]]^             rtable1[(BYTE)(x[0]>>8)]^             rtable2[(BYTE)(x[3]>>16)]^             rtable3[x[2]>>24];        y[2]=a->rkey[k+2]^rtable[(BYTE)x[2]]^             rtable1[(BYTE)(x[1]>>8)]^             rtable2[(BYTE)(x[0]>>16)]^             rtable3[x[3]>>24];        y[3]=a->rkey[k+3]^rtable[(BYTE)x[3]]^             rtable1[(BYTE)(x[2]>>8)]^             rtable2[(BYTE)(x[1]>>16)]^             rtable3[x[0]>>24];#else        y[0]=a->rkey[k]^rtable[(BYTE)x[0]]^             ROTL8(rtable[(BYTE)(x[3]>>8)])^             ROTL16(rtable[(BYTE)(x[2]>>16)])^             ROTL24(rtable[x[1]>>24]);        y[1]=a->rkey[k+1]^rtable[(BYTE)x[1]]^             ROTL8(rtable[(BYTE)(x[0]>>8)])^             ROTL16(rtable[(BYTE)(x[3]>>16)])^             ROTL24(rtable[x[2]>>24]);        y[2]=a->rkey[k+2]^rtable[(BYTE)x[2]]^             ROTL8(rtable[(BYTE)(x[1]>>8)])^             ROTL16(rtable[(BYTE)(x[0]>>16)])^             ROTL24(rtable[x[3]>>24]);        y[3]=a->rkey[k+3]^rtable[(BYTE)x[3]]^             ROTL8(rtable[(BYTE)(x[2]>>8)])^             ROTL16(rtable[(BYTE)(x[1]>>16)])^             ROTL24(rtable[x[0]>>24]);#endif        k+=4;        t=x;        x=y;        y=t;      /* swap pointers */    }    /* Last Round */    y[0]=a->rkey[k]^(WORD)rbsub[(BYTE)x[0]]^         ROTL8((WORD)rbsub[(BYTE)(x[3]>>8)])^         ROTL16((WORD)rbsub[(BYTE)(x[2]>>16)])^         ROTL24((WORD)rbsub[x[1]>>24]);    y[1]=a->rkey[k+1]^(WORD)rbsub[(BYTE)x[1]]^         ROTL8((WORD)rbsub[(BYTE)(x[0]>>8)])^         ROTL16((WORD)rbsub[(BYTE)(x[3]>>16)])^         ROTL24((WORD)rbsub[x[2]>>24]);    y[2]=a->rkey[k+2]^(WORD)rbsub[(BYTE)x[2]]^         ROTL8((WORD)rbsub[(BYTE)(x[1]>>8)])^         ROTL16((WORD)rbsub[(BYTE)(x[0]>>16)])^         ROTL24((WORD)rbsub[x[3]>>24]);    y[3]=a->rkey[k+3]^(WORD)rbsub[(BYTE)x[3]]^         ROTL8((WORD)rbsub[(BYTE)(x[2]>>8)])^         ROTL16((WORD)rbsub[(BYTE)(x[1]>>16)])^         ROTL24((WORD)rbsub[x[0]>>24]);    for (i=j=0; i<NB; i++,j+=4)    {        unpack(y[i],(BYTE *)&buff[j]);        x[i]=y[i]=0;   /* clean up stack */    }}
开发者ID:karllen,项目名称:Windows_Program,代码行数:84,


示例10: mail1

/* * Mail a message on standard input to the people indicated * in the passed header.  (Internal interface). */voidmail1(struct header *hp, int printheaders){	char *cp;	char *nbuf;	int pid;	char **namelist;	struct name *to, *nsto;	FILE *mtf;	/*	 * Collect user's mail from standard input.	 * Get the result as mtf.	 */	if ((mtf = collect(hp, printheaders)) == NULL)		return;	if (value("interactive") != NULL) {		if (value("askcc") != NULL || value("askbcc") != NULL) {			if (value("askcc") != NULL)				grabh(hp, GCC);			if (value("askbcc") != NULL)				grabh(hp, GBCC);		} else {			printf("EOT/n");			(void)fflush(stdout);		}	}	if (fsize(mtf) == 0) {		if (value("dontsendempty") != NULL)			goto out;		if (hp->h_subject == NULL)			printf("No message, no subject; hope that's ok/n");		else			printf("Null message body; hope that's ok/n");	}	/*	 * Now, take the user names from the combined	 * to and cc lists and do all the alias	 * processing.	 */	senderr = 0;	to = usermap(cat(hp->h_bcc, cat(hp->h_to, hp->h_cc)));	if (to == NULL) {		printf("No recipients specified/n");		senderr++;	}	/*	 * Look through the recipient list for names with /'s	 * in them which we write to as files directly.	 */	to = outof(to, mtf, hp);	if (senderr)		savedeadletter(mtf);	to = elide(to);	if (count(to) == 0)		goto out;	if (value("recordrecip") != NULL) {		/*		 * Before fixing the header, save old To:.		 * We do this because elide above has sorted To: list, and		 * we would like to save message in a file named by the first		 * recipient the user has entered, not the one being the first		 * after sorting happened.		 */		if ((nsto = malloc(sizeof(struct name))) == NULL)			err(1, "Out of memory");		bcopy(hp->h_to, nsto, sizeof(struct name));	}	fixhead(hp, to);	if ((mtf = infix(hp, mtf)) == NULL) {		fprintf(stderr, ". . . message lost, sorry./n");		return;	}	namelist = unpack(cat(hp->h_smopts, to));	if (debug) {		char **t;		printf("Sendmail arguments:");		for (t = namelist; *t != NULL; t++)			printf(" /"%s/"", *t);		printf("/n");		goto out;	}	if (value("recordrecip") != NULL) {		/*		 * Extract first recipient username from saved To: and use it		 * as a filename.		 */		if ((nbuf = malloc(strlen(detract(nsto, 0)) + 1)) == NULL)			err(1, "Out of memory");		if ((cp = yanklogin(detract(nsto, 0), nbuf)) != NULL)			(void)savemail(expand(nbuf), mtf);		free(nbuf);		free(nsto);	} else if ((cp = value("record")) != NULL)		(void)savemail(expand(cp), mtf);//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:freebsd,代码行数:101,


示例11: main

//.........这里部分代码省略.........		/*<-SELECT-> */		if(select(maxfd+1, &readfds, NULL, NULL, &tvcop) == -1){			perror("program: error on select()");			close(tcp_sourcefd);			//close(newfd);			exit(1);		}		/*<-ACTIVE TCP SOCKET CHECK for ACTIVE CLIENTS-> */		//expects setStation: 8 +16		for(s=station_0;s!=NULL;s=s->si_next){			printf("1/n");		for(c=s->client_list;c!=NULL;c=c->ci_next){			//did you say something, i?			printf("checking active client %d/n",c->ci_fd);			if(FD_ISSET(c->ci_fd, &readfds)){				printf("new message from active client %d/n", c->ci_fd);				if((request_bytes = recv(c->ci_fd, request, sizeof request, 0)) == -1){					perror("recv()");					continue;				}				if(!request_bytes){					printf("client quits/n");					//TODO get rid of the client from the active list					//TODO how to get the next highest fd number?					if(c->ci_fd == maxfd) maxfd = maxfd-1;					FD_CLR(c->ci_fd, &masterfds);					close(c->ci_fd);					continue; 				}				unpack(request, "ch", &commandType, &udpPort);				printf("bytes_received: %d /n commandType: %hd/n udpPort: %d/n", request_bytes, commandType, udpPort);			}		}		}			/*<-PASSIVE TCP: New Client connect()-> */			if (FD_ISSET(tcp_sourcefd, &readfds)){			client_count++;			printf("new client!/n");			int clientfd = accept(tcp_sourcefd, (struct sockaddr *)&their_addr, &ss_size);			if ( clientfd == -1 ) {				perror("program: error on accept()/n");				close(tcp_sourcefd);				exit(1);			}			//announce new connection			inet_ntop(their_addr.ss_family,				get_in_addr( (struct sockaddr *)&their_addr),				addr_str, sizeof addr_str);			printf("connection accepted from: %s/n", addr_str);			//make client_info struct 			struct client_info *newclient = (struct client_info *) malloc(sizeof(struct client_info));			newclient->ci_family = their_addr.ss_family;			newclient->ci_addr = addr_str;			newclient->ci_next = NULL;			newclient->ci_fd = clientfd;			//add client to the pending list
开发者ID:pqhwan,项目名称:snowcast,代码行数:67,


示例12: while

bvt float_utilst::div(const bvt &src1, const bvt &src2){  // unpack  const unbiased_floatt unpacked1=unpack(src1);  const unbiased_floatt unpacked2=unpack(src2);  std::size_t div_width=unpacked1.fraction.size()*2+1;  // pad fraction1 with zeros  bvt fraction1=unpacked1.fraction;  fraction1.reserve(div_width);  while(fraction1.size()<div_width)    fraction1.insert(fraction1.begin(), const_literal(false));  // zero-extend fraction2  const bvt fraction2=    bv_utils.zero_extension(unpacked2.fraction, div_width);  // divide fractions  unbiased_floatt result;  bvt rem;  bv_utils.unsigned_divider(fraction1, fraction2, result.fraction, rem);  // is there a remainder?  literalt have_remainder=bv_utils.is_not_zero(rem);  // we throw this into the result, as one additional bit,  // to get the right rounding decision  result.fraction.insert(    result.fraction.begin(), have_remainder);  // We will subtract the exponents;  // to account for overflow, we add a bit.  // we add a second bit for the adjust by extra fraction bits  const bvt exponent1=bv_utils.sign_extension(unpacked1.exponent, unpacked1.exponent.size()+2);  const bvt exponent2=bv_utils.sign_extension(unpacked2.exponent, unpacked2.exponent.size()+2);  // subtract exponents  bvt added_exponent=bv_utils.sub(exponent1, exponent2);  // adjust, as we have thown in extra fraction bits  result.exponent=bv_utils.add(    added_exponent,    bv_utils.build_constant(spec.f, added_exponent.size()));  // new sign  result.sign=prop.lxor(unpacked1.sign, unpacked2.sign);  // Infinity? This happens when  // 1) dividing a non-nan/non-zero by zero, or  // 2) first operand is inf and second is non-nan and non-zero  // In particular, inf/0=inf.  result.infinity=    prop.lor(      prop.land(!unpacked1.zero,      prop.land(!unpacked1.NaN,                unpacked2.zero)),      prop.land(unpacked1.infinity,      prop.land(!unpacked2.NaN,                !unpacked2.zero)));  // NaN?  result.NaN=prop.lor(unpacked1.NaN,             prop.lor(unpacked2.NaN,             prop.lor(prop.land(unpacked1.zero, unpacked2.zero),                      prop.land(unpacked1.infinity, unpacked2.infinity))));  // Division by infinity produces zero, unless we have NaN  literalt force_zero=    prop.land(!unpacked1.NaN, unpacked2.infinity);  result.fraction=bv_utils.select(force_zero,    bv_utils.zeros(result.fraction.size()), result.fraction);  return rounder(result);}
开发者ID:diffblue,项目名称:cbmc,代码行数:76,


示例13: add_sub

bvt float_utilst::add_sub(  const bvt &src1,  const bvt &src2,  bool subtract){  unbiased_floatt unpacked1=unpack(src1);  unbiased_floatt unpacked2=unpack(src2);  // subtract?  if(subtract)    unpacked2.sign=!unpacked2.sign;  // figure out which operand has the bigger exponent  const bvt exponent_difference=subtract_exponents(unpacked1, unpacked2);  literalt src2_bigger=exponent_difference.back();  const bvt bigger_exponent=    bv_utils.select(src2_bigger, unpacked2.exponent, unpacked1.exponent);  // swap fractions as needed  const bvt new_fraction1=    bv_utils.select(src2_bigger, unpacked2.fraction, unpacked1.fraction);  const bvt new_fraction2=    bv_utils.select(src2_bigger, unpacked1.fraction, unpacked2.fraction);  // compute distance  const bvt distance=bv_utils.absolute_value(exponent_difference);  // limit the distance: shifting more than f+3 bits is unnecessary  const bvt limited_dist=limit_distance(distance, spec.f+3);  // pad fractions with 2 zeros from below  const bvt fraction1_padded=bv_utils.concatenate(bv_utils.zeros(3), new_fraction1);  const bvt fraction2_padded=bv_utils.concatenate(bv_utils.zeros(3), new_fraction2);  // shift new_fraction2  literalt sticky_bit;  const bvt fraction1_shifted=fraction1_padded;  const bvt fraction2_shifted=sticky_right_shift(    fraction2_padded, limited_dist, sticky_bit);  // sticky bit: or of the bits lost by the right-shift  bvt fraction2_stickied=fraction2_shifted;  fraction2_stickied[0]=prop.lor(fraction2_shifted[0], sticky_bit);  // need to have two extra fraction bits for addition and rounding  const bvt fraction1_ext=bv_utils.zero_extension(fraction1_shifted, fraction1_shifted.size()+2);  const bvt fraction2_ext=bv_utils.zero_extension(fraction2_stickied, fraction2_stickied.size()+2);  unbiased_floatt result;  // now add/sub them  literalt subtract_lit=prop.lxor(unpacked1.sign, unpacked2.sign);  result.fraction=    bv_utils.add_sub(fraction1_ext, fraction2_ext, subtract_lit);  // sign of result  literalt fraction_sign=result.fraction.back();  result.fraction=bv_utils.absolute_value(result.fraction);  result.exponent=bigger_exponent;  // adjust the exponent for the fact that we added two bits to the fraction  result.exponent=    bv_utils.add(bv_utils.sign_extension(result.exponent, result.exponent.size()+1),      bv_utils.build_constant(2, result.exponent.size()+1));  // NaN?  result.NaN=prop.lor(      prop.land(prop.land(unpacked1.infinity, unpacked2.infinity),                prop.lxor(unpacked1.sign, unpacked2.sign)),      prop.lor(unpacked1.NaN, unpacked2.NaN));  // infinity?  result.infinity=prop.land(      !result.NaN,      prop.lor(unpacked1.infinity, unpacked2.infinity));  // zero?  // Note that:  //  1. The zero flag isn't used apart from in divide and  //     is only set on unpack  //  2. Subnormals mean that addition or subtraction can't round to 0,  //     thus we can perform this test now  //  3. The rules for sign are different for zero  result.zero = prop.land(      !prop.lor(result.infinity, result.NaN),      !prop.lor(result.fraction));  // sign  literalt add_sub_sign=    prop.lxor(prop.lselect(src2_bigger, unpacked2.sign, unpacked1.sign),              fraction_sign);  literalt infinity_sign=    prop.lselect(unpacked1.infinity, unpacked1.sign, unpacked2.sign);  #if 1//.........这里部分代码省略.........
开发者ID:diffblue,项目名称:cbmc,代码行数:101,


示例14: assert

bvt float_utilst::conversion(  const bvt &src,  const ieee_float_spect &dest_spec){  assert(src.size()==spec.width());  #if 1  // Catch the special case in which we extend,  // e.g. single to double.  // In this case, rounding can be avoided,  // but a denormal number may be come normal.  // Be careful to exclude the difficult case  // when denormalised numbers in the old format  // can be converted to denormalised numbers in the  // new format.  Note that this is rare and will only  // happen with very non-standard formats.  int sourceSmallestNormalExponent = -((1 << (spec.e - 1)) - 1);  int sourceSmallestDenormalExponent =    sourceSmallestNormalExponent - spec.f;  // Using the fact that f doesn't include the hidden bit  int destSmallestNormalExponent = -((1 << (dest_spec.e - 1)) - 1);  if(dest_spec.e>=spec.e &&     dest_spec.f>=spec.f &&     !(sourceSmallestDenormalExponent < destSmallestNormalExponent))  {    unbiased_floatt unpacked_src=unpack(src);    unbiased_floatt result;    // the fraction gets zero-padded    std::size_t padding=dest_spec.f-spec.f;    result.fraction=      bv_utils.concatenate(bv_utils.zeros(padding), unpacked_src.fraction);    // the exponent gets sign-extended    result.exponent=      bv_utils.sign_extension(unpacked_src.exponent, dest_spec.e);    // if the number was denormal and is normal in the new format,    // normalise it!    if(dest_spec.e > spec.e)    {      normalization_shift(result.fraction,result.exponent);    }    // the flags get copied    result.sign=unpacked_src.sign;    result.NaN=unpacked_src.NaN;    result.infinity=unpacked_src.infinity;    // no rounding needed!    spec=dest_spec;    return pack(bias(result));  }  else  #endif  {    // we actually need to round    unbiased_floatt result=unpack(src);    spec=dest_spec;    return rounder(result);  }}
开发者ID:diffblue,项目名称:cbmc,代码行数:66,


示例15: logF

//.........这里部分代码省略.........         // valBeta=0;         // for(i=0;i<T;i++)valBeta+= (natGrad[i]-natGradOld[i])*gradGamma[i];         valBeta /= squareNormOld;      }else if(method==OPTT_FR ){         valBeta = squareNorm / squareNormOld;      }else if(method==OPTT_HS ){         // already computed:         //valBeta=div=0;         //for(i=0;i<T;i++){         //   valBeta += (natGrad[i]-natGradOld[i])*gradGamma[i];         //   div += (natGrad[i]-natGradOld[i])*gradGammaOld[i];         //}         if(valBetaDiv!=0)valBeta /= valBetaDiv;         else valBeta = 0;      }      if(valBeta>0){         usedSteepest = false;         //for(i=0;i<T;i++)searchDir[i]= -natGrad[i] + valBeta*searchDirOld[i];         // removed need for searchDirOld:         #pragma omp parallel for         for(i=0;i<T;i++)            searchDir[i]= -natGrad[i] + valBeta*searchDir[i];      }else{         usedSteepest = true;         #pragma omp parallel for         for(i=0;i<T;i++)            searchDir[i]= -natGrad[i];      }      //try conjugate step      SWAPD(gradPhi,phiOld);      memcpy(phiOld,phi_sm->val,T*sizeof(double)); // memcpy(phiOld,pack(),T*sizeof(double));      unpack(phiOld,searchDir);      bound = getBound();      iteration++;      // make sure there is an increase in L, else revert to steepest      if((bound<boundOld) && (valBeta>0)){         usedSteepest = true;         #pragma omp parallel for         for(i=0;i<T;i++)            searchDir[i]= -natGrad[i];         unpack(phiOld,searchDir);         bound = getBound();         // this should not be increased: iteration++;      }      if(bound<boundOld) { // If bound decreased even after using steepest, step back and quit.         unpack(phiOld);      }      SWAPD(gradPhi,phiOld);      if(verbose){         #ifdef SHOW_FIXED            messageF("iter(%c): %5.ld  bound: %.3lf grad: %.7lf  beta: %.7lf  fixed: %ld/n",(usedSteepest?'s':'o'),iteration,bound,squareNorm,valBeta,phi->countAboveDelta(0.999));         #else            messageF("iter(%c)[%5.lds]: %5.ld  bound: %.3lf grad: %.7lf  beta: %.7lf/n",(usedSteepest?'s':'o'),(long)timer.getTime(),iteration,bound,squareNorm,valBeta);         #endif      }else if(!quiet){         messageF("/riter(%c): %5.ld  bound: %.3lf grad: %.7lf  beta: %.7lf      ",(usedSteepest?'s':'o'),iteration,bound,squareNorm,valBeta);      }#ifdef LOG_CONV   if((iteration%100==0) ||      ((iteration<500) && (iteration%50==0)) ||      ((iteration<150) && (iteration%10==0)) ||      ((iteration<50) && (iteration%5==0))){      logF<<iteration<<" "<<bound<<" "<<squareNorm;      if(logTimer)logF<<" "<<logTimer->current(0,'m');
开发者ID:BitSeq,项目名称:BitSeq-BioC-old,代码行数:67,


示例16: syncToNS

int syncToNS(NodeAddress *ns, NodeAddress *fs) {	int i = 0;	int success = 0;	fd_set fds;	int n;	struct timeval tv;	int packetSize;	char buf[MAX_BUF_LEN];	memset(buf, 0, sizeof(buf));	int16_t responseMessageType, responseMessageMode;	struct sockaddr_in nsSocketAddr;	nsSocketAddr.sin_family = AF_INET;	nsSocketAddr.sin_port = atoi(ns->portNumber);	inet_pton(AF_INET, ns->ip, &(nsSocketAddr.sin_addr.s_addr));	for (; i < numberOfAttempt && success == 0; i++) {		printf("Requesting Name Server to register... Attempt: %d/r/n", i + 1);		char addressString[1024];		strcpy(addressString, fs->ip);		strcat(addressString, "-");		strcat(addressString, fs->portNumber);		packetSize = pack(buf, "hhs", (int16_t) syncNS, (int16_t) req,				addressString);		if (sendto(controlSocket, buf, packetSize, 0,				(struct sockaddr *) &nsSocketAddr,				sizeof(nsSocketAddr)) == SOCKET_ERROR) {			continue;		}		bzero(buf, sizeof(buf));		FD_ZERO(&fds);		FD_SET(controlSocket, &fds);		tv.tv_sec = 0;		tv.tv_usec = timeOutusec;		n = select(controlSocket + 1, &fds, NULL, NULL, &tv);		if (n == 0)			printf("Timeout occurred to receive response.../r/n"); // timeout!		else if (n == -1)			printf("Error occurred to select while receiving response.../r/n"); // error		else {			if (read(controlSocket, buf,			MAX_BUF_LEN) == SOCKET_ERROR) {				continue;			}			unpack(buf, "hh", &responseMessageType, &responseMessageMode);			if (responseMessageType == syncNS && responseMessageMode == ack)				success = 1;		}	}	return success;}
开发者ID:DebashisGanguly,项目名称:SFTP,代码行数:66,


示例17: ping

//.........这里部分代码省略.........	pingsock = create_icmp6_socket();	memset(&pingaddr, 0, sizeof(struct sockaddr_in));	pingaddr.sin6_family = AF_INET6;	hostent = xgethostbyname2(host, AF_INET6);	if (hostent->h_addrtype != AF_INET6)		bb_error_msg_and_die("unknown address type; only AF_INET6 is currently supported.");	memcpy(&pingaddr.sin6_addr, hostent->h_addr, sizeof(pingaddr.sin6_addr));#ifdef ICMP6_FILTER	{		struct icmp6_filter filt;		if (!(options & O_VERBOSE)) {			ICMP6_FILTER_SETBLOCKALL(&filt);#if 0			if ((options & F_FQDN) || (options & F_FQDNOLD) ||				(options & F_NODEADDR) || (options & F_SUPTYPES))				ICMP6_FILTER_SETPASS(ICMP6_NI_REPLY, &filt);			else#endif				ICMP6_FILTER_SETPASS(ICMP6_ECHO_REPLY, &filt);		} else {			ICMP6_FILTER_SETPASSALL(&filt);		}		if (setsockopt(pingsock, IPPROTO_ICMPV6, ICMP6_FILTER, &filt,					   sizeof(filt)) < 0)			bb_error_msg_and_die("setsockopt(ICMP6_FILTER)");	}#endif /*ICMP6_FILTER*/	/* enable broadcast pings */	sockopt = 1;	setsockopt(pingsock, SOL_SOCKET, SO_BROADCAST, (char *) &sockopt,			   sizeof(sockopt));	/* set recv buf for broadcast pings */	sockopt = 48 * 1024;	setsockopt(pingsock, SOL_SOCKET, SO_RCVBUF, (char *) &sockopt,			   sizeof(sockopt));	sockopt = offsetof(struct icmp6_hdr, icmp6_cksum);	setsockopt(pingsock, SOL_RAW, IPV6_CHECKSUM, (char *) &sockopt,			   sizeof(sockopt));	sockopt = 1;	setsockopt(pingsock, SOL_IPV6, IPV6_HOPLIMIT, (char *) &sockopt,			   sizeof(sockopt));	if (ifname) {		if ((pingaddr.sin6_scope_id = if_nametoindex(ifname)) == 0)			bb_error_msg_and_die("%s: invalid interface name", ifname);	}	printf("PING %s (%s): %d data bytes/n",	           hostent->h_name,			   inet_ntop(AF_INET6, (struct in_addr6 *) &pingaddr.sin6_addr,						 buf, sizeof(buf)),		   datalen);	signal(SIGINT, pingstats);	/* start the ping's going ... */	sendping(0);	/* listen for replies */	msg.msg_name=&from;	msg.msg_namelen=sizeof(from);	msg.msg_iov=&iov;	msg.msg_iovlen=1;	msg.msg_control=control_buf;	iov.iov_base=packet;	iov.iov_len=sizeof(packet);	while (1) {		int c;		struct cmsghdr *cmsgptr = NULL;		int hoplimit=-1;		msg.msg_controllen=sizeof(control_buf);		if ((c = recvmsg(pingsock, &msg, 0)) < 0) {			if (errno == EINTR)				continue;			bb_perror_msg("recvfrom");			continue;		}		for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL;			 cmsgptr = CMSG_NXTHDR(&msg, cmsgptr)) {			if (cmsgptr->cmsg_level == SOL_IPV6 &&				cmsgptr->cmsg_type == IPV6_HOPLIMIT ) {				hoplimit=*(int*)CMSG_DATA(cmsgptr);			}		}		unpack(packet, c, &from, hoplimit);		if (pingcount > 0 && nreceived >= pingcount)			break;	}	pingstats(0);}
开发者ID:patrick-ken,项目名称:bipac-7800nl,代码行数:101,


示例18: unpack

inlineboolConfigValuesFactory::unpack(const UtilBuffer& buf){  return unpack(buf.get_data(), buf.length());}
开发者ID:Baoxiyi-Github,项目名称:Mysql,代码行数:5,


示例19: file_uncompress

//.........这里部分代码省略.........			goto lose;		}		out = fdopen(dup(zfd), "w");		if (out == NULL) {			maybe_warn("fdopen for write: %s", outfile);			fclose(in);			goto lose;		}		size = zuncompress(in, out, NULL, 0, NULL);		/* need to fclose() if ferror() is true... */		if (ferror(in) | fclose(in)) {			maybe_warn("failed infile fclose");			unlink(outfile);			(void)fclose(out);		}		if (fclose(out) != 0) {			maybe_warn("failed outfile fclose");			unlink(outfile);			goto lose;		}		break;	}#endif#ifndef NO_PACK_SUPPORT	case FT_PACK:		if (lflag) {			maybe_warnx("no -l with packed files");			goto lose;		}		size = unpack(fd, zfd, NULL, 0, NULL);		break;#endif#ifndef NO_XZ_SUPPORT	case FT_XZ:		if (lflag) {			maybe_warnx("no -l with xz files");			goto lose;		}		size = unxz(fd, zfd, NULL, 0, NULL);		break;#endif#ifndef SMALL	case FT_UNKNOWN:		if (lflag) {			maybe_warnx("no -l for unknown filetypes");			goto lose;		}		size = cat_fd(NULL, 0, NULL, fd);		break;#endif	default:		if (lflag) {			print_list(fd, isb.st_size, outfile, isb.st_mtime);			close(fd);			return -1;	/* XXX */		}		size = gz_uncompress(fd, zfd, NULL, 0, NULL, file);		break;
开发者ID:jamesbjackson,项目名称:src,代码行数:67,


示例20: unpack

void Blobs::blobify(){	//mm not entirely sure yet, but I think this function might just "draw" the blobs, based on the color model of each pixel. the color model is already determined in the "packed" data (see unpack...color model information is extracted from the packed data there...)		    uint32_t i, j, k;    CBlob *blob;    uint16_t *blobsStart;    uint16_t numBlobsStart, invalid, invalid2;    uint16_t left, top, right, bottom;    //uint32_t timer, timer2=0;    unpack(); //mm as is clear in unpack(), at this point, we already know the model to which each blob belongs.    // copy blobs into memory //mm does this refer to the unpack() above??    invalid = 0;	    // mutex keeps interrupt routine from stepping on us    m_mutex = true;		//mm iterate through models:    for (i=0, m_numBlobs=0; i<NUM_MODELS; i++)    {		//mm iterate through blobs in this model:        for (j=m_numBlobs*5, k=0, blobsStart=m_blobs+j, numBlobsStart=m_numBlobs, blob=m_assembler[i].finishedBlobs;             blob && m_numBlobs<m_maxBlobs && k<m_maxBlobsPerModel; blob=blob->next, k++)        {            if (blob->GetArea()<(int)m_minArea)                continue;            blob->getBBox((short &)left, (short &)top, (short &)right, (short &)bottom);            m_blobs[j + 0] = i+1;            m_blobs[j + 1] = left;            m_blobs[j + 2] = right;            m_blobs[j + 3] = top;            m_blobs[j + 4] = bottom;            m_numBlobs++;            j += 5;        }        //setTimer(&timer);        if (true)        {            while(1)            {                invalid2 = combine2(blobsStart, m_numBlobs-numBlobsStart);                if (invalid2==0)                    break;                invalid += invalid2;            }        }        //timer2 += getTimer(timer);    }    //setTimer(&timer);    invalid += combine(m_blobs, m_numBlobs);    if (false)    {        m_codedBlobs = (BlobB *)(m_blobs + m_numBlobs*5);        processCoded();    }    if (invalid)    {        invalid2 = compress(m_blobs, m_numBlobs);        m_numBlobs -= invalid2;        if (invalid2!=invalid)            cprintf("**** %d %d/n", invalid2, invalid);    }    //timer2 += getTimer(timer);    //cprintf("time=%d/n", timer2); // never seen this greater than 200us.  or 1% of frame period    // reset read index-- new frame    m_blobReadIndex = 0;    m_mutex = false;    // free memory    for (i=0; i<NUM_MODELS; i++)        m_assembler[i].Reset();#if 0    static int frame = 0;    if (m_numBlobs>0)        cprintf("%d: blobs %d %d %d %d %d/n", frame, m_numBlobs, m_blobs[1], m_blobs[2], m_blobs[3], m_blobs[4]);    else        cprintf("%d: blobs 0/n", frame);    frame++;#endif}
开发者ID:mjlm,项目名称:pixy,代码行数:87,


示例21: mail1

//.........这里部分代码省略.........		fprintf(stderr, gettext(". . . message lost, sorry./n"));		return;	}	rewind(mtf);	if (askme && isatty(0)) {		char ans[64];		puthead(hp, stdout, GTO|GCC|GBCC, 0);		printf(gettext("Send? "));		printf("[yes] ");		if (fgets(ans, sizeof(ans), stdin) && ans[0] &&				(tolower(ans[0]) != 'y' && ans[0] != '/n'))			goto dead;	}	if (senderr)		goto dead;	/*	 * Look through the recipient list for names with /'s	 * in them which we write to as files directly.	 */	i = outof(to, mtf);	rewind(mtf);	if (!gotcha && !i) {		printf(gettext("No recipients specified/n"));		goto dead;	}	if (senderr)		goto dead;	getrecf(orig_to, recfile, use_to, sizeof (recfile));	if (recfile != NOSTR && *recfile)		savemail(safeexpand(recfile), hp, mtf);	if (!gotcha)		goto out;	namelist = unpack(to);	if (debug) {		fprintf(stderr, "Recipients of message:/n");		for (t = namelist; *t != NOSTR; t++)			fprintf(stderr, " /"%s/"", *t);		fprintf(stderr, "/n");		return;	}	/*	 * Wait, to absorb a potential zombie, then	 * fork, set up the temporary mail file as standard	 * input for "mail" and exec with the user list we generated	 * far above. Return the process id to caller in case he	 * wants to await the completion of mail.	 */#ifdef VMUNIX	while (wait3((int *)0, WNOHANG, (struct rusage *)0) > 0)		;#else#ifdef preSVr4	wait((int *)0);#else	while (waitpid((pid_t)-1, (int *)0, WNOHANG) > 0)		;#endif#endif	rewind(mtf);	pid = fork();	if (pid == (pid_t)-1) {		perror("fork");dead:
开发者ID:AlainODea,项目名称:illumos-gate,代码行数:67,


示例22: Tic

/* *  returns:	-1 = Errors. *		0  = No files processed *		1  = Processed file(s) */int Tic(){    char	    *inbound, *fname;    DIR		    *dp;    struct dirent   *de;    struct stat	    sbuf;    int		    i, rc = 0, Age;    fd_list	    *fdl = NULL;    orphans	    *opl = NULL, *tmp;    time_t	    Now, Fdate;    IsDoing("Process .tic files");    CompileNL = FALSE;    if (do_unprot) {	inbound = xstrcpy(CFG.inbound);    } else {	inbound = xstrcpy(CFG.pinbound);    }    Syslog('+', "Pass: process ticfiles (%s)", inbound);    if (enoughspace(CFG.freespace) == 0) {	Syslog('+', "Low diskspace, abort tic processing");	free(inbound);	return -1;    }    if (chdir(inbound) == -1) {	WriteError("$Can't chdir(%s)", inbound);	free(inbound);	return -1;    }    if ((dp = opendir(inbound)) == NULL) {	WriteError("$Can't opendir(%s)", inbound);	free(inbound);	return -1;    }    while ((de = readdir(dp))) {	if ((strlen(de->d_name) == 12) && (strncasecmp(de->d_name+11, "c", 1) == 0)) {	    if ((strncasecmp(de->d_name+8, ".a", 2) == 0) || (strncasecmp(de->d_name+8, ".c", 2) == 0) ||		(strncasecmp(de->d_name+8, ".z", 2) == 0) || (strncasecmp(de->d_name+8, ".l", 2) == 0) ||		(strncasecmp(de->d_name+8, ".r", 2) == 0) || (strncasecmp(de->d_name+8, ".0", 2) == 0)) {		if (checkspace(inbound, de->d_name, UNPACK_FACTOR)) {		    if ((unpack(de->d_name)) != 0) {			WriteError("Error unpacking %s", de->d_name);		    }		} else {		    Syslog('+', "Insufficient space to unpack file %s", de->d_name);		}	    }	}    }    rewinddir(dp);    while ((de = readdir(dp))) {	if ((strlen(de->d_name) == 12) && (strncasecmp(de->d_name+8, ".tic", 4) == 0)) {	    stat(de->d_name, &sbuf);	    fill_fdlist(&fdl, de->d_name, sbuf.st_mtime);	}    }    closedir(dp);    sort_fdlist(&fdl);    while ((fname = pull_fdlist(&fdl)) != NULL) {	if (LoadTic(inbound, fname, &opl) == 0)	    rc = 1;	if (IsSema((char *)"upsalarm")) {	    rc = 0;	    Syslog('+', "Detected upsalarm semafore, aborting tic processing");	    break;	}	if (enoughspace(CFG.freespace) == 0) {	    Syslog('+', "Low diskspace, aborting tic processing");	    rc = 0;	    break;	}    }    if (!do_quiet) {	printf("/r");	for (i = 0; i < 79; i++)	    printf(" ");	printf("/r");	fflush(stdout);    }    if (rc)	do_flush = TRUE;    if (CompileNL) 	CreateSema((char *)"ftnindex");//.........这里部分代码省略.........
开发者ID:ftnapps,项目名称:FTNd,代码行数:101,


示例23: codec2_decode_1200

void codec2_decode_1200(struct CODEC2 *c2, short speech[], const unsigned char * bits){    MODEL   model[4];    int     lsp_indexes[LPC_ORD];    float   lsps[4][LPC_ORD];    int     WoE_index;    float   e[4];    float   snr;    float   ak[4][LPC_ORD+1];    int     i,j;    unsigned int nbit = 0;    float   weight;    assert(c2 != NULL);    /* only need to zero these out due to (unused) snr calculation */    for(i=0; i<4; i++)	for(j=1; j<=MAX_AMP; j++)	    model[i].A[j] = 0.0;    /* unpack bits from channel ------------------------------------*/    /* this will partially fill the model params for the 4 x 10ms       frames */    model[0].voiced = unpack(bits, &nbit, 1);    model[1].voiced = unpack(bits, &nbit, 1);    WoE_index = unpack(bits, &nbit, WO_E_BITS);    decode_WoE(&model[1], &e[1], c2->xq_dec, WoE_index);    model[2].voiced = unpack(bits, &nbit, 1);    model[3].voiced = unpack(bits, &nbit, 1);    WoE_index = unpack(bits, &nbit, WO_E_BITS);    decode_WoE(&model[3], &e[3], c2->xq_dec, WoE_index);     for(i=0; i<LSP_PRED_VQ_INDEXES; i++) {	lsp_indexes[i] = unpack(bits, &nbit, lsp_pred_vq_bits(i));    }    decode_lsps_vq(lsp_indexes, &lsps[3][0], LPC_ORD);    check_lsp_order(&lsps[3][0], LPC_ORD);    bw_expand_lsps(&lsps[3][0], LPC_ORD);     /* interpolate ------------------------------------------------*/    /* Wo and energy are sampled every 20ms, so we interpolate just 1       10ms frame between 20ms samples */    interp_Wo(&model[0], &c2->prev_model_dec, &model[1]);    e[0] = interp_energy(c2->prev_e_dec, e[1]);    interp_Wo(&model[2], &model[1], &model[3]);    e[2] = interp_energy(e[1], e[3]);     /* LSPs are sampled every 40ms so we interpolate the 3 frames in       between, then recover spectral amplitudes */    for(i=0, weight=0.25; i<3; i++, weight += 0.25) {	interpolate_lsp_ver2(&lsps[i][0], c2->prev_lsps_dec, &lsps[3][0], weight);    }    for(i=0; i<4; i++) {	lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD);	aks_to_M2(c2->fft_fwd_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 0, 0,                  c2->lpc_pf, c2->bass_boost, c2->beta, c2->gamma); 	apply_lpc_correction(&model[i]);    }    /* synthesise ------------------------------------------------*/    for(i=0; i<4; i++)	synthesise_one_frame(c2, &speech[N*i], &model[i], &ak[i][0]);    /* update memories for next frame ----------------------------*/    c2->prev_model_dec = model[3];    c2->prev_e_dec = e[3];    for(i=0; i<LPC_ORD; i++)	c2->prev_lsps_dec[i] = lsps[3][i];}
开发者ID:AhmedObaidi,项目名称:codec2-android,代码行数:80,


示例24: unpack

 void unpack( Stream& s, fc::ecc::private_key& pk) {     fc::sha256 sec;     unpack( s, sec );     pk = ecc::private_key::regenerate(sec); }
开发者ID:BitMoneta,项目名称:fc,代码行数:6,


示例25: ERROR

void Flow::fragmentSortedHandler(UInt64 stage,PacketReader& fragment,UInt8 flags) {	if(stage<=this->stage) {		ERROR("Stage %llu not sorted on flow %llu",stage,id);		return;	}	if(stage>(this->stage+1)) {		// not following stage!		UInt32 lostCount = (UInt32)(stage-this->stage-1);		(UInt64&)this->stage = stage;		if(_pPacket) {			delete _pPacket;			_pPacket = NULL;		}		if(flags&MESSAGE_WITH_BEFOREPART) {			lostFragmentsHandler(lostCount+1);			return;		}		lostFragmentsHandler(lostCount);	} else		(UInt64&)this->stage = stage;	// If MESSAGE_ABANDONMENT, content is not the right normal content!	if(flags&MESSAGE_ABANDONMENT) {		if(_pPacket) {			delete _pPacket;			_pPacket = NULL;		}		return;	}	PacketReader* pMessage(&fragment);	if(flags&MESSAGE_WITH_BEFOREPART){		if(!_pPacket) {			WARN("A received message tells to have a 'beforepart' and nevertheless partbuffer is empty, certainly some packets were lost");			lostFragmentsHandler(1);			delete _pPacket;			_pPacket = NULL;			return;		}				_pPacket->add(fragment);		if(flags&MESSAGE_WITH_AFTERPART)			return;		pMessage = _pPacket->release();	} else if(flags&MESSAGE_WITH_AFTERPART) {		if(_pPacket) {			ERROR("A received message tells to have not 'beforepart' and nevertheless partbuffer exists");			lostFragmentsHandler(_pPacket->fragments);			delete _pPacket;		}		_pPacket = new Packet(fragment);		return;	}	Message::Type type = unpack(*pMessage);	if(type!=Message::EMPTY) {		writer._callbackHandle = 0;		string name;		AMFReader amf(*pMessage);		if(type==Message::AMF_WITH_HANDLER || type==Message::AMF) {			amf.read(name);			if(type==Message::AMF_WITH_HANDLER) {				writer._callbackHandle = amf.readNumber();				if(amf.followingType()==AMF::Null)					amf.readNull();			}		}		try {			switch(type) {				case Message::AMF_WITH_HANDLER:				case Message::AMF:					messageHandler(name,amf);					break;				case Message::AUDIO:					audioHandler(*pMessage);					break;				case Message::VIDEO:					videoHandler(*pMessage);					break;				default:					rawHandler(type,*pMessage);			}		} catch(Exception& ex) {			_error = "flow error, " + ex.displayText();		} catch(exception& ex) {			_error = string("flow error, ") + ex.what();		} catch(...) {			_error = "Unknown flow error";		}	}	writer._callbackHandle = 0;	if(_pPacket) {		delete _pPacket;		_pPacket=NULL;	}//.........这里部分代码省略.........
开发者ID:wilkystorm,项目名称:Cumulus,代码行数:101,


示例26: cmd_receive_pack

int cmd_receive_pack(int argc, const char **argv, const char *prefix){	int advertise_refs = 0;	int stateless_rpc = 0;	int i;	char *dir = NULL;	struct command *commands;	packet_trace_identity("receive-pack");	argv++;	for (i = 1; i < argc; i++) {		const char *arg = *argv++;		if (*arg == '-') {			if (!strcmp(arg, "--advertise-refs")) {				advertise_refs = 1;				continue;			}			if (!strcmp(arg, "--stateless-rpc")) {				stateless_rpc = 1;				continue;			}			usage(receive_pack_usage);		}		if (dir)			usage(receive_pack_usage);		dir = xstrdup(arg);	}	if (!dir)		usage(receive_pack_usage);	setup_path();	if (!enter_repo(dir, 0))		die("'%s' does not appear to be a git repository", dir);	if (is_repository_shallow())		die("attempt to push into a shallow repository");	git_config(receive_pack_config, NULL);	if (0 <= transfer_unpack_limit)		unpack_limit = transfer_unpack_limit;	else if (0 <= receive_unpack_limit)		unpack_limit = receive_unpack_limit;	if (advertise_refs || !stateless_rpc) {		add_alternate_refs();		write_head_info();		clear_extra_refs();		/* EOF */		packet_flush(1);	}	if (advertise_refs)		return 0;	if ((commands = read_head_info()) != NULL) {		const char *unpack_status = NULL;		if (!delete_only(commands))			unpack_status = unpack();		execute_commands(commands, unpack_status);		if (pack_lockfile)			unlink_or_warn(pack_lockfile);		if (report_status)			report(commands, unpack_status);		run_receive_hook(commands, post_receive_hook, 1);		run_update_post_hook(commands);		if (auto_gc) {			const char *argv_gc_auto[] = {				"gc", "--auto", "--quiet", NULL,			};			run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);		}		if (auto_update_server_info)			update_server_info(0);	}	if (use_sideband)		packet_flush(1);	return 0;}
开发者ID:Lisda,项目名称:git,代码行数:84,


示例27: unpack

inline boolProperties::unpack(UtilBuffer &buf) {  return unpack((const Uint32 *)buf.get_data(), buf.length());}
开发者ID:Baoxiyi-Github,项目名称:Mysql,代码行数:4,


示例28: unpack_array

static int unpack_array(scanner_t *s, json_t *root, va_list *ap){    size_t i = 0;    int strict = 0;    if(root && !json_is_array(root)) {        set_error(s, "<validation>", "Expected array, got %s", type_name(root));        return -1;    }    next_token(s);    while(s->token != ']') {        json_t *value;        if(strict != 0) {            set_error(s, "<format>", "Expected ']' after '%c', got '%c'",                      (strict == 1 ? '!' : '*'),                      s->token);            return -1;        }        if(!s->token) {            set_error(s, "<format>", "Unexpected end of format string");            return -1;        }        if(s->token == '!' || s->token == '*') {            strict = (s->token == '!' ? 1 : -1);            next_token(s);            continue;        }        if(!strchr(unpack_value_starters, s->token)) {            set_error(s, "<format>", "Unexpected format character '%c'",                      s->token);            return -1;        }        if(!root) {            /* skipping */            value = NULL;        }        else {            value = json_array_get(root, i);            if(!value) {                set_error(s, "<validation>", "Array index %lu out of range",                          (unsigned long)i);                return -1;            }        }        if(unpack(s, value, ap))            return -1;        next_token(s);        i++;    }    if(strict == 0 && (s->flags & JSON_STRICT))        strict = 1;    if(root && strict == 1 && i != json_array_size(root)) {        long diff = (long)json_array_size(root) - (long)i;        set_error(s, "<validation>", "%li array item(s) left unpacked", diff);        return -1;    }    return 0;}
开发者ID:mkawick,项目名称:Station04,代码行数:69,


示例29: usbip_run

//.........这里部分代码省略.........               OP_REP_IMPORT rep;               printf("attach device/n");               if ((nb = recv (sockfd, busid, 32, 0)) != 32)               {                 printf ("receive error : %s /n", strerror (errno));                 break;               };#ifdef _DEBUG             print_recv(busid, 32,"Busid");#endif               handle_attach(dev_dsc,&rep);               if (send (sockfd, (char *)&rep, sizeof(OP_REP_IMPORT), 0) != sizeof(OP_REP_IMPORT))               {                   printf ("send error : %s /n", strerror (errno));                   break;               };               attached = 1;             }          }          else          {             printf("------------------------------------------------/n");              printf("handles requests/n");             USBIP_CMD_SUBMIT cmd;             USBIP_RET_SUBMIT usb_req;             if ((nb = recv (sockfd, (char *)&cmd, sizeof(USBIP_CMD_SUBMIT), 0)) != sizeof(USBIP_CMD_SUBMIT))             {               printf ("receive error : %s /n", strerror (errno));               break;             };#ifdef _DEBUG             print_recv((char *)&cmd, sizeof(USBIP_CMD_SUBMIT),"USBIP_CMD_SUBMIT");#endif             unpack((int *)&cmd,sizeof(USBIP_CMD_SUBMIT));                            printf("usbip cmd %u/n",cmd.command);             printf("usbip seqnum %u/n",cmd.seqnum);             printf("usbip devid %u/n",cmd.devid);             printf("usbip direction %u/n",cmd.direction);             printf("usbip ep %u/n",cmd.ep);             printf("usbip flags %u/n",cmd.transfer_flags);             printf("usbip number of packets %u/n",cmd.number_of_packets);             printf("usbip interval %u/n",cmd.interval);#ifdef LINUX             printf("usbip setup %llu/n",cmd.setup);#else             printf("usbip setup %I64u/n",cmd.setup);#endif             printf("usbip buffer lenght  %u/n",cmd.transfer_buffer_length);             usb_req.command=0;             usb_req.seqnum=cmd.seqnum;             usb_req.devid=cmd.devid;             usb_req.direction=cmd.direction;             usb_req.ep=cmd.ep;             usb_req.status=0;             usb_req.actual_length=0;             usb_req.start_frame=0;             usb_req.number_of_packets=0;             usb_req.error_count=0;             usb_req.setup=cmd.setup;                          if(cmd.command == 1)               handle_usb_request(sockfd, &usb_req, cmd.transfer_buffer_length);                          if(cmd.command == 2) //unlink urb             {
开发者ID:lcgamboa,项目名称:USBIP-Virtual-USB-Device,代码行数:67,



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


C++ unpack_trees函数代码示例
C++ unorm_normalize函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。