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

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

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

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

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

示例1: fli_read_frame_header

boolean_tfli_read_frame_header(char *refany, struct fli_frame_header *frame_hdr, unsigned short *offset, boolean_t *lsb){	struct fli_frame_header *fh;	unsigned short magic;	int i;	for(i=0; i<6; i++){		bcopy(refany+sizeof(int)+i, (char*) &magic, sizeof(unsigned short));		if((magic  == FLI_FRAME_HEADER_MAGIC) || 		   (magic == FLI_FRAME_HEADER_MAGIC_V26976))		{			*lsb = FALSE;			*offset = i;			bcopy(refany+i,(char*)frame_hdr,sizeof(struct fli_frame_header));			return TRUE;		} 		else if ((swap_bytes(magic) == FLI_FRAME_HEADER_MAGIC) || 			 (swap_bytes(magic) == FLI_FRAME_HEADER_MAGIC_V26976))		{			*lsb = TRUE;			*offset = i;			bcopy(refany+i,(char*)frame_hdr,sizeof(struct fli_frame_header));			return TRUE;		} 		else				{			printf("fli_read_frame_header() magic %x != %x/n",magic,FLI_FRAME_HEADER_MAGIC);		}	}	return FALSE;}
开发者ID:metacore,项目名称:spin,代码行数:32,


示例2: RawGetNext

int RawGetNext(CRaw * I, int *size, int *version){  PyMOLGlobals *G = I->G;  int result = cRaw_EOF;  switch (I->mode) {  case cRaw_file_stream:    if(I->f) {      if(!feof(I->f)) {        if(fread((char *) I->header, cRaw_header_size, 1, I->f) != 1) {          PRINTFD(G, FB_Raw)            " RawGetNextType-Debug: Couldn't read header./n" ENDFD;        } else {          if(I->swap) {            swap_bytes(I->header);            swap_bytes(I->header + 1);            swap_bytes(I->header + 2);            swap_bytes(I->header + 3);          }          fseek(I->f, -cRaw_header_size, SEEK_CUR);          *size = I->header[0];          result = I->header[1];          *version = I->header[2];        }      }    }  }  return (result);}
开发者ID:Almad,项目名称:pymol,代码行数:28,


示例3: RawReadSkip

int RawReadSkip(CRaw * I){  PyMOLGlobals *G = I->G;  int result = false;  switch (I->mode) {  case cRaw_file_stream:    if(I->f) {      if(!feof(I->f)) {        if(fread((char *) I->header, cRaw_header_size, 1, I->f) != 1) {          PRINTFB(G, FB_Raw, FB_Errors)            "Error-Raw: Error reading header./n" ENDFB(G);        } else {          if(I->swap) {            swap_bytes(I->header);            swap_bytes(I->header + 1);            swap_bytes(I->header + 2);            swap_bytes(I->header + 3);          }          fseek(I->f, I->header[0], SEEK_CUR);          result = true;        }      }    }    break;  }  return (result);}
开发者ID:Almad,项目名称:pymol,代码行数:27,


示例4: RC4_stream

int RC4_stream(struct RC4_ctx *context, unsigned char *input, unsigned char *output,                 unsigned int size_bytes){ 	    	// PRGA: pseudo-random generation algorithm	int x;	unsigned char y; //   memset(context, '/0', sizeof(struct RC4_ctx)); // no comment	for (x = 0; x < 256; x++) { // upgrade			context->i++;			context->j += context->s[context->i];			swap_bytes(&context->s[context->i],					&context->s[context->j]);		}	for (x = 0; x < size_bytes; x++) {			context->i++;			context->j += context->s[context->i];			swap_bytes(&context->s[context->i],					&context->s[context->j]);			/* Encrypt/decrypt next byte */			y = context->s[context->i] + context->s[context->j];			output[x] = input[x] ^ context->s[y];		}}
开发者ID:blackthorne,项目名称:Secure-Talk,代码行数:30,


示例5: hash_step

/* *      Calculate H(i+1) = Hash(Hi,Mi) *      Where H and M are 32 bytes long */static int hash_step(gost_ctx * c, byte * H, const byte * M){    byte U[32], W[32], V[32], S[32], Key[32];    int i;    /* Compute first key */    xor_blocks(W, H, M, 32);    swap_bytes(W, Key);    /* Encrypt first 8 bytes of H with first key */    gost_enc_with_key(c, Key, H, S);    /* Compute second key */    circle_xor8(H, U);    circle_xor8(M, V);    circle_xor8(V, V);    xor_blocks(W, U, V, 32);    swap_bytes(W, Key);    /* encrypt second 8 bytes of H with second key */    gost_enc_with_key(c, Key, H + 8, S + 8);    /* compute third key */    circle_xor8(U, U);    U[31] = ~U[31];    U[29] = ~U[29];    U[28] = ~U[28];    U[24] = ~U[24];    U[23] = ~U[23];    U[20] = ~U[20];    U[18] = ~U[18];    U[17] = ~U[17];    U[14] = ~U[14];    U[12] = ~U[12];    U[10] = ~U[10];    U[8] = ~U[8];    U[7] = ~U[7];    U[5] = ~U[5];    U[3] = ~U[3];    U[1] = ~U[1];    circle_xor8(V, V);    circle_xor8(V, V);    xor_blocks(W, U, V, 32);    swap_bytes(W, Key);    /* encrypt third 8 bytes of H with third key */    gost_enc_with_key(c, Key, H + 16, S + 16);    /* Compute fourth key */    circle_xor8(U, U);    circle_xor8(V, V);    circle_xor8(V, V);    xor_blocks(W, U, V, 32);    swap_bytes(W, Key);    /* Encrypt last 8 bytes with fourth key */    gost_enc_with_key(c, Key, H + 24, S + 24);    for (i = 0; i < 12; i++)        transform_3(S);    xor_blocks(S, S, M, 32);    transform_3(S);    xor_blocks(S, S, H, 32);    for (i = 0; i < 61; i++)        transform_3(S);    memcpy(H, S, 32);    return 1;}
开发者ID:MaXaMaR,项目名称:engine-new,代码行数:63,


示例6: blowfish_decrypt

static void blowfish_decrypt(u_char *src, u_char *dst, int len, void *state){   struct blowfish_state *dstate;   dstate = (struct blowfish_state *)state;   swap_bytes(src, dst, len);   BF_cbc_encrypt((void *)dst, dst, len, &dstate->key, dstate->iv, BF_DECRYPT);   swap_bytes(dst, dst, len);}
开发者ID:abdimuna1,项目名称:ettercap,代码行数:9,


示例7: bf_ssh1_cipher

static intbf_ssh1_cipher(EVP_CIPHER_CTX *ctx, u_char *out, const u_char *in, u_int len){	int ret;	swap_bytes(in, out, len);	ret = (*orig_bf)(ctx, out, out, len);	swap_bytes(out, out, len);	return (ret);}
开发者ID:andreiw,项目名称:polaris,代码行数:10,


示例8: blowfish_encrypt

voidblowfish_encrypt(u_char *src, u_char *dst, int len, void *state){	struct blowfish_state *estate;	estate = (struct blowfish_state *)state;	swap_bytes(src, dst, len);	BF_cbc_encrypt((void *)dst, dst, len, &estate->key, estate->iv,		       BF_ENCRYPT);	swap_bytes(dst, dst, len);}
开发者ID:Lorindellia,项目名称:dsniff,代码行数:11,


示例9: reverse_inplace_quad

/** * reverse_inplace_quad * *  Reverses a block of memory in-place, 4 bytes at a time. This function *  requires the uint32_t type, which is 32 bits wide. * * Parameters: * *   src  - the memory block to reverse *   size - the size (in bytes) of the memory block * * Returns: nothing */static void reverse_inplace_quad(unsigned char *src, int size){    uint32_t *nsrc = (uint32_t *)src;              /* first quad */    uint32_t *ndst = (uint32_t *)(src + size - 4); /* last quad */    register uint32_t tmp;    while (nsrc < ndst) {        tmp = swap_bytes(*ndst);        *ndst-- = swap_bytes(*nsrc);        *nsrc++ = tmp;    }}
开发者ID:mterzo,项目名称:motion,代码行数:25,


示例10: hist_prep

int hist_prep(void *data_in, map_reduce_args_t *args) {	hist_data_t *data = (hist_data_t *)data_in;    struct stat finfo;	char topdata[READ_AHEAD];	if(data->fname == NULL) {		printf("Must specify filename./n");		return(-1);	}	    // Read in the file    CHECK_ERROR((data->fd = open(data->fname, O_RDONLY)) < 0);	// Get the file info (for file length)	CHECK_ERROR(fstat(data->fd, &finfo) < 0);	if(read(data->fd, topdata, READ_AHEAD) != READ_AHEAD) {		return(-1);	}		if ((topdata[0] != 'B') || (topdata[1] != 'M')) {		printf("File is not a valid bitmap file./n");		return(-1);	}		int swap;	test_endianess(&swap);     // will set the variable "swap"	unsigned short *bitsperpixel = (unsigned short *)(&(topdata[BITS_PER_PIXEL_POS]));	if (swap) {		swap_bytes((char *)(bitsperpixel), sizeof(*bitsperpixel));	}	if (*bitsperpixel != 24) {     // ensure its 3 bytes per pixel		printf("Error: Invalid bitmap format - ");		printf("This application only accepts 24-bit pictures./n");		return(-1);	}		unsigned short data_offset = *(unsigned short *)(&(topdata[IMG_DATA_OFFSET_POS]));	if (swap) {		swap_bytes((char *)(&data_offset), sizeof(data_offset));	}		data->data_bytes = (int)finfo.st_size - (int)data_offset;    args->data_size = data->data_bytes;	printf("This file has %d bytes of image data, %d pixels/n", data->data_bytes,		   data->data_bytes / 3);		// Seek the FD to the beginning of the data	lseek(data->fd, data_offset, SEEK_SET);	data->offset = 0;		return(0);}
开发者ID:MrOptifyGitHub,项目名称:elastic-phoenix,代码行数:53,


示例11: cipher_decrypt

voidcipher_decrypt(CipherContext *context, unsigned char *dest,	       const unsigned char *src, unsigned int len){	if ((len & 7) != 0)		fatal("cipher_decrypt: bad ciphertext length %d", len);	switch (context->type) {	case SSH_CIPHER_NONE:		memcpy(dest, src, len);		break;	case SSH_CIPHER_3DES:		SSH_3CBC_DECRYPT(context->u.des3.key1,				 context->u.des3.key2, &context->u.des3.iv2,				 context->u.des3.key3, &context->u.des3.iv3,				 dest, (unsigned char *) src, len);		break;	case SSH_CIPHER_BLOWFISH:		swap_bytes(src, dest, len);		BF_cbc_encrypt((void *) dest, dest, len,			       &context->u.bf.key, context->u.bf.iv,			       BF_DECRYPT);		swap_bytes(dest, dest, len);		break;	case SSH_CIPHER_BLOWFISH_CBC:		BF_cbc_encrypt((void *) src, dest, len,			       &context->u.bf.key, context->u.bf.iv,			       BF_DECRYPT);		break;	case SSH_CIPHER_3DES_CBC:		des_ede3_cbc_encrypt(src, dest, len,		    context->u.des3.key1, context->u.des3.key2,		    context->u.des3.key3, &context->u.des3.iv3, DES_DECRYPT);		break;	case SSH_CIPHER_ARCFOUR:		RC4(&context->u.rc4, len, (unsigned char *)src, dest);		break;	case SSH_CIPHER_CAST128_CBC:		CAST_cbc_encrypt(src, dest, len,		    &context->u.cast.key, context->u.cast.iv, CAST_DECRYPT);		break;	default:		fatal("cipher_decrypt: unknown cipher: %s", cipher_name(context->type));	}}
开发者ID:OpenDarwin-CVS,项目名称:SEDarwin,代码行数:52,


示例12: swap_bytes

unsigned int Elf::GetProgramHeader(int i, void **data, unsigned int *vaddr, unsigned int *memsize, unsigned int *filesize){	if (i < 0 || (unsigned int)i >= GetNumProgramHeaders())		return false;	Elf32_Phdr *p = &m_pProgramHeader[i];	*data = (void *)&((char *)m_pElf)[swap_bytes(p->p_offset, m_littleEndian)];	*vaddr = swap_bytes(p->p_vaddr, m_littleEndian);	*memsize= swap_bytes(p->p_memsz, m_littleEndian);	*filesize = swap_bytes(p->p_filesz, m_littleEndian);	return swap_bytes(p->p_type, m_littleEndian);}
开发者ID:priyanr,项目名称:os,代码行数:14,


示例13: unpackDataChunk_32bit

void unpackDataChunk_32bit(unsigned char* raw, float* outdata, int nbits,        int nchans, unsigned int nsamps, enum endianness end, char isSigned,        char isChannelInterleaved, int nsampStart, int nsampEnd,        char swapChannels) {    int i, channel, sample;    int in, out, outchan;    char swapem = 0;    float* farr = (float*) raw;    if(end!=INDEPENDANT){	    swapem = endian() != end;    }    if (!isChannelInterleaved) {        for (channel = 0; channel < nchans; channel++) {            if (swapChannels) {                outchan = nchans - channel - 1;            } else {                outchan = channel;            }            in = channel*nsamps;            out = outchan*nsamps;            for (sample = nsampStart; sample < nsampEnd; sample++) {                outdata[out + sample] = farr[in + sample];                swap_bytes((unsigned int*) (&outdata[out + sample]), swapem);            }        }    } else {        farr += nsampStart * nchans;                for (sample = nsampStart; sample < nsampEnd; sample++) {            for (channel = 0; channel < nchans; channel++) {                if (swapChannels) {                    out = (nchans - channel - 1) * nsamps + sample;                    outdata[out]                            = *farr;                } else {                    out = (channel) * nsamps + sample;                    outdata[out]                            = *farr;                }                swap_bytes((unsigned int*) (&outdata[out]), swapem);                farr++;            }        }    }}
开发者ID:SixByNine,项目名称:psrxml,代码行数:49,


示例14: mywrite

/**  * Write speech data in little endian. *  * @param buf [in] speech data * @param unitbyte [in] unit size in bytes * @param unitnum [in] number of units to be written * @param fp [in] file pointer *  * @return TRUE on success (specified number of data has been written), FALSE on failure. */static booleanmywrite(void *buf, size_t unitbyte, int unitnum, FILE *fp){  int tmp;#ifdef WORDS_BIGENDIAN  if (unitbyte > 1) swap_bytes(buf, unitbyte, unitnum);#endif  if ((tmp = myfwrite(buf, unitbyte, unitnum, fp)) < unitnum) {    return(FALSE);  }#ifdef WORDS_BIGENDIAN  if (unitbyte > 1) swap_bytes(buf, unitbyte, unitnum);#endif  return(TRUE);}
开发者ID:1cochan,项目名称:iPhone-julius,代码行数:25,


示例15: rc4_crypt

/* * Encrypt some data using the supplied RC4 state buffer. * The input and output buffers may be the same buffer. * Since RC4 is a stream cypher, this function is used * for both encryption and decryption. */voidrc4_crypt(	rc4_state* const state,	const uint8_t *inbuf, 	uint8_t *outbuf, 	int buflen	){	int i;	uint8_t j;	for (i = 0; i < buflen; i++) {		/* Update modification indicies */		state->index1++;		state->index2 += state->perm[state->index1];		/* Modify permutation */		swap_bytes(&state->perm[state->index1],		    &state->perm[state->index2]);		/* Encrypt/decrypt next byte */		j = state->perm[state->index1] + state->perm[state->index2];		outbuf[i] = inbuf[i] ^ state->perm[j];	}}
开发者ID:gkscndrl,项目名称:GoldRushData,代码行数:32,


示例16: wrtfunc

/**  * Binary write function, with byte swapping if needed. *  * @param fp [in] file pointer * @param buf [in] data buffer to write * @param unitbyte [in] unit size in bytes * @param unitnum [in] number of unit to write */static booleanwrtfunc(FILE *fp, void *buf, size_t unitbyte, size_t unitnum){  if (need_swap == TRUE && unitbyte != 1) {    swap_bytes((char *)buf, unitbyte, unitnum);  }  if (myfwrite(buf, unitbyte, unitnum, fp) < unitnum) {    jlog("Error: write_ngram_bin: failed to write %d bytes", unitbyte*unitnum);    return FALSE;  }  if (need_swap == TRUE && unitbyte != 1) {    swap_bytes((char *)buf, unitbyte, unitnum);  }  count += unitbyte * unitnum;  return TRUE;}
开发者ID:drv5455,项目名称:sdes_music,代码行数:24,


示例17: RC4_init

int RC4_init(unsigned char *key, unsigned char key_size, struct RC4_ctx *context){	if(DEBUG_MODE)		printf("key: %s key_size: %d context: %d/n",key,key_size,context);		// these two are needed for KSA	unsigned char y;	int x;        context->i = 0;    context->j = 0;            // KSA: key-scheduling algorithm    // Initialization	for (x = 0; x < 256; x++)        context->s[x] = (unsigned char) x;	// Scrambling		for (x = y = 0; x < 256; x++){		y += context->s[x] + key[x % key_size];		swap_bytes(&context->s[x],&context->s[y]);	}		return 0;	}
开发者ID:blackthorne,项目名称:Secure-Talk,代码行数:26,


示例18: FRead

void OS::FRead_swap(void* buffer, int32 size, FILE* stream) {  FRead(buffer, size, stream);  int32* end = (int32*)((char*)buffer + size);  for (int32* p = (int32*)buffer;  p < end;  p++)    if (Memory->is_snapshot_other_endian)       swap_bytes(p); }
开发者ID:ardeujho,项目名称:self,代码行数:7,


示例19: send_file

/** * Send a file to be written at config.memory_address */int			send_file(void){	FILE*			fd = NULL;	/* Open the file */	if ((fd = fopen(config.filename, "r")) == NULL) {		fprintf(stderr,			"Error opening file %s./n", config.filename);		goto error_fopen;	}	if (config.verbose)		fprintf(stderr,			"File %s has been opened./n", config.filename);	/* Retreive file size */	get_file_size(&(config.data_size), fd);	if (config.verbose)		fprintf(stderr,			"File size is: %d/n", config.data_size);	/* Copy the file in memory */	if ((config.data = calloc(1, config.data_size + sizeof (edcl_header_t))) == NULL) {		fprintf(stderr,			"Error allocating memory./n");		goto error_malloc;	}	fread(config.data, 1, config.data_size, fd);	if (config.verbose)		fprintf(stderr,			"File has been copied in memory./n");	/* Swap the file bytes if necessary */	if (config.big_endian)		swap_bytes(config.data, config.data_size / 4);	/* Send the file over the socket */	if (send_fragmented() != 0)		goto error_send;	if (config.verbose)		fprintf(stderr,			"File has been sent to the ethernet IP./n");	/* Release ressources */	free(config.data);	fclose(fd);	return (0); error_send:	fprintf(stderr,		"Error when sending the file./n");	free(config.data); error_malloc:	fprintf(stderr,		"Unable to allocate a packet./n");	fclose(fd); error_fopen:	return (errno);}
开发者ID:casasnovas,项目名称:greth,代码行数:62,


示例20: vm_convert_to_host_endianness

voidvm_convert_to_host_endianness(char *value, size_t length){    int val;    char *valp;    val = 1;    valp = (char *) &val;    if (valp[0] == 0) {        /* Host is big endian */        if (!is_big_endian)            swap_bytes(value, length);    } else {        /* Host is little endian */        if (is_big_endian)            swap_bytes(value, length);    }}
开发者ID:wilfriedvanasten,项目名称:essig,代码行数:18,


示例21: write_header

static int	write_header(int fd_dest, header_t *header, t_parser *parser){    int		magic;    int		prog_size;    magic = COREWAR_EXEC_MAGIC;    swap_bytes((char *)&magic, sizeof(magic));    header->magic = magic;    prog_size = parser->current_address;    swap_bytes((char *)&prog_size, sizeof(int));    header->prog_size = prog_size;    if (write(fd_dest, header, sizeof(*header)) == -1)    {        my_putstr_err("Cannot write in the file", 2);        return (1);    }    return (0);}
开发者ID:sabs231,项目名称:corewar,代码行数:18,


示例22: validate_patch

void validate_patch(char *rom_name,char *patch_name){    u8 cpuf[51];    int z64_endianess;    long destsize;    if ((IO_GetcSingle(patch_file) != 1) || (IO_GetcSingle(patch_file) != 0))        return;//error_exit(ERROR_NO_APS,patch_name);    IO_ReadSingle(cpuf,1,50,patch_file);    cpuf[50] = 0;    printf("- Info   : %s/n",cpuf);    z64_endianess = IO_GetcSingle(patch_file);    *cpuf = IO_GetcSingle(rom_file);    if ((z64_endianess  && (*cpuf != 0x80)) ||            (!z64_endianess && (*cpuf != 0x37)))        return;//error_exit(ERROR_WRONG_ENDIANESS,rom_name);    IO_ReadSingle(cpuf,1,11,patch_file);    IO_SeekSingle(0x3C,IO_SEEK_SET,rom_file);   // Cart-ID+country-code    IO_ReadSingle(cpuf+20,1,3,rom_file);    if (!z64_endianess)        cpuf[22] = IO_GetcSingle(rom_file);    IO_SeekSingle(0x10,IO_SEEK_SET,rom_file);   // CRCs    IO_ReadSingle(cpuf+23,1,8,rom_file);    if (!z64_endianess)    {        swap_bytes(&cpuf[20],2);        swap_bytes(&cpuf[23],8);    }    if (memcmp(cpuf,cpuf+20,11))        return;//error_exit(ERROR_NOT_RIGHT_ROM,rom_name);    IO_SeekSingle(74,IO_SEEK_SET,patch_file);   // Skip future-expansion    IO_ReadSingle(&destsize,4,1,patch_file);    if (destsize != fsize(rom_file))        return;//error_exit(ERROR_NOT_RIGHT_ROM,rom_name);    IO_SeekSingle(0,IO_SEEK_SET,rom_file);}
开发者ID:conleon,项目名称:neo-myth-plugins,代码行数:44,


示例23: player_process

static void player_process(MSFilter *f){	PlayerData *d=(PlayerData*)f->data;	int nsamples=(f->ticker->interval*d->rate*d->nchannels)/1000;	int bytes;	/*send an even number of samples each tick. At 22050Hz the number of samples per 10 ms chunk is odd.	Odd size buffer of samples cause troubles to alsa. Fixing in alsa is difficult, so workaround here.	*/	if (nsamples & 0x1 ) { //odd number of samples		if (d->count & 0x1 )			nsamples++;		else			nsamples--;	}	bytes=2*nsamples;	d->count++;	ms_filter_lock(f);	if (d->state==STARTED){		int err;		mblk_t *om=allocb(bytes,0);		if (d->pause_time>0){			err=bytes;			memset(om->b_wptr,0,bytes);			d->pause_time-=f->ticker->interval;		}else{			err=read(d->fd,om->b_wptr,bytes);			if (d->swap) swap_bytes(om->b_wptr,bytes);		}		if (err>=0){			if (err!=0){				if (err<bytes) 					memset(om->b_wptr+err,0,bytes-err);				om->b_wptr+=bytes;				ms_queue_put(f->outputs[0],om);			}else freemsg(om);			if (err<bytes){				ms_filter_notify_no_arg(f,MS_FILE_PLAYER_EOF);				lseek(d->fd,d->hsize,SEEK_SET);				/* special value for playing file only once */				if (d->loop_after==-2)				{					d->state=STOPPED;					ms_filter_unlock(f);					return;				}				if (d->loop_after>=0){					d->pause_time=d->loop_after;				}			}		}else{			ms_warning("Fail to read %i bytes: %s",bytes,strerror(errno));		}	}	ms_filter_unlock(f);}
开发者ID:hunghtbk,项目名称:LinphoneV1,代码行数:56,


示例24: return

void *Elf::FindSection(const char *name, unsigned int *length, unsigned int *vaddr){	if (!m_initialised)		return 0;	for (unsigned int count = 0; count < m_pHeader->e_shnum; count++)		if (strcmp(name, &m_pSectionStrings[swap_bytes(m_pSectionHeader[count].sh_name, m_littleEndian)]) == 0)		{			if (length)				*length = swap_bytes(m_pSectionHeader[count].sh_size, m_littleEndian);			if (vaddr)				*vaddr = swap_bytes(m_pSectionHeader[count].sh_addr, m_littleEndian);			return (void *)&((char *)m_pElf)[swap_bytes(m_pSectionHeader[count].sh_offset, m_littleEndian)];		}	return 0;}
开发者ID:priyanr,项目名称:os,代码行数:19,


示例25: transport_read_uint32_t

// read a uint32_t from the transport uint32_t transport_read_uint32_t( Transport *tpt ){  union uint32_t_bytes ub;  struct exception e;  TRANSPORT_VERIFY_OPEN;  transport_read_buffer ( tpt, ub.b, 4 );  if( tpt->net_little != tpt->loc_little )    swap_bytes( ( uint8_t * )ub.b, 4 );  return ub.i;}
开发者ID:lipp,项目名称:luarpc,代码行数:11,


示例26: transport_write_uint32_t

// write a uint32_t to the transport void transport_write_uint32_t( Transport *tpt, uint32_t x ){  union uint32_t_bytes ub;  struct exception e;  TRANSPORT_VERIFY_OPEN;  ub.i = ( uint32_t )x;  if( tpt->net_little != tpt->loc_little )    swap_bytes( ( uint8_t * )ub.b, 4 );  transport_write_buffer( tpt, ub.b, 4 );}
开发者ID:lipp,项目名称:luarpc,代码行数:11,


示例27: fli_display_frame

voidfli_display_frame(struct fli_frame_header *fh, video_t dpy,		  unsigned short height, unsigned short width,		  char *buff, boolean_t lsb){	struct fli_chunk_header	*ch;	char 			*chunk_buff;	int 			i;#if	__alpha	int			size;#endif	__alpha	unsigned short 		chunks;		chunks = fh->chunks;	ch = (struct fli_chunk_header *)buff;   	while (chunks--)	{		unsigned short type;		if(lsb) type = swap_bytes(ch->type);		else    type = ch->type;		chunk_buff = (char *)((long)ch + (long)FLI_CHUNK_HEADER_SIZE);		switch (type)		{		case FLI_CHUNK_4:			fli_clr(dpy,0x8,chunk_buff,lsb);			break;		case FLI_CLR:			fli_clr(dpy,0x6,chunk_buff,lsb);			break;		case FLI_LC:			fli_lc(dpy, chunk_buff,lsb);			break;		case FLI_BLK:			printf("fli_blk not implemented/n");			/* bzero(screen_buff,width * height);*/			break;		case FLI_BRUN:			fli_brun(dpy, height, width, chunk_buff,lsb);			break;		case FLI_CPY:					printf("fli_cpy not implemented/n");			/* bcopy(chunk_buff,screen_buff, (* fli_image_size = *) fli_image_width * fli_image_height); */			break;		case FLI_MINI:			printf("fli_mini not implemented/n");			break;		default:			printf("Bad chunk with type = %d/n",type);		}	   (long)ch += fli_size((char*)ch,FLI_CHUNK_HEADER_SIZE_OFFSET,lsb);	}}
开发者ID:metacore,项目名称:spin,代码行数:55,



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


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