void cf_putLong(struct cfile *cf, long n) { register int r = 0; FILE *fp; if (cf->mode != W_MODE) { fprintf(stderr, "%s: not open for writing\n", cf->fileName); exit(1); } fp = cf->fp; if (cf->atFirstChar) { /* If no key, make it blank */ cf->atFirstChar = 0; r |= putc(' ', fp); } if (cf->pendingCount) { if (cf->pendingValue == n) { ++cf->pendingCount; cf->atFirstChar = 0; return; } r = 0; if (cf->pendingCount <= 1) { r |= putLong(fp, cf->pendingValue); } else { if (cf->pendingValue != 0) { r |= putLong(fp, cf->pendingValue); } if (cf->pendingCount == 2 && cf->pendingValue < 10 && cf->pendingValue > 0) { r |= putc(' ', fp); r |= putc((char) (cf->pendingValue + '0'), fp); } else { r |= putc('!', fp); r |= putLong(fp, cf->pendingCount); } } r |= putc(' ', fp); if (r == EOF) { perror(cf->fileName); exit(1); } } cf->pendingCount = 1; cf->pendingValue = n; cf->atFirstChar = 0; }
void cf_putString(struct cfile *cf, const char *s) { register int r; FILE *fp; const char *p; int c; r = 0; if (cf->mode != W_MODE) { fprintf(stderr, "%s: not open for writing\n", cf->fileName); exit(1); } fp = cf->fp; if (cf->atFirstChar) { /* If no key, make it blank */ cf->atFirstChar = 0; r |= putc(' ', fp); } if (cf->pendingCount) { r |= putLong(fp, cf->pendingValue); if (cf->pendingCount > 1) { if (cf->pendingCount == 2 && cf->pendingValue < 10 && cf->pendingValue >= 0) { r |= putc(' ', fp); r |= putc((char) (cf->pendingValue + '0'), fp); } else { r |= putc('!', fp); r |= putLong(fp, cf->pendingCount); } } cf->pendingCount = 0; r |= putc(' ', fp); } p = s; while ((c = *p++) != '\0') { r |= putc(c, fp); } r |= putc(' ', fp); if (r == EOF) { perror(cf->fileName); exit(1); } }
int MakeTask (void * A) { int i, n, pid; char * NF, buf[50]; i = FctInTask-1; if ((pid = fork()) == -1) stopErr("IF_NewTask","fork"); if (pid == 0) { /* fils */ ITASK=FctInTask; /* TASK 0 is the interractive one */ NF = FicCons(ITASK); n = i+1; if ((i=open(NF,O_CREAT|O_RDWR|O_TRUNC,0600)) < 0) perror(NF); else { sprintf(buf,"Task #%d console :\n",n); write(i,buf,strlen(buf)); dup2(i,1); dup2(i,2); close(i); close(0); } } else { TASKp[i] = pid; putLong(FctInTask); TASKf[i]=A; FctInTask=0; } return(pid); }
int net_buffer_putLong(struct net_buffer * buf, uint64_t lword) { if (!buf) return -1; if ((buf->buf_ptr + sizeof(uint64_t)) > buf->buf+buf->size) return -1; putLong(buf->buf_ptr, lword); buf->buf_ptr += sizeof(uint64_t); return 0; }
encode() { Packet::encode(); buffer+=ID; putMagic(); putLong(serverId); putAddress(clientAddress,clientPort); putShort(mtuSize); putByte('\0');//server security }
void cf_putNewline(struct cfile *cf) { register int r; FILE *fp; r = 0; if (cf->mode != W_MODE) { fprintf(stderr, "%s: not open for writing\n", cf->fileName); exit(1); } fp = cf->fp; if (cf->pendingCount) { if (cf->pendingValue) { r |= putLong(fp, cf->pendingValue); if (cf->pendingCount > 1) { if (cf->pendingCount == 2 && cf->pendingValue < 10 && cf->pendingValue >= 0) { r |= putc(' ', fp); r |= putc((char) (cf->pendingValue + '0'), fp); } else { r |= putc('!', fp); r |= putLong(fp, cf->pendingCount); } } } cf->pendingCount = 0; } r |= putc('\n', fp); if (r == EOF) { perror(cf->fileName); exit(1); } ++cf->lineNo; cf->atFirstChar = 1; }
/* =========================================================================== Flushes all pending output if necessary, closes the compressed file and deallocates all the (de)compression state. */ int lib_gzclose (gzFile file) { #ifndef NO_DEFLATE int err; #endif gz_stream *s = (gz_stream*)file; if (s == NULL) return Z_STREAM_ERROR; if (s->mode == 'w') { #ifdef NO_DEFLATE return Z_STREAM_ERROR; #else err = do_flush (file, Z_FINISH); if (err != Z_OK) return destroy((gz_stream*)file); putLong (s->file, s->crc); putLong (s->file, s->stream.total_in); #endif } return destroy((gz_stream*)file); }
encode() { Packet::encode(); buffer+=ID; putInt(seed); putByte(dimension); putInt(generator); putInt(gamemode); putLong(eid); putInt(spawnX); putInt(spawnY); putInt(spawnZ); putFloat(x); putFloat(y); putFloat(z); putByte('\0'); }
void convert_num(unsigned char *buf, char *str, int base, int size) { int negative = 0, tval, max; u_int32_t val = 0; char *ptr = str; if (*ptr == '-') { negative = 1; ptr++; } /* If base wasn't specified, figure it out from the data. */ if (!base) { if (ptr[0] == '0') { if (ptr[1] == 'x') { base = 16; ptr += 2; } else if (isascii(ptr[1]) && isdigit(ptr[1])) { base = 8; ptr += 1; } else base = 10; } else base = 10; } do { tval = *ptr++; /* XXX assumes ASCII... */ if (tval >= 'a') tval = tval - 'a' + 10; else if (tval >= 'A') tval = tval - 'A' + 10; else if (tval >= '0') tval -= '0'; else { warning("Bogus number: %s.", str); break; } if (tval >= base) { warning("Bogus number: %s: digit %d not in base %d", str, tval, base); break; } val = val * base + tval; } while (*ptr); if (negative) max = (1 << (size - 1)); else max = (1 << (size - 1)) + ((1 << (size - 1)) - 1); if (val > max) { switch (base) { case 8: warning("value %s%o exceeds max (%d) for precision.", negative ? "-" : "", val, max); break; case 16: warning("value %s%x exceeds max (%d) for precision.", negative ? "-" : "", val, max); break; default: warning("value %s%u exceeds max (%d) for precision.", negative ? "-" : "", val, max); break; } } if (negative) switch (size) { case 8: *buf = -(unsigned long)val; break; case 16: putShort(buf, -(unsigned long)val); break; case 32: putLong(buf, -(unsigned long)val); break; default: warning("Unexpected integer size: %d", size); break; } else switch (size) { case 8: *buf = (u_int8_t)val; break; case 16: putUShort(buf, (u_int16_t)val); break; case 32: putULong(buf, val); break; default: warning("Unexpected integer size: %d", size); break; } }
void IF_NoError(void) { putLong((long)LASTERR); }
sp<ByteBuffer> ByteBuffer::putLong(int64_t value) { putLong(mPosition, value); mPosition += sizeof(value); return this; }
static void IF_getIndDo(int v) { int i = I_DO - v; if (i<0) putLong((long long)0); else putLong((long long)D_DO[i]); }
void IF_nDO (void) { putLong((long long)(I_DO+1)); }