static void dinfo(int dn, int r, int c) { double atime; #define ADV if (disk_horiz) r++; else c += DISKCOLWIDTH mvprintw(r, c, "%*.*s", DISKCOLWIDTH, DISKCOLWIDTH, dr_name[dn]); ADV; putint((int)(cur.seek[dn]/etime+0.5), r, c, DISKCOLWIDTH); ADV; putint((int)((cur.rxfer[dn]+cur.wxfer[dn])/etime+0.5), r, c, DISKCOLWIDTH); ADV; puthumanint((cur.rbytes[dn] + cur.wbytes[dn]) / etime + 0.5, r, c, DISKCOLWIDTH); ADV; /* time busy in disk activity */ atime = cur.time[dn].tv_sec + cur.time[dn].tv_usec / 1000000.0; atime = atime * 100.0 / etime; if (atime >= 100) putint(100, r, c, DISKCOLWIDTH); else putfloat(atime, r, c, DISKCOLWIDTH, 1, 1); }
static int assemble_athena_ticket(char *ticket, int *ticketLen, char *name, char *inst, char *realm, afs_int32 host, struct ktc_encryptionKey *sessionKey, afs_uint32 start, afs_uint32 end, char *sname, char *sinst) { char *ticketBeg = ticket; int slen; unsigned char life; *ticket++ = 0; /* flags, always send net-byte-order */ putstr(name, 1); putstr(inst, 0); putstr(realm, 0); putint(host); memcpy(ticket, sessionKey, sizeof(struct ktc_encryptionKey)); ticket += sizeof(struct ktc_encryptionKey); life = time_to_life(start, end); if (life == 0) return -1; *ticket++ = life; putint(start); putstr(sname, 1); putstr(sinst, 0); *ticketLen = ticket - ticketBeg; return 0; }
void display(void){ clear(2,4,2); clear(3,4,2); clear(4,4,2); clear(2,11,3); clear(3,11,2); clear(4,11,4); cursorxy(2,4);//set cursor //putint(light,3);//print data from adc putint(light,2); //cursorxy(2,7); putstr((unsigned char*)"%"); cursorxy(2,11); putint(humidity,3); putstr((unsigned char*)"%"); cursorxy(3,4);//set cursor putint(temp1,2);//print data from adc putstr((unsigned char*)"^"); cursorxy(3,11); putint(pressure,2); putstr((unsigned char*)"kP"); cursorxy(4,4);//set cursor putint(temp2,2);//print data from adc putstr((unsigned char*)"^"); cursorxy(4,11); if(soil<30) putstr((unsigned char*)"Wet"); else if(soil>70) putstr((unsigned char*)"Dry"); else putstr((unsigned char*)"Mid"); }
static afs_int32 create_reply(struct packet *ans, char *name, char *inst, Date startTime, Date endTime, afs_int32 kvno, char *cipher, int cipherLen) { char *answer = ans->data; int slen; ans->len = 2 + strlen(name) + strlen(inst) + 3 /*nulls */ + sizeof(afs_int32) + 1 /*ntkts */ + sizeof(afs_int32) + 1 /*kvno */ + sizeof(short) + cipherLen; if (ans->len > sizeof(ans->data)) return KAANSWERTOOLONG; if (kvno > 255) return KAANSWERTOOLONG; *answer++ = (unsigned char)KRB_PROT_VERSION; *answer++ = (unsigned char)AUTH_MSG_KDC_REPLY; /* always send claiming network byte order */ putstr(name); putstr(inst); putstr(""); putint(startTime); *answer++ = 1; /* undocumented number of tickets! */ putint(endTime); *answer++ = (unsigned char)kvno; { short w = (short)cipherLen; w = htons(w); memcpy(answer, &w, sizeof(short)); answer += sizeof(short); } memcpy(answer, cipher, cipherLen); return 0; }
void send_welcome(int n) { ENetPacket * packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE); uchar *start = packet->data; uchar *p = start + 2; putint(p, SV_INITS2C); putint(p, n); putint(p, PROTOCOL_VERSION); putint(p, smapname[0]); sendIString(serverpassword, p); putint(p, clients.size() > maxclients); if (smapname[0]) { putint(p, SV_MAPCHANGE); sendIString(smapname, p); putint(p, mode); putint(p, SV_ITEMLIST); for (int i = 0; i < sents.size(); i++) { if (sents[i].spawned) putint(p, i); } putint(p, -1); }; *(ushort *) start = ENET_HOST_TO_NET_16(p - start); enet_packet_resize(packet, p - start); send(n, packet); }
void sendmap(char *mapname) { if(*mapname) save_world(mapname); changemap(mapname); mapname = getclientmap(); int mapsize; uchar *mapdata = readmap(mapname, &mapsize); if(!mapdata) return; ENetPacket *packet = enet_packet_create(NULL, MAXTRANS + mapsize, ENET_PACKET_FLAG_RELIABLE); uchar *start = packet->data; uchar *p = start+2; putint(p, SV_SENDMAP); sendstring(mapname, p); putint(p, mapsize); if(65535 - (p - start) < mapsize) { conoutf("map %s is too large to send", mapname); free(mapdata); enet_packet_destroy(packet); return; }; memcpy(p, mapdata, mapsize); p += mapsize; free(mapdata); *(ushort *)start = ENET_HOST_TO_NET_16(p-start); enet_packet_resize(packet, p-start); sendpackettoserv(packet); conoutf("sending map %s to server...", mapname); sprintf_sd(msg)("[map %s uploaded to server, \"getmap\" to receive it]", mapname); toserver(msg); }
void foo(int v1, int v2, int v3, int v4, int v5) { putint( v1); putint( v2); putint( v3); putint( v4); putint( v5); }
void serverms(int mode, int numplayers, int minremain, char *smapname, int seconds, bool isfull) { checkmasterreply(); updatemasterserver(seconds); // reply all server info requests ENetBuffer buf; ENetAddress addr; u8 pong[MAXTRANS], *p; int len; enet_uint32 events = ENET_SOCKET_WAIT_RECEIVE; buf.data = pong; while (enet_socket_wait(pongsock, &events, 0) >= 0 && events) { buf.dataLength = sizeof(pong); len = enet_socket_receive(pongsock, &addr, &buf, 1); if (len < 0) return; p = &pong[len]; putint(p, PROTOCOL_VERSION); putint(p, mode); putint(p, numplayers); putint(p, minremain); string mname; strcpy_s(mname, isfull ? "[FULL] " : ""); strcat_s(mname, smapname); sendstring(mname, p); sendstring(serverdesc, p); buf.dataLength = p - pong; enet_socket_send(pongsock, &addr, &buf, 1); } }
static PyObject *sendPacket(PyObject *self, PyObject *args) { int goodcn = -1; packetbuf p(MAXTRANS,ENET_PACKET_FLAG_RELIABLE); putint(p, N_CLIENT); std::cout<<"N_CLIENT "; loopv(server::clients) { int cn = server::clients[i]->clientnum; if(goodcn < 0) goodcn = cn; // find a good cn } putint(p, goodcn); std::cout<<goodcn<<" "; putuint(p, (((unsigned int)PyTuple_Size(args)))*2); std::cout<<(((unsigned int)PyTuple_Size(args))*2)<<" [ "; for(Py_ssize_t i=0;i<PyTuple_Size(args);i++) { int data=PyInt_AsLong(PyTuple_GetItem(args,i)); std::cout<<data<<" "; putint(p, data); } sendpacket(-1, 1, p.finalize(), -1); std::cout<<"- sent\n"; Py_INCREF(Py_None); return Py_None; }
int main(void) { int b[10]; a[7] = 123; b[5] = 456; putint(a[7]); putint(b[5]); return 0; }
int main(void) { int bar; foo = 76; bar = 54321; putint(foo); putint(bar); return 0; }
static int err_packet(int ksoc, struct packet *pkt, afs_int32 code, char *reason) { struct packet ans; char *answer = ans.data; int slen; char buf[256]; if (reason == 0) reason = ""; snprintf(buf, 255, "code = %d: %s", code, reason); if (krb_udp_debug) { printf("Sending error packet to '%s'.'%s'@'%s' containing %s\n", pkt->name, pkt->inst, pkt->realm, buf); } ans.len = 2 + strlen(pkt->name) + strlen(pkt->inst) + strlen(pkt->realm) + 3 /* nulls */ + (2 * sizeof(afs_int32)) + strlen(buf) + 1; if (ans.len > sizeof(ans.data)) { printf("Answer packet too long\n"); return -1; } *answer++ = (unsigned char)KRB_PROT_VERSION; *answer++ = (unsigned char)AUTH_MSG_ERR_REPLY; /* always send claiming network byte order */ putstr(pkt->name); putstr(pkt->inst); putstr(pkt->realm); putint(pkt->time); if ((code < 0) || (code > KERB_ERR_MAXIMUM)) { /* It could be because of kauth errors so we should return something instead of success!! */ code = KDC_GEN_ERR; } putint(code); putstr(buf); code = sendto(ksoc, ans.data, ans.len, 0, (struct sockaddr *)&pkt->from, sizeof(pkt->from)); if (code != ans.len) { if (code >= 0) printf ("call to sendto returned %d, sending error packet %d bytes long\n", code, ans.len); else perror("err_packet: sendto"); } return 0; }
void show_vmstat_top(vmtotal_t *Total, uvmexp_sysctl_t *uvm, uvmexp_sysctl_t *uvm1) { float f1, f2; int psiz; int i, l, c; struct { struct uvmexp_sysctl *uvmexp; } us, us1; us.uvmexp = uvm; us1.uvmexp = uvm1; putint(ucount(), STATROW, STATCOL, 3); putfloat(avenrun[0], STATROW, STATCOL + 17, 6, 2, 0); putfloat(avenrun[1], STATROW, STATCOL + 23, 6, 2, 0); putfloat(avenrun[2], STATROW, STATCOL + 29, 6, 2, 0); mvaddstr(STATROW, STATCOL + 53, buf); putint(Total->t_rq - 1, PROCSROW + 1, PROCSCOL + 3, 3); putint(Total->t_dw, PROCSROW + 1, PROCSCOL + 6, 3); putint(Total->t_sl, PROCSROW + 1, PROCSCOL + 9, 3); PUTRATE(us, us1, uvmexp->swtch, GENSTATROW + 1, GENSTATCOL - 1, 7); PUTRATE(us, us1, uvmexp->traps, GENSTATROW + 1, GENSTATCOL + 7, 6); PUTRATE(us, us1, uvmexp->syscalls, GENSTATROW + 1, GENSTATCOL + 14, 6); PUTRATE(us, us1, uvmexp->intrs, GENSTATROW + 1, GENSTATCOL + 21, 5); PUTRATE(us, us1, uvmexp->softs, GENSTATROW + 1, GENSTATCOL + 27, 6); PUTRATE(us, us1, uvmexp->faults, GENSTATROW + 1, GENSTATCOL + 34, 6); /* Last CPU state not calculated yet. */ for (f2 = 0.0, psiz = 0, c = 0; c < CPUSTATES; c++) { i = cpuorder[c]; f1 = cputime(i); f2 += f1; l = (int) ((f2 + 1.0) / 2.0) - psiz; if (c == 0) putfloat(f1, GRAPHROW, GRAPHCOL + 1, 5, 1, 0); else putfloat(f1, GRAPHROW, GRAPHCOL + 10 * c + 1, 5, 1, 0); mvhline(GRAPHROW + 2, psiz, cpuchar[c], l); psiz += l; } PUTRATE(us, us1, uvmexp->pageins, PAGEROW + 2, PAGECOL + 5, 5); PUTRATE(us, us1, uvmexp->pdpageouts, PAGEROW + 2, PAGECOL + 10, 5); PUTRATE(us, us1, uvmexp->pgswapin, PAGEROW + 3, PAGECOL + 5, 5); PUTRATE(us, us1, uvmexp->pgswapout, PAGEROW + 3, PAGECOL + 10, 5); }
int main (void) { int i; char space[2]; char cr[2]; space[0] = ' '; space[1] = 0; cr[0] = '\n'; cr[1] = 0; i = 0; while (i<=12) { putint(i); putstring(space); putint(fib(i)); putstring(cr); i = i + 1; } }
int main() { unsigned char c; uart0_init(); cur_timer_func = idle_func; init_timer_queue(&global_timer_queue); enqueue_timer(&global_timer_queue,1000,uart_message1); enqueue_timer(&global_timer_queue,300,uart_message2); enqueue_timer(&global_timer_queue,400,uart_message3); putc('T'); putc('e'); putc('s'); putc('t'); putc(':'); putc('\n'); putc('\r'); putstr("str_test"); putint(987649); while(1) { c = getc(); putc(c); } return 0; }
int main(void) { char nameq[]; char ageq[]; char youare[]; char cr[]; char name[80]; int age; nameq = "Your name? "; ageq = "Your age "; youare = "You are: "; cr = "\n"; putstring(nameq); getstring(name); putstring(ageq); age = getint(); putstring(youare); putstring(name); putstring(cr); putstring(youare); putint(age); putstring(cr); }
void send2(bool rel, int cn, int a, int b) { ENetPacket *packet = enet_packet_create(NULL, 32, rel ? ENET_PACKET_FLAG_RELIABLE : 0); uchar *start = packet->data; uchar *p = start + 2; putint(p, a); putint(p, b); *(ushort *) start = ENET_HOST_TO_NET_16(p - start); enet_packet_resize(packet, p - start); if (cn < 0) process(packet, -1); else send(cn, packet); if (packet->referenceCount == 0) enet_packet_destroy(packet); }
Arraylist allGraphs(int rank) { Arraylist result = newArraylist(rank); Intstack cand = newIntstack(0, NULL), fg = fullgraph(rank); unsigned long int x, y, ulim = 1 << fg->size; int i; setRank(rank); for (x = 0L; x < ulim; x++) { cand->size = 0; y = x; i = 0; while (y > 0) { if (y % 2 == 1) putint(fg->it[i], cand); y /= 2; i++; } if (portHistDescending(cand)) { putItem((void*) newIntstack(0, cand), result); } } freestack(cand); freestack(fg); sortAndWeedForGraphs(rank, result); return result; }
int main(void) { int t, n; usi a[MAX], maxcount, minindex, i, max; t = getint(); while(t--) { maxcount = max = minindex = 0; memset(a, 0, sizeof(usi) * MAX); n = getint(); while(n--) { if(++a[i = (usi) (getint() - 1)] > max) { if((max = a[i]) == maxcount && i < minindex) { minindex = i; } else if(max > maxcount) { maxcount = max; minindex = i; } } } putint((int) (minindex + 1)); putchar(' '); putint((int) maxcount); putchar('\n'); for(i = 0; i < MAX; i++) if(a[i]) printf("###\t\t%d : %d\n", i + 1, a[i]); putchar('\n'); } return 0; }
bool CslGameAssaultCube::PingDefault(ucharbuf& buf, CslServerInfo& info) const { putint(buf, m_fourcc); if (info.Protocol==-1 || info.Protocol>=1128) // >=1.0.x { if (info.InfoText.IsEmpty()) { putint(buf, AC_EXTPING_SERVERINFO); putint(buf, 'e'); putint(buf, 'n'); return true; } } putint(buf, AC_EXTPING_NOP); return true; }
Intstack fullgraph(int rank) { Intstack result = newIntstack(rank * (rank-1) / 2, NULL); int p, q = 2, qlim = 1 << rank; for (q = 2; q < qlim; q <<= 1) for (p = 1; p < q; p <<= 1) putint(p+q, result); assert(result->size == rank * (rank-1) / 2); return result; }
int main(void) { int i; char space[2]; char cr[2]; space[0] = ' '; space[1] = '\0'; cr[0] = '\n'; cr[1] = (char)0; i = 0; while (i<=10) { putint(i); putstring(space); putint(fac(i)); putstring(cr); i = i + 1; } return 0; }
static void oputint( /* write a siz-byte integer to stdout */ register long i, register int siz ) { putint(i, siz, stdout); if (ferror(stdout)) error(SYSTEM, "write error in putint"); }
int main(void){ //printf("hello"); //printf("\nhello again\n"); int ret; char *exit = "Exiting program\n"; char *help0 = "List of utilities\n"; char *help1 = "help\tDisplays this help menu\n"; char *help2 = "exit\tTerminates execution of the shell\n"; char *help3 = "echo\tSimple utility that writes to stdout\n"; char input[INPUT_BUFFER]; while(!(strcmp(input,"exit\n")==1)){ putchar('>'); fgets(INPUT_BUFFER, input); if(strcmp(input,"help\n")==1){ putchar('\n'); printf("%s", help0); printf("%s", help1); printf("%s",help2); printf("%s", help3); ret = 0; } else if(strncmp(input, "echo",4)==1){ if(input[5] == 36 && input[6]==63){ //help(0); putint(ret); putchar('\n'); } else{ int x = strlen(input); int z = 5; while(z<x){ putchar(input[z]); z++; } } } else if(strcmp(input,"exit\n")==1); else{ if(strlen(input)>256){ printf("Path is too long\n"); ret = -1; } else{ char buff[INPUT_BUFFER]; strncpy(buff, input, strlen(input)-2); ret = exec(buff); if(ret == -1){ printf("%s:command not found\n", buff); } } } } printf("%s", exit); }
static afs_int32 create_cipher(char *cipher, int *cipherLen, struct ktc_encryptionKey *sessionKey, char *sname, char *sinst, Date start, Date end, afs_int32 kvno, char *ticket, int ticketLen, struct ktc_encryptionKey *key) { char *answer; int slen; unsigned char life = time_to_life(start, end); int len; DES_key_schedule schedule; afs_int32 code; answer = cipher; len = sizeof(*sessionKey) + strlen(sname) + strlen(sinst) + strlen(lrealm) + 3 /*nulls */ + 3 + ticketLen + sizeof(Date); if (len > *cipherLen) return KAANSWERTOOLONG; if (ticketLen > 255) return KAANSWERTOOLONG; if (kvno > 255) return KAANSWERTOOLONG; memcpy(answer, sessionKey, sizeof(*sessionKey)); answer += sizeof(*sessionKey); putstr(sname); putstr(sinst); putstr(lrealm); *answer++ = life; *answer++ = (unsigned char)kvno; *answer++ = (unsigned char)ticketLen; memcpy(answer, ticket, ticketLen); answer += ticketLen; putint(start); if (krb_udp_debug) { printf("Printing ticket (%d) and date: ", ticketLen); ka_PrintBytes(ticket, ticketLen); ka_PrintBytes(answer - 4, 4); printf("\n"); } if ((code = DES_key_sched(ktc_to_cblock(key), &schedule))) printf("In KAAuthenticate: key_sched returned %d\n", code); DES_pcbc_encrypt(cipher, cipher, len, &schedule, ktc_to_cblockptr(key), ENCRYPT); *cipherLen = round_up_to_ebs(len); if (krb_udp_debug) { printf("Printing cipher (%d): ", *cipherLen); ka_PrintBytes(cipher, *cipherLen); printf("\n"); } return 0; }
void getmap() { ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE); uchar *start = packet->data; uchar *p = start+2; putint(p, SV_RECVMAP); *(ushort *)start = ENET_HOST_TO_NET_16(p-start); enet_packet_resize(packet, p-start); sendpackettoserv(packet); conoutf("requesting map from server..."); }
void sendservmsg(const char *msg) { ENetPacket *packet = enet_packet_create(NULL, MAXDEFSTR+10, ENET_PACKET_FLAG_RELIABLE); u8 *start = packet->data; u8 *p = start+2; putint(p, SV_SERVMSG); sendstring(msg, p); *(u16 *)start = ENET_HOST_TO_NET_16(int(p-start)); enet_packet_resize(packet, p-start); multicast(packet, -1); if (packet->referenceCount==0) enet_packet_destroy(packet); }
inline void putint(int N) { if(N < 0) { putchar('-'); N *= -1; // check for potential overflows } if(N >= 10) putint(N / 10); putchar((N % 10) + '0'); }
static void dinfo(int dn, int c) { double words, atime; c += DISKCOL; /* time busy in disk activity */ atime = (double)cur.dk_time[dn].tv_sec + ((double)cur.dk_time[dn].tv_usec / (double)1000000); /* # of K transferred */ words = (cur.dk_rbytes[dn] + cur.dk_wbytes[dn]) / 1024.0; putint((int)((float)cur.dk_seek[dn]/etime+0.5), DISKROW + 1, c, 5); putint((int)((float)(cur.dk_rxfer[dn] + cur.dk_wxfer[dn])/etime+0.5), DISKROW + 2, c, 5); putintmk((int)(words/etime + 0.5), DISKROW + 3, c, 5); putfloat(atime/etime, DISKROW + 4, c, 5, 1, 1); }
void putflt( /* put out floating point number */ double f, FILE *fp ) { long m; int e; m = frexp(f, &e) * 0x7fffffff; if (e > 127) { /* overflow */ m = m > 0 ? (long)0x7fffffff : -(long)0x7fffffff; e = 127; } else if (e < -128) { /* underflow */ m = 0; e = 0; } putint(m, 4, fp); putint((long)e, 1, fp); }