本文整理汇总了C++中read_long函数的典型用法代码示例。如果您正苦于以下问题:C++ read_long函数的具体用法?C++ read_long怎么用?C++ read_long使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_long函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: read_long
unsigned long
midifile::parse_prop_header (int file_size)
{
unsigned long result = 0;
if ((file_size - m_pos) > (int) sizeof(unsigned long))
{
result = read_long(); /* status (new), or tag */
unsigned char status = (result & 0xFF000000) >> 24;
if (status == 0xFF)
{
m_pos -= 3; /* back up to retrench */
unsigned char type = read_byte(); /* get meta type */
if (type == 0x7F)
{
(void) read_varinum(); /* prop section length */
result = read_long(); /* control tag */
}
else
{
fprintf
(
stderr,
"Bad status '%x' in proprietary section near offset %x",
int(type), m_pos
);
}
}
}
开发者ID:EQ4,项目名称:sequencer24,代码行数:28,代码来源:midifile.cpp
示例2: unpack_list
static cDict *unpack_dict(cBuf *buf, Long *buf_pos)
{
cDict *dict;
cList *keys, *values;
Int i;
keys = unpack_list(buf, buf_pos);
values = unpack_list(buf, buf_pos);
if (keys->len <= 64) {
dict = dict_new(keys, values);
list_discard(keys);
list_discard(values);
return dict;
} else {
dict = EMALLOC(cDict, 1);
dict->keys = keys;
dict->values = values;
dict->hashtab_size = read_long(buf, buf_pos);
dict->links = EMALLOC(Int, dict->hashtab_size);
dict->hashtab = EMALLOC(Int, dict->hashtab_size);
for (i = 0; i < dict->hashtab_size; i++) {
dict->links[i] = read_long(buf, buf_pos);
dict->hashtab[i] = read_long(buf, buf_pos);
}
dict->refs = 1;
return dict;
}
}
开发者ID:braddr,项目名称:cold,代码行数:28,代码来源:dbpack.c
示例3: unpack_methods
static void unpack_methods(cBuf *buf, Long *buf_pos, Obj *obj)
{
Int i, size;
size = read_long(buf, buf_pos);
if (size == -1) {
obj->methods = NULL;
return;
}
obj->methods = EMALLOC(ObjMethods, 1);
obj->methods->size = size;
obj->methods->blanks = read_long(buf, buf_pos);
obj->methods->hashtab = EMALLOC(Int, obj->methods->size);
obj->methods->tab = EMALLOC(struct mptr, obj->methods->size);
for (i = 0; i < obj->methods->size; i++) {
obj->methods->hashtab[i] = read_long(buf, buf_pos);
obj->methods->tab[i].m = unpack_method(buf, buf_pos);
if (obj->methods->tab[i].m)
obj->methods->tab[i].m->object = obj;
obj->methods->tab[i].next = read_long(buf, buf_pos);
}
unpack_strings(buf, buf_pos, obj);
unpack_idents(buf, buf_pos, obj);
}
开发者ID:braddr,项目名称:cold,代码行数:30,代码来源:dbpack.c
示例4: fopen
lwObject *lw_object_read(const char *lw_file)
{
FILE *f = NULL;
lwObject *lw_object = NULL;
gint32 form_bytes = 0;
gint32 read_bytes = 0;
/* open file */
f = fopen(lw_file, "rb");
if (f == NULL) {
g_warning("can't open file %s", lw_file);
return NULL;
}
/* check for headers */
if (read_long(f) != ID_FORM) {
g_warning("file %s is not an IFF file", lw_file);
fclose(f);
return NULL;
}
form_bytes = read_long(f);
read_bytes += 4;
if (read_long(f) != ID_LWOB) {
g_warning("file %s is not a LWOB file", lw_file);
fclose(f);
return NULL;
}
/* create new lwObject */
lw_object = g_malloc0(sizeof(lwObject));
/* read chunks */
while (read_bytes < form_bytes) {
gint32 id = read_long(f);
gint32 nbytes = read_long(f);
read_bytes += 8 + nbytes + (nbytes%2);
switch (id) {
case ID_PNTS:
read_pnts(f, nbytes, lw_object);
break;
case ID_POLS:
read_pols(f, nbytes, lw_object);
break;
case ID_SRFS:
read_srfs(f, nbytes, lw_object);
break;
case ID_SURF:
read_surf(f, nbytes, lw_object);
break;
default:
fseek(f, nbytes + (nbytes%2), SEEK_CUR);
}
}
fclose(f);
return lw_object;
}
开发者ID:DX-MON,项目名称:gtkGLExt2,代码行数:60,代码来源:lw.c
示例5: perform_restoreundo
/* perform_restoreundo():
Pull a state pointer from the undo chain. This returns 0 on success,
1 on failure. Note that if it succeeds, the frameptr, localsbase,
and valstackbase registers are invalid; they must be rebuilt from
the stack.
*/
glui32 perform_restoreundo()
{
dest_t dest;
glui32 res, val;
glui32 heapsumlen = 0;
glui32 *heapsumarr = NULL;
if (undo_chain_size == 0 || undo_chain_num == 0)
return 1;
dest.ismem = TRUE;
dest.size = 0;
dest.pos = 0;
dest.ptr = undo_chain[0];
dest.str = NULL;
res = 0;
if (res == 0) {
res = read_long(&dest, &val);
}
if (res == 0) {
res = read_memstate(&dest, val);
}
if (res == 0) {
res = read_long(&dest, &val);
}
if (res == 0) {
res = read_heapstate(&dest, val, FALSE, &heapsumlen, &heapsumarr);
}
if (res == 0) {
res = read_long(&dest, &val);
}
if (res == 0) {
res = read_stackstate(&dest, val, FALSE);
}
/* ### really, many of the failure modes of those calls ought to
cause fatal errors. The stack or main memory may be damaged now. */
if (res == 0) {
if (heapsumarr)
res = heap_apply_summary(heapsumlen, heapsumarr);
}
if (res == 0) {
/* It worked. */
if (undo_chain_size > 1)
memmove(undo_chain, undo_chain+1,
(undo_chain_size-1) * sizeof(unsigned char *));
undo_chain_num -= 1;
glulx_free(dest.ptr);
dest.ptr = NULL;
}
else {
/* It didn't work. */
dest.ptr = NULL;
}
return res;
}
开发者ID:309972460,项目名称:software,代码行数:65,代码来源:serial.c
示例6: fopen
lwObject *lw_object_read(const char *lw_file)
{
/* open file */
FILE *f = fopen(lw_file, "rb");
if (f == NULL) {
return NULL;
}
/* check for headers */
if (read_long(f) != ID_FORM) {
fclose(f);
return NULL;
}
wxInt32 read_bytes = 0;
wxInt32 form_bytes = read_long(f);
read_bytes += 4;
if (read_long(f) != ID_LWOB) {
fclose(f);
return NULL;
}
/* create new lwObject */
lwObject *lw_object = (lwObject*) calloc(sizeof(lwObject),1);
/* read chunks */
while (read_bytes < form_bytes) {
wxInt32 id = read_long(f);
wxInt32 nbytes = read_long(f);
read_bytes += 8 + nbytes + (nbytes%2);
switch (id) {
case ID_PNTS:
read_pnts(f, nbytes, lw_object);
break;
case ID_POLS:
read_pols(f, nbytes, lw_object);
break;
case ID_SRFS:
read_srfs(f, nbytes, lw_object);
break;
case ID_SURF:
read_surf(f, nbytes, lw_object);
break;
default:
fseek(f, nbytes + (nbytes%2), SEEK_CUR);
}
}
fclose(f);
return lw_object;
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:55,代码来源:lw.cpp
示例7: unpack_idents
static void unpack_idents(cBuf *buf, Long *buf_pos, Obj *obj)
{
Int i;
obj->methods->idents_size = read_long(buf, buf_pos);
obj->methods->num_idents = read_long(buf, buf_pos);
obj->methods->idents = EMALLOC(Ident_entry, obj->methods->idents_size);
for (i = 0; i < obj->methods->num_idents; i++) {
obj->methods->idents[i].id = read_ident(buf, buf_pos);
if (obj->methods->idents[i].id != NOT_AN_IDENT)
obj->methods->idents[i].refs = read_long(buf, buf_pos);
}
}
开发者ID:braddr,项目名称:cold,代码行数:13,代码来源:dbpack.c
示例8: lw_is_lwobject
gint lw_is_lwobject(const char *lw_file)
{
FILE *f = osgDB::fopen(lw_file, "rb");
if (f) {
gint32 form = read_long(f);
gint32 nlen = read_long(f);
gint32 lwob = read_long(f);
fclose(f);
if (form == ID_FORM && nlen != 0 && lwob == ID_LWOB)
return TRUE;
}
return FALSE;
}
开发者ID:151706061,项目名称:OpenSceneGraph,代码行数:13,代码来源:old_lw.cpp
示例9: lw_is_lwobject
bool lw_is_lwobject(const char *lw_file)
{
FILE *f = fopen(lw_file, "rb");
if (f) {
wxInt32 form = read_long(f);
wxInt32 nlen = read_long(f);
wxInt32 lwob = read_long(f);
fclose(f);
if (form == ID_FORM && nlen != 0 && lwob == ID_LWOB)
return true;
}
return false;
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:13,代码来源:lw.cpp
示例10: SendMBINBuffers
void SendMBINBuffers (EmbMBINChannel* mbinChannel)
{
register EmbQueue *gthQ = mbinChannel->guestToHostQueue;
register EmbQueue *gthrQ = mbinChannel->guestToHostReturnQueue;
EmbPtr bufferPtr;
struct rm_aligned_pkt *buffer;
struct rm_pkt pkt;
unsigned int nBytes, id;
int historyID;
if (mbinChannel->header.messageChannel->guestToHostImpulse)
switch (mbinChannel->header.messageChannel->guestToHostImpulse)
{
case EmbMBINImpulseShutdown:
activeMBINChannel = NULL;
ResetIncomingQueue (gthQ);
ResetOutgoingQueue (gthrQ);
ResetIncomingQueue (mbinChannel->hostToGuestSupplyQueue);
ResetOutgoingQueue (mbinChannel->hostToGuestQueue);
mbinChannel->header.messageChannel->guestToHostImpulse = EmbMessageImpulseNone;
UnthreadMessageChannel (mbinChannel->header.messageChannel);
free (mbinChannel);
return;
default:
mbinChannel->header.messageChannel->guestToHostImpulse = EmbMessageImpulseNone;
break;
}
while (EmbQueueFilled (gthQ)) {
if (0 == EmbQueueSpace (gthrQ)) {
SignalLater (gthQ->signal);
return;
}
bufferPtr = EmbQueueTakeWord (gthQ);
if (bufferPtr && (bufferPtr != NullEmbPtr) && mbin_sinValid) {
buffer = (struct rm_aligned_pkt*) HostPointer (bufferPtr);
nBytes = read_long(&buffer->rm_operand[0]) & 0xFFFFFF;
memcpy (&pkt.rm_id[0], &buffer->rm_id[0], REMOTE_MEMORY_ALIGNED_PACKET_HEADER);
memcpy (&pkt.data[0], &buffer->data[0], nBytes);
if (rm_ack == buffer->rm_opcode) {
id = read_long(&buffer->rm_id[0]);
historyID = id & 0xF;
MBINHistory[historyID].id = id;
MBINHistory[historyID].acked = TRUE;
}
spy_transmit(&pkt, REMOTE_MEMORY_PACKET_HEADER + nBytes, &mbin_sin);
}
EmbQueuePutWord (gthrQ, bufferPtr);
}
}
开发者ID:Flight310,项目名称:vlm,代码行数:50,代码来源:spy.c
示例11: read_ident
Ident read_ident(cBuf *buf, Long *buf_pos)
{
Int len;
Char *s;
Ident id;
/* Read the length of the identifier. */
len = read_long(buf, buf_pos);
/* If the length is -1, it's not really an identifier, but a -1 signalling
* a blank variable or method. */
if (len == NOT_AN_IDENT)
return NOT_AN_IDENT;
/* Otherwise, it's an identifier. Read it into temporary storage. */
s = TMALLOC(Char, len + 1);
MEMCPY(s, &(buf->s[*buf_pos]), len);
(*buf_pos) += len;
s[len] = 0;
/* Get the index for the identifier and free the temporary memory. */
id = ident_get(s);
tfree_chars(s);
return id;
}
开发者ID:braddr,项目名称:cold,代码行数:26,代码来源:dbpack.c
示例12: read_surf
static void read_surf(FILE *f, int nbytes, lwObject *lwo)
{
int i;
char name[LW_MAX_NAME_LEN];
lwMaterial *material = NULL;
/* read surface name */
nbytes -= read_string(f,name);
/* find material */
for (i=0; i< lwo->material_cnt; i++) {
if (strcmp(lwo->material[i].name,name) == 0) {
material = &lwo->material[i];
break;
}
}
/* read values */
while (nbytes > 0) {
int id = read_long(f);
int len = read_short(f);
nbytes -= 6 + len + (len%2);
switch (id) {
case ID_COLR:
material->r = read_char(f) / 255.0;
material->g = read_char(f) / 255.0;
material->b = read_char(f) / 255.0;
read_char(f); /* dummy */
break;
default:
fseek(f, len+(len%2), SEEK_CUR);
}
}
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:35,代码来源:lw.cpp
示例13: test_qtostr
int test_qtostr(testspec_t *t, FILE *ofp)
{
mp_rat in[2];
long radix;
mp_result res, len;
if(!parse_rat_values(t, in, NULL, NULL))
return imath_errno = MP_BADARG, 0;
trim_line(t->input[1]);
if(!read_long(&radix, t->input[1]))
return imath_errno = MP_BADARG, 0;
if(radix < MP_MIN_RADIX || radix > MP_MAX_RADIX) {
fprintf(stderr, "Line %d: Radix %ld out of range\n",
t->line, radix);
return imath_errno = MP_RANGE, 0;
}
trim_line(t->output[0]);
len = mp_rat_string_len(in[0], radix);
if((res = mp_rat_to_string(in[0], radix, g_output, len)) != MP_OK)
return imath_errno = res, 0;
if(strcmp(t->output[0], g_output) != 0)
return imath_errno = OTHER_ERROR, 0;
return 1;
}
开发者ID:admobitec,项目名称:IP2Location-C-Library,代码行数:30,代码来源:imdrover.c
示例14: main
int main(int argc, char **argv)
{
printf("utf_view " VERSION "\n\n");
CHECK_ERROR(argc != 2 && argc != 3, "Incorrect program usage\n\nusage: utf_tab file [offset]");
long offset = 0;
if (argc == 3)
{
offset = read_long(argv[2]);
}
/* open file */
FILE *infile = fopen(argv[1], "rb");
CHECK_ERRNO(!infile, "fopen");
/* get file size */
CHECK_ERRNO(fseek(infile, 0 , SEEK_END) != 0, "fseek");
long file_length = ftell(infile);
CHECK_ERRNO(file_length == -1, "ftell");
rewind(infile);
analyze(infile, offset, file_length);
exit(EXIT_SUCCESS);
}
开发者ID:hcs64,项目名称:vgm_ripping,代码行数:26,代码来源:utf_view.c
示例15: load_dictionary
ucell load_dictionary(const char *data, ucell len)
{
u32 checksum=0;
const char *checksum_walk;
ucell *walk, *reloc_table;
dictionary_header_t *header=(dictionary_header_t *)data;
/* assertions */
if (len <= (sizeof(dictionary_header_t)) || strncmp(DICTID, data, 8))
return 0;
#ifdef CONFIG_DEBUG_DICTIONARY
dump_header(header);
#endif
checksum_walk=data;
while (checksum_walk<data+len) {
checksum+=read_long(checksum_walk);
checksum_walk+=sizeof(u32);
}
if(checksum) {
printk("Checksum invalid (%08x)!\n", checksum);
return 0;
}
data += sizeof(dictionary_header_t);
dicthead = target_long(header->length);
memcpy(dict, data, dicthead);
reloc_table=(ucell *)(data+dicthead);
#ifdef CONFIG_DEBUG_DICTIONARY
printk("\nmoving dictionary (%x bytes) to %x\n",
(ucell)dicthead, (ucell)dict);
printk("\ndynamic relocation...");
#endif
for (walk = (ucell *) dict; walk < (ucell *) (dict + dicthead);
walk++) {
int pos, bit, l;
l=(walk-(ucell *)dict);
pos=l/BITS;
bit=l&~(-BITS);
if (reloc_table[pos] & target_ucell((ucell)1ULL << bit)) {
// printk("%lx, pos %x, bit %d\n",*walk, pos, bit);
write_ucell(walk, read_ucell(walk)+pointer2cell(dict));
}
}
#ifdef CONFIG_DEBUG_DICTIONARY
printk(" done.\n");
#endif
last = (ucell *)(dict + target_ucell(header->last));
return -1;
}
开发者ID:Kokoro666,项目名称:Evangelion-BIOS,代码行数:58,代码来源:dict.c
示例16: read_object_basic
int read_object_basic(FILE *fp, int *index, object *obj)
{
int i;
char str[10];
/* begin of object data */
read_int(fp, index); /* object # */
read_chars(fp, obj->name, sizeof(obj->name));
read_chars(fp, obj->description, sizeof(obj->description));
for (i = 0; i != 3; i++)
read_chars(fp, obj->key[i], sizeof(obj->key[i]));
read_chars(fp, obj->use_output, sizeof(obj->use_output));
read_long(fp, &obj->value);
read_short(fp, &obj->weight);
read_char(fp, &obj->type);
read_char(fp, &obj->adjustment);
read_short(fp, &obj->shotsmax);
read_short(fp, &obj->shotscur);
read_short(fp, &obj->ndice);
read_short(fp, &obj->sdice);
read_short(fp, &obj->pdice);
read_char(fp, &obj->armor);
read_char(fp, &obj->wearflag);
read_char(fp, &obj->magicpower);
read_char(fp, &obj->magicrealm);
read_short(fp, &obj->special);
read_chars(fp, obj->flags, sizeof(obj->flags));
read_char(fp, &obj->questnum);
read_char(fp,&obj->strength);
read_char(fp,&obj->dexterity);
read_char(fp,&obj->constitution);
read_char(fp,&obj->intelligence);
read_char(fp,&obj->piety);
for (i = 0; i != 16; i++)
read_short(fp, &obj->sets_flag[i]);
read_short(fp,&obj->special1);
read_long(fp,&obj->special2);
/* end of object data */
return(0);
}
开发者ID:FuzzyHobbit,项目名称:mordor,代码行数:45,代码来源:ascii1.c
示例17: unpack_handled
void unpack_handled (cBuf *buf, Long *buf_pos, cData *d)
{
HandledFrob *h=TMALLOC(HandledFrob, 1);
h->cclass = read_long(buf, buf_pos);
unpack_data (buf, buf_pos, &h->rep);
h->handler = read_ident(buf, buf_pos);
d->u.instance = (void*) h;
}
开发者ID:braddr,项目名称:cold,代码行数:9,代码来源:handled_frob.c
示例18: unpack_strings
static void unpack_strings(cBuf *buf, Long *buf_pos, Obj *obj)
{
Int i;
Long size;
size = read_long(buf, buf_pos);
if (size != -1) {
#if 1
obj->methods->strings = string_tab_new_with_size(size);
obj->methods->strings->tab_num = read_long(buf, buf_pos);
obj->methods->strings->blanks = read_long(buf, buf_pos);
for (i = 0; i < size; i++) {
obj->methods->strings->hashtab[i] = read_long(buf, buf_pos);
obj->methods->strings->tab[i].next = read_long(buf, buf_pos);
obj->methods->strings->tab[i].hash = read_long(buf, buf_pos);
obj->methods->strings->tab[i].refs = read_long(buf, buf_pos);
}
for (i = 0; i < obj->methods->strings->tab_size; i++) {
obj->methods->strings->tab[i].str = string_unpack(buf, buf_pos);
}
#else
Long last_blank = -1;
// caused 3 crashes on TEC, disabling code until problem can be determined
obj->methods->strings = string_tab_new_with_size(size);
obj->methods->strings->tab_size = size;
obj->methods->strings->blanks = 0;
for (i = 0; i < size; i++) {
obj->methods->strings->tab[i].str = string_unpack(buf, buf_pos);
if (obj->methods->strings->tab[i].str) {
obj->methods->strings->tab_num++;
obj->methods->strings->tab[i].hash = read_long(buf, buf_pos);
obj->methods->strings->tab[i].refs = read_long(buf, buf_pos);
if (obj->methods->strings->blanks == i) {
obj->methods->strings->blanks = i+1;
last_blank = i+1;
}
} else {
if (last_blank != -1)
obj->methods->strings->tab[last_blank].next = i;
last_blank = i;
}
}
string_tab_fixup_hashtab(obj->methods->strings, obj->methods->strings->tab_size);
#endif
} else {
obj->methods->strings = string_tab_new();
}
}
开发者ID:braddr,项目名称:cold,代码行数:49,代码来源:dbpack.c
示例19: test_qtodec
int test_qtodec(testspec_t *t, FILE *ofp)
{
mp_rat in[4];
long radix, prec;
mp_round_mode rmode;
mp_result res, expect = MP_OK, len;
if(!parse_rat_values(t, in, NULL, NULL))
return imath_errno = MP_BADARG, 0;
if(t->output[0][0] == '$' && !parse_result_code(t->output[0], &expect)) {
fprintf(stderr, "Line %d: Invalid result code [%s]\n",
t->line, t->output[0]);
return 0;
}
trim_line(t->input[1]);
trim_line(t->input[2]);
trim_line(t->input[3]);
if(!read_long(&radix, t->input[1]))
return imath_errno = MP_BADARG, 0;
if(!read_long(&prec, t->input[2]))
return imath_errno = MP_BADARG, 0;
if(!read_long((long *)&rmode, t->input[3]))
return imath_errno = MP_BADARG, 0;
if(prec < 0) {
fprintf(stderr, "Line %d: Precision %ld out of range\n",
t->line, prec);
return imath_errno = MP_RANGE, 0;
}
trim_line(t->output[0]);
len = mp_rat_decimal_len(in[0], radix, prec);
if((res = mp_rat_to_decimal(in[0], radix, prec,
rmode, g_output, len)) != expect)
return imath_errno = res, 0;
if(res == MP_OK && strcmp(t->output[0], g_output) != 0)
return imath_errno = OTHER_ERROR, 0;
return 1;
}
开发者ID:admobitec,项目名称:IP2Location-C-Library,代码行数:44,代码来源:imdrover.c
示例20: main
main()
{
char **tokenv;
char *s;
int tokenc;
int i;
prompt();
for ( s=read_long(); s!=NULL; s=read_long() )
{
tokenv=tokenize(s,&tokenc);
if (!no_token(tokenv)) /* if there is a token */
{
check_for_exit(tokenv);
do_fork(tokenv,&tokenc);
}
prompt();
}
}
开发者ID:aclark4life,项目名称:CS,代码行数:19,代码来源:main.c
注:本文中的read_long函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论