本文整理汇总了C++中bswap_16函数的典型用法代码示例。如果您正苦于以下问题:C++ bswap_16函数的具体用法?C++ bswap_16怎么用?C++ bswap_16使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bswap_16函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: wire_to_host
static fsal_status_t wire_to_host(struct fsal_export *exp_hdl,
fsal_digesttype_t in_type,
struct gsh_buffdesc *fh_desc,
int flags)
{
size_t fh_min;
uint64_t *hashkey;
ushort *len;
fh_min = 1;
if (fh_desc->len < fh_min) {
LogMajor(COMPONENT_FSAL,
"Size mismatch for handle. should be >= %zu, got %zu",
fh_min, fh_desc->len);
return fsalstat(ERR_FSAL_SERVERFAULT, 0);
}
hashkey = (uint64_t *)fh_desc->addr;
len = (ushort *)((char *)hashkey + sizeof(uint64_t));
if (flags & FH_FSAL_BIG_ENDIAN) {
#if (BYTE_ORDER != BIG_ENDIAN)
*len = bswap_16(*len);
*hashkey = bswap_64(*hashkey);
#endif
} else {
#if (BYTE_ORDER == BIG_ENDIAN)
*len = bswap_16(*len);
*hashkey = bswap_64(*hashkey);
#endif
}
return fsalstat(ERR_FSAL_NO_ERROR, 0);
}
开发者ID:hongjil5,项目名称:nfs-ganesha,代码行数:32,代码来源:export.c
示例2: ffiget_arg_length
void ffiget_arg_length(unsigned char *c, long clen, unsigned char *a, long alen) {
uint16_t arg;
memcpy(&arg, a, sizeof(arg));
arg = bswap_16(arg);
uint16_t len_result = bswap_16(strlen(argv[arg]));
memcpy(a, &len_result, sizeof(len_result));
}
开发者ID:GaloisInc,项目名称:camkes-tool,代码行数:7,代码来源:args.c
示例3: pci_get_vendor
static int pci_get_vendor(
unsigned char bus,
unsigned char dev,
int func)
{
int retval;
char path[100];
int fd;
short vendor, device;
sprintf(path,"/proc/bus/pci/%02d/%02x.0", bus, dev);
fd = open(path,O_RDONLY|O_SYNC);
if (fd == -1) {
retval=0xFFFF;
}
else if (pread(fd, &vendor, 2, PCI_VENDOR_ID) == 2 &&
pread(fd, &device, 2, PCI_DEVICE_ID) == 2) {
vendor = bswap_16(vendor);
device = bswap_16(device);
retval = vendor + (device<<16); /*no worries about byte order,
all ppc are bigendian*/
} else {
retval = 0xFFFF;
}
if (fd > 0) {
close(fd);
}
return retval;
}
开发者ID:OS2World,项目名称:MM-SOUND-xine,代码行数:28,代码来源:pci_powerpc.c
示例4: check_elf_header
int check_elf_header(Elf32_Ehdr *const ehdr)
{
if (! ehdr || strncmp((void *)ehdr, ELFMAG, SELFMAG) != 0 ||
ehdr->e_ident[EI_CLASS] != ELFCLASS32 ||
ehdr->e_ident[EI_VERSION] != EV_CURRENT)
{
return 1;
}
/* Check if the target endianness matches the host's endianness */
byteswap = 0;
#if __BYTE_ORDER == __LITTLE_ENDIAN
if (ehdr->e_ident[5] == ELFDATA2MSB) {
/* Ick -- we will have to byte-swap everything */
byteswap = 1;
}
#elif __BYTE_ORDER == __BIG_ENDIAN
if (ehdr->e_ident[5] == ELFDATA2LSB) {
byteswap = 1;
}
#else
#error Unknown host byte order!
#endif
/* Be vary lazy, and only byteswap the stuff we use */
if (byteswap==1) {
ehdr->e_type=bswap_16(ehdr->e_type);
ehdr->e_machine=bswap_16(ehdr->e_machine);
ehdr->e_phoff=bswap_32(ehdr->e_phoff);
ehdr->e_shoff=bswap_32(ehdr->e_shoff);
ehdr->e_phnum=bswap_16(ehdr->e_phnum);
ehdr->e_shnum=bswap_16(ehdr->e_shnum);
}
return 0;
}
开发者ID:jhbsz,项目名称:actiontec_opensource_mi424wr-rev-acd-56-0-10-14-4,代码行数:34,代码来源:readelf.c
示例5: volume_id_probe_squashfs
int volume_id_probe_squashfs(struct volume_id *id, uint64_t off, uint64_t size)
{
struct squashfs_super *sqs;
info("probing at offset 0x%" PRIx64 "\n", off);
sqs = (struct squashfs_super *) volume_id_get_buffer(id, off, 0x200);
if (sqs == NULL)
return -1;
if (sqs->s_magic == SQUASHFS_MAGIC || sqs->s_magic == SQUASHFS_MAGIC_LZMA) {
snprintf(id->type_version, sizeof(id->type_version), "%u.%u",
sqs->s_major, sqs->s_minor);
goto found;
}
if (sqs->s_magic == bswap_32(SQUASHFS_MAGIC) || sqs->s_magic == bswap_32(SQUASHFS_MAGIC_LZMA)) {
snprintf(id->type_version, sizeof(id->type_version), "%u.%u",
bswap_16(sqs->s_major), bswap_16(sqs->s_minor));
goto found;
}
return -1;
found:
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
id->type = "squashfs";
return 0;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:28,代码来源:squashfs.c
示例6: bswap_32
void DeepStarComponent::byteSwap( deepStarData *stardata ) {
stardata->RA = bswap_32( stardata->RA );
stardata->Dec = bswap_32( stardata->Dec );
stardata->dRA = bswap_16( stardata->dRA );
stardata->dDec = bswap_16( stardata->dDec );
stardata->B = bswap_16( stardata->B );
stardata->V = bswap_16( stardata->V );
}
开发者ID:KDE,项目名称:kstars,代码行数:8,代码来源:deepstarcomponent.cpp
示例7: ocfs2_swap_extent_block_header
static void ocfs2_swap_extent_block_header(struct ocfs2_extent_block *eb)
{
eb->h_suballoc_slot = bswap_16(eb->h_suballoc_slot);
eb->h_suballoc_bit = bswap_16(eb->h_suballoc_bit);
eb->h_fs_generation = bswap_32(eb->h_fs_generation);
eb->h_blkno = bswap_64(eb->h_blkno);
eb->h_next_leaf_blk = bswap_64(eb->h_next_leaf_blk);
}
开发者ID:ystk,项目名称:debian-ocfs2-tools,代码行数:9,代码来源:extents.c
示例8: lynx_init
int
lynx_init (st_rominfo_t *rominfo)
{
int result = -1;
rominfo->console_usage = lynx_usage[0].help;
rominfo->copier_usage = unknown_usage[0].help;
ucon64_fread (&lnx_header, 0, LNX_HEADER_LEN, ucon64.rom);
if (!strncmp (lnx_header.magic, "LYNX", 4))
result = 0;
else
result = -1;
if (ucon64.console == UCON64_LYNX)
result = 0;
if (!strncmp (lnx_header.magic, "LYNX", 4))
{
rominfo->buheader_len = UCON64_ISSET (ucon64.buheader_len) ?
ucon64.buheader_len : (int) LNX_HEADER_LEN;
if (UCON64_ISSET (ucon64.buheader_len) && !ucon64.buheader_len)
return ucon64.console == UCON64_LYNX ? 0 : result;
ucon64_fread (&lnx_header, 0, LNX_HEADER_LEN, ucon64.rom);
rominfo->buheader = &lnx_header;
// internal ROM name
strcpy (rominfo->name, lnx_header.cartname);
// ROM maker
rominfo->maker = lnx_header.manufname;
// misc stuff
sprintf (rominfo->misc,
"Internal Size: Bank0 %hd Bytes (%.4f Mb)\n"
" Bank1 %hd Bytes (%.4f Mb)\n"
"Version: %hd\n"
"Rotation: %s",
#ifdef WORDS_BIGENDIAN
bswap_16 (lnx_header.page_size_bank0) * 256,
TOMBIT_F (bswap_16 (lnx_header.page_size_bank0) * 256),
bswap_16 (lnx_header.page_size_bank1) * 256,
TOMBIT_F (bswap_16 (lnx_header.page_size_bank1) * 256),
bswap_16 (lnx_header.version),
#else
lnx_header.page_size_bank0 * 256,
TOMBIT_F (lnx_header.page_size_bank0 * 256),
lnx_header.page_size_bank1 * 256,
TOMBIT_F (lnx_header.page_size_bank1 * 256),
lnx_header.version,
#endif
(!lnx_header.rotation) ? "No" : ((lnx_header.rotation == 1) ? "Left" : "Right"));
}
return result;
}
开发者ID:GunioRobot,项目名称:quickdev16,代码行数:57,代码来源:lynx.c
示例9: fprintf
bool YapClient::sendSyncCommand()
{
char pktHeader[4] = { 0, 0, 0, 0 };
uint16_t pktLen;
char * ppp = 0;
if (d->cmdPacket->length() == 0) {
fprintf(stderr, "Command is empty\n");
return false;
}
pktLen = 0;
::memset(pktHeader, 0, sizeof(pktHeader));
pktLen = d->cmdPacket->length();
pktLen = bswap_16(pktLen);
::memcpy(pktHeader, &pktLen, 2);
pktHeader[3] = kPacketFlagSyncMask;
if (!writeSocket(d->cmdSocketFd, pktHeader, 4))
goto Detached;
if (!writeSocket(d->cmdSocketFd, (char*) d->cmdBuffer, d->cmdPacket->length()))
goto Detached;
pktLen = 0;
::memset(pktHeader, 0, sizeof(pktHeader));
if (!readSocketSync(d->cmdSocketFd, pktHeader, 4))
goto Detached;
ppp = ((char *)&pktHeader[0]);
pktLen = *((uint16_t*) ppp);
pktLen = bswap_16(pktLen);
if (pktLen > kMaxMsgLen) {
fprintf(stderr, "YAP: Message too large %u > %u\n", pktLen, kMaxMsgLen);
goto Detached;
}
if (!readSocketSync(d->cmdSocketFd, (char*) d->replyBuffer, pktLen))
goto Detached;
d->replyPacket->reset();
d->replyPacket->setReadTotalLength(pktLen);
return true;
Detached:
serverDisconnected();
closeMsgSocket();
closeCmdSocket();
return false;
}
开发者ID:dkirker,项目名称:BrowserServer,代码行数:56,代码来源:YapClient.cpp
示例10: ocfs2_swap_group_desc_header
static void ocfs2_swap_group_desc_header(struct ocfs2_group_desc *gd)
{
gd->bg_size = bswap_16(gd->bg_size);
gd->bg_bits = bswap_16(gd->bg_bits);
gd->bg_free_bits_count = bswap_16(gd->bg_free_bits_count);
gd->bg_chain = bswap_16(gd->bg_chain);
gd->bg_generation = bswap_32(gd->bg_generation);
gd->bg_next_group = bswap_64(gd->bg_next_group);
gd->bg_parent_dinode = bswap_64(gd->bg_parent_dinode);
gd->bg_blkno = bswap_64(gd->bg_blkno);
}
开发者ID:djs55,项目名称:ocfs2-tools,代码行数:11,代码来源:chain.c
示例11: cfg_blob_copy
int cfg_blob_copy( blob_t *from, void *to ) {
size_t len = from->options & BLOB_LENGTH_MASK;
if( to != NULL ) {
if( is_host_endian( from ) ||
( ( from->options & BLOB_LENGTH_MASK ) == 1 )
)
__copy( from, to );
else {
__copy( from, to );
if( from->options & BLOB_ARRAY )
switch( len ) {
case 2:
for( char *limit = to + 2 * from->array.length, *cyc = to;
cyc < limit;
cyc += 2
)
bswap_16( *( ( uint16_t* ) cyc ) );
break;
case 4:
for( char *limit = to + 4 * from->array.length, *cyc = to;
cyc < limit;
cyc += 4
)
bswap_32( *( ( uint32_t* ) cyc ) );
break;
default:
for( char *limit = to + len * from->array.length, *cyc = to;
cyc < limit;
cyc += len
)
__swap_bytes( cyc, len );
}
else
switch( len ) {
case 2:
bswap_16( *( ( uint16_t* ) to ) );
break;
case 4:
bswap_32( *( ( uint32_t* ) to ) );
break;
default:
__swap_bytes( to, len );
};
}
}
if( from->options & BLOB_ARRAY )
return ( len * from->array.length )
else
return len;
}
开发者ID:buffovich,项目名称:pcfgm,代码行数:52,代码来源:values.c
示例12: volume_id_probe_minix
int volume_id_probe_minix(struct volume_id *id, uint64_t off, uint64_t size)
{
uint8_t *buf;
struct minix_super_block *ms;
struct minix3_super_block *m3s;
info("probing at offset 0x%" PRIx64 "\n", off);
buf = volume_id_get_buffer(id, off + MINIX_SUPERBLOCK_OFFSET, 0x200);
if (buf == NULL)
return -1;
ms = (struct minix_super_block *) buf;
if (ms->s_magic == MINIX_SUPER_MAGIC ||
ms->s_magic == bswap_16(MINIX_SUPER_MAGIC)) {
strcpy(id->type_version, "1");
goto found;
}
if (ms->s_magic == MINIX_SUPER_MAGIC2 ||
ms->s_magic == bswap_16(MINIX_SUPER_MAGIC2)) {
strcpy(id->type_version, "1");
goto found;
}
if (ms->s_magic == MINIX2_SUPER_MAGIC ||
ms->s_magic == bswap_16(MINIX2_SUPER_MAGIC)) {
strcpy(id->type_version, "2");
goto found;
}
if (ms->s_magic == MINIX2_SUPER_MAGIC2 ||
ms->s_magic == bswap_16(MINIX2_SUPER_MAGIC2)) {
strcpy(id->type_version, "2");
goto found;
}
m3s = (struct minix3_super_block *) buf;
if (m3s->s_magic == MINIX3_SUPER_MAGIC ||
m3s->s_magic == bswap_16(MINIX3_SUPER_MAGIC)) {
strcpy(id->type_version, "3");
goto found;
}
goto exit;
found:
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
id->type = "minix";
return 0;
exit:
return -1;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:51,代码来源:minix.c
示例13: ocfs2_swap_group_desc
void ocfs2_swap_group_desc(struct ocfs2_group_desc *gd)
{
if (cpu_is_little_endian)
return;
gd->bg_size = bswap_16(gd->bg_size);
gd->bg_bits = bswap_16(gd->bg_bits);
gd->bg_free_bits_count = bswap_16(gd->bg_free_bits_count);
gd->bg_chain = bswap_16(gd->bg_chain);
gd->bg_generation = bswap_32(gd->bg_generation);
gd->bg_next_group = bswap_64(gd->bg_next_group);
gd->bg_parent_dinode = bswap_64(gd->bg_parent_dinode);
gd->bg_blkno = bswap_64(gd->bg_blkno);
}
开发者ID:ystk,项目名称:debian-ocfs2-tools,代码行数:14,代码来源:chain.c
示例14: memset
bool YapClient::connect()
{
// connect to remote server
struct sockaddr_un socketAddr;
d->cmdSocketFd = ::socket(PF_LOCAL, SOCK_STREAM, 0);
if (d->cmdSocketFd < 0)
return false;
memset(&socketAddr, 0, sizeof(socketAddr));
socketAddr.sun_family = AF_LOCAL;
strncpy(socketAddr.sun_path, d->cmdSocketPath, G_N_ELEMENTS(socketAddr.sun_path));
socketAddr.sun_path[G_N_ELEMENTS(socketAddr.sun_path)-1] = '\0';
if (::connect(d->cmdSocketFd, (struct sockaddr*) &socketAddr,
SUN_LEN(&socketAddr)) != 0) {
close(d->cmdSocketFd);
d->cmdSocketFd = -1;
fprintf(stderr, "YAP: Failed to connect to server\n");
return false;
}
// send our msg server socket path
int16_t strLen = ::strlen(d->msgServerSocketPath);
int16_t pktLen = bswap_16(strLen);
if (!writeSocket(d->cmdSocketFd, (char*) &pktLen, 2))
return false;
if (!writeSocket(d->cmdSocketFd, d->msgServerSocketPath, strLen))
return false;
strLen = ::strlen(d->msgServerSocketPostfix);
pktLen = bswap_16(strLen);
if (!writeSocket(d->cmdSocketFd, (char*) &pktLen, 2))
return false;
if (!writeSocket(d->cmdSocketFd, d->msgServerSocketPostfix, strLen))
return false;
// Add io channel to know when the command socket is disconnected.
d->cmdIoChannel = g_io_channel_unix_new(d->cmdSocketFd);
d->cmdIoSource = g_io_create_watch(d->cmdIoChannel, (GIOCondition) (G_IO_HUP));
g_source_set_callback(d->cmdIoSource, (GSourceFunc) YapClientPriv::ioCallback, this, NULL);
g_source_attach(d->cmdIoSource, d->mainCtxt);
return true;
}
开发者ID:dkirker,项目名称:BrowserServer,代码行数:50,代码来源:YapClient.cpp
示例15: qDebug
bool DeepStarComponent::openDataFile() {
if( starReader.getFileHandle() )
return true;
starReader.openFile( dataFileName );
fileOpened = false;
if( !starReader.getFileHandle() )
qDebug() << "WARNING: Failed to open deep star catalog " << dataFileName << ". Disabling it." << endl;
else if( !starReader.readHeader() )
qDebug() << "WARNING: Header read error for deep star catalog " << dataFileName << "!! Disabling it!" << endl;
else {
qint16 faintmag;
quint8 htm_level;
fread( &faintmag, 2, 1, starReader.getFileHandle() );
if( starReader.getByteSwap() )
faintmag = bswap_16( faintmag );
if( starReader.guessRecordSize() == 16 )
m_FaintMagnitude = faintmag / 1000.0;
else
m_FaintMagnitude = faintmag / 100.0;
fread( &htm_level, 1, 1, starReader.getFileHandle() );
qDebug() << "Processing " << dataFileName << ", HTMesh Level" << htm_level;
m_skyMesh = SkyMesh::Instance( htm_level );
if( !m_skyMesh ) {
if( !( m_skyMesh = SkyMesh::Create( htm_level ) ) ) {
qDebug() << "Could not create HTMesh of level " << htm_level << " for catalog " << dataFileName << ". Skipping it.";
return false;
}
}
meshLevel = htm_level;
fread( &MSpT, 2, 1, starReader.getFileHandle() );
if( starReader.getByteSwap() )
MSpT = bswap_16( MSpT );
fileOpened = true;
qDebug() << " Sky Mesh Size: " << m_skyMesh->size();
for (long int i = 0; i < m_skyMesh->size(); i++) {
StarBlockList *sbl = new StarBlockList( i, this );
if( !sbl ) {
qDebug() << "NULL starBlockList. Expect trouble!";
}
m_starBlockList.append( sbl );
}
m_zoomMagLimit = 0.06;
}
return fileOpened;
}
开发者ID:KDE,项目名称:kstars,代码行数:48,代码来源:deepstarcomponent.cpp
示例16: vars_get_variable_size
static int
vars_get_variable_size(efi_guid_t guid, const char *name, size_t *size)
{
int errno_value;
int ret = -1;
char *path = NULL;
int rc = asprintf(&path, VARS_PATH "%s-"GUID_FORMAT"/size",
name, guid.a, guid.b, guid.c, bswap_16(guid.d),
guid.e[0], guid.e[1], guid.e[2], guid.e[3],
guid.e[4], guid.e[5]);
if (rc < 0)
goto err;
long long int retsize = 0;
rc = get_size_from_file(path, &retsize);
if (rc >= 0) {
ret = 0;
*size = (size_t) retsize;
}
err:
errno_value = errno;
if (path)
free(path);
errno = errno_value;
return ret;
}
开发者ID:Nomad280279,项目名称:vendor_intel_external_efivar,代码行数:29,代码来源:vars.c
示例17: tpm_hash2pcr
static void tpm_hash2pcr(struct xc_dom_image *dom, char *cmdline)
{
struct tpmfront_dev* tpm = init_tpmfront(NULL);
uint8_t *resp;
size_t resplen = 0;
struct pcr_extend_cmd cmd;
/* If all guests have access to a vTPM, it may be useful to replace this
* with ASSERT(tpm) to prevent configuration errors from allowing a guest
* to boot without a TPM (or with a TPM that has not been sent any
* measurements, which could allow forging the measurements).
*/
if (!tpm)
return;
cmd.tag = bswap_16(TPM_TAG_RQU_COMMAND);
cmd.size = bswap_32(sizeof(cmd));
cmd.ord = bswap_32(TPM_ORD_Extend);
cmd.pcr = bswap_32(4); // PCR #4 for kernel
sha1(dom->kernel_blob, dom->kernel_size, cmd.hash);
tpmfront_cmd(tpm, (void*)&cmd, sizeof(cmd), &resp, &resplen);
cmd.pcr = bswap_32(5); // PCR #5 for cmdline
sha1(cmdline, strlen(cmdline), cmd.hash);
tpmfront_cmd(tpm, (void*)&cmd, sizeof(cmd), &resp, &resplen);
cmd.pcr = bswap_32(5); // PCR #5 for initrd
sha1(dom->ramdisk_blob, dom->ramdisk_size, cmd.hash);
tpmfront_cmd(tpm, (void*)&cmd, sizeof(cmd), &resp, &resplen);
shutdown_tpmfront(tpm);
}
开发者ID:CrazyXen,项目名称:XEN_CODE,代码行数:33,代码来源:kexec.c
示例18: g_malloc
/* serialize channels data to the parcel. return parcel and its "size" */
static void *ParcelCtor(const struct Manifest *manifest,
uint32_t *size, uint32_t binds, uint32_t connects)
{
struct NSParcel *p;
int64_t end = binds + connects;
int64_t m = 0, n = 0;
int64_t i;
/* allocate parcel */
*size = sizeof *p + (end - 1) * sizeof(struct NSRecord);
p = g_malloc(*size);
/* parcel header */
p->node = bswap_32(manifest->node);
p->bind_number = bswap_32(binds);
p->connect_number = bswap_32(connects);
/* populate parcel with bind/connect records */
for(i = 0; i < end; ++i)
{
struct Connection *c;
NEXT_SRC();
p->records[i].host = bswap_32(c->host);
p->records[i].port = bswap_16(c->port);
}
return (void*)p;
}
开发者ID:painterjd,项目名称:zerovm-2.0,代码行数:29,代码来源:nservice.c
示例19: commitchanges
/* commitchanges() writes the new headers back to the original file
* and sets the file to its new size.
*/
static int commitchanges(int fd, Elf_Ehdr const *ehdr, Elf_Phdr *phdrs,
unsigned long newsize)
{
size_t n;
unsigned long e_phoff;
short e_phnum;
e_phnum=ehdr->e_phnum;
if (swap_bytes) e_phnum=bswap_16(e_phnum);
e_phoff=ehdr->e_phoff;
#if (ELF_CLASS==ELFCLASS64)
if (swap_bytes) {
e_phoff=bswap_64(e_phoff);
}
#else
if (swap_bytes) {
e_phoff=bswap_32(e_phoff);
}
#endif
/* Save the changes to the ELF header, if any.
*/
if (lseek(fd, 0, SEEK_SET))
return ferr("could not rewind file");
errno = 0;
if (write(fd, ehdr, sizeof *ehdr) != sizeof *ehdr)
return err("could not modify file");
/* Save the changes to the program segment header table, if any.
*/
if (lseek(fd, e_phoff, SEEK_SET) == (off_t)-1) {
err("could not seek in file.");
goto warning;
}
n = e_phnum * sizeof *phdrs;
if (write(fd, phdrs, n) != (ssize_t)n) {
err("could not write to file");
goto warning;
}
/* Eleventh-hour sanity check: don't truncate before the end of
* the program segment header table.
*/
if (newsize < e_phoff + n)
newsize = e_phoff + n;
/* Chop off the end of the file.
*/
if (ftruncate(fd, newsize)) {
err("could not resize file");
goto warning;
}
return 1;
warning:
return err("ELF file may have been corrupted!");
}
开发者ID:deater,项目名称:tb1,代码行数:63,代码来源:sstrip.c
示例20: lynx_b
static int
lynx_b (st_rominfo_t *rominfo, int bank, const char *value)
{
st_lnx_header_t header;
short int *bankvar;
char dest_name[FILENAME_MAX];
if (!rominfo->buheader_len)
{
fprintf (stderr, "ERROR: This is no LNX file\n\n");
return -1;
}
ucon64_fread (&header, 0, sizeof (st_lnx_header_t), ucon64.rom);
bankvar = (bank == 0 ? &header.page_size_bank0 : &header.page_size_bank1);
if ((atol (value) % 64) != 0 || (atol (value) > 512))
*bankvar = 0;
else
#ifdef WORDS_BIGENDIAN
*bankvar = bswap_16 (atol (value) * 4);
#else
*bankvar = atol (value) * 4;
#endif
strcpy (dest_name, ucon64.rom);
ucon64_file_handler (dest_name, NULL, 0);
fcopy (ucon64.rom, 0, ucon64.file_size, dest_name, "wb");
ucon64_fwrite (&header, 0, sizeof (st_lnx_header_t), dest_name, "r+b");
printf (ucon64_msg[WROTE], dest_name);
return 0;
}
开发者ID:GunioRobot,项目名称:quickdev16,代码行数:33,代码来源:lynx.c
注:本文中的bswap_16函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论