int process_args(int argc, char **argv) { int i; if (argc != 2) { help(); return -1; } for (i = 1; i < argc; i++) { if (argue(argc, argv[i]) != 0) { return -1; } } return 0; }
int main(int argc, char *argv[]) { off_t cursor = 0, seek_point; int f, x, y, symbol; char command[60]; char mask[60]; unsigned char data[16]; argue(argc, argv); if (arguments == 0) { printf("one file argument required\n"); return 0; } #ifdef DOS f = open(argument[0], O_RDONLY | O_BINARY, 0); #else f = open(argument[0], O_RDONLY, 0); #endif if (f < 0) { printf("%s not read code %d\n", argument[0], errno); return 0; } for (;;) { y = read(f, data, 16); if (y < 0) break; printf("%16.16llx: ", cursor); for (x = 0; x < y; x++) printf("%2.2x", data[x]); while (x++ < 16) printf(" "); printf(" \""); for (x = 0; x < y; x++) { symbol = data[x]; if ((symbol > 0x1F) && (symbol < 0x7F)) putchar(symbol); else putchar('.'); } while (x++ < 16) putchar(' '); putchar('\"'); fflush(stdout); if (y < 16) break; cursor += 16; if (uflag['Z'-'A']) { if (flag['e'-'a'] == 0) putchar('\n'); continue; } x = read(0, command, 60 - 1); if (x > 0) { command[x] = 0; if (command[0] == '.') break; if ((command[0] > '0' - 1) && (command[0] < '9' + 1)) { if (command[0] == '0') y = sscanf(command, "%llx %[^\r\n]", &cursor, mask); else y = sscanf(command, "%lld %[^\r\n]", &cursor, mask); seek_point = lseek(f, (off_t) cursor, SEEK_SET); if (seek_point < 0) { printf("position not taken\n"); break; } if (y > 1) { y = strlen(mask); if (y > 16) y = 16; x = read(f, data, y); if (x < y) break; symbol = y - 1; for (;;) { x = memcmp(data, mask, y); if (x == 0) break; memcpy(data, data + 1, symbol); x = read(f, data + symbol, 1); if (x < 1) break; } cursor = lseek(f, (off_t) 0, SEEK_CUR); cursor -= y; seek_point = lseek(f, (off_t) cursor, SEEK_SET); if (x < 0) break; } } if (command[0] == '+') { y = strlen(mask); if (y > 16) y = 16; x = read(f, data, y); if (x < y) break; symbol = y - 1; for (;;) { x = memcmp(data, mask, y); if (x == 0) break; memcpy(data, data + 1, symbol); x = read(f, data + symbol, 1); if (x < 1) break; } cursor = lseek(f, (off_t) 0, SEEK_CUR); cursor -= y; seek_point = lseek(f, cursor, SEEK_SET); if (x < 0) break; } if (command[0] == '-') { reflag(command + 1); putchar('\n'); } } } putchar('\n'); close(f); return 0; }
int main(int argc, char *argv[]) { #ifdef DAYCLOCK #ifdef X86_MSW SYSTEMTIME stime; FILETIME ftime; #else struct timeval time; #endif int instructions = INTERVAL; int imask; #endif int _x; #ifdef DAYCLOCK unsigned long long time_pointer; #endif #ifdef LP_TSLICE_HERE /* It's not. It's in engine.rta/rta.c:execute() */ int icount; #endif char command[84]; int index = 1; int offset; int symbol; char *file; int f, count, image_size = 0; word *load_address = memory.array; word data_word = { 0, 0, 0, 0 } ; #ifdef METRIC struct timeval time2; #endif #ifdef ASYNC #ifdef X86_MSW #else pthread_attr_t asyncb; pthread_t asyncid; #endif #endif argue(argc, argv); if (arguments) { #ifdef X86_MSW f = open(argument[0], O_RDONLY | O_BINARY, 0444); #else f = open(argument[0], O_RDONLY, 0444); #endif if (f < 0) { printf("rom image file not available\n"); return 0; } if (flag['v'-'a']) { printf("reading %s with options:\n", argument[0]); if (flag['s'-'a']) printf("-s\tsingle step\n"); if (flag['v'-'a']) printf("-v\tvocal\n"); if (flag['l'-'a']) printf("-l\tline per instruction\n"); } for (;;) { count = read(f, (void *) &data_word.t1, 3); if (count < 1) break; if (count ^ 3) printf("last load word incomplete\n"); *load_address++ = data_word; image_size++; } printf("rom image %d target words read\n", image_size); image_size += 4095; base[124] = image_size >> 12; /* ROM boundary port */ base[128] = PAGES_IN_MEMORY - 1; /* system memory size port */ close(f); } else {
int main(int argc, char *argv[]) { unsigned char sdata[TEXT]; unsigned char rdata[TEXT]; #ifdef DOS int wnet = WSAStartup(MAKEWORD(1, 1), &wsa); int s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); int f = 1; int u = ioctlsocket(s, FIONBIO, &f); #else int s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); int f = fcntl(s, F_GETFL, 0); int u = fcntl(s, F_SETFL, f | O_NONBLOCK); #endif int x, y, maxtry, symbol; int resends, bytes; unsigned char *p; unsigned char newnet[ARGUMENTS][4]; FILE *config = fopen("config.fp", "r"); argue(argc, argv); if (flag['v'-'a']) { #if DOS printf("[wsa %d socket %d cntl %d:%d]\n", wnet, s, f, u); if (wnet) printf("[wsadetail %d\n]", WSAGetLastError()); #else printf("[socket %d cntl %d:%d]\n", s, f, u); #endif } if (config) { while (p = fgets(rdata, TEXT-1, config)) { if (flag['q'-'a']) printf(p); x = sscanf(rdata, "%s %hhd.%hhd.%hhd.%hhd", sdata, &newnet[0][0], &newnet[0][1], &newnet[0][2], &newnet[0][3]); if (strcmp(sdata, "fp-client") == 0) { local.sin_addr.s_addr = *((long *) newnet[0]); } if (strcmp(sdata, "fp-server") == 0) { target.sin_addr.s_addr = *((long *) newnet[0]); } } fclose(config); } for (x = 0; x < arguments; x++) { y = sscanf(argument[x], "%hhd.%hhd.%hhd.%hhd", &newnet[x][0], &newnet[x][1], &newnet[x][2], &newnet[x][3]); } if (arguments) target.sin_addr.s_addr = *((long *) newnet[0]); if (arguments > 1) local.sin_addr.s_addr = *((long *) newnet[1]); if (flag['v'-'a']) printf("[%8.8X > %8.8X]\n", local.sin_addr.s_addr, target.sin_addr.s_addr); x = bind(s, (struct sockaddr *) &local, 16); y = connect(s, (struct sockaddr *) &target, 16); if ((uflag['Q'-'A'] == 0) || (s < 0) || (x < 0) || (f < 0) || (u < 0) || (y < 0)) printf("remote application socket %d bind state %d " "F %x NB %d udconnect state %d\n", s, x, f, u, y); for (;;) { p = fgets(sdata, TEXT, stdin); if (!p) break; if (flag['p'-'a']) printf(p); if (sdata[0] == '.') break; resends = 1; if (uflag['R'-'A']) resends = RESENDS; bytes = strlen(sdata); while (resends--) { /***************************************************** RESEND is about sending again optionally for scripted benchmarks where one lost UDP response ought not stop benchmark *****************************************************/ x = send(s, sdata, bytes, 0); if ((uflag['Q'-'A'] == 0) || (x < 0)) printf("send state %d\n", x); if (flag['z'-'a']) continue; maxtry = MAXTRY; while (maxtry--) { /************************************************* MAXTRY is about restarting the nonblock receive / wait. There are MAXTRY polls *************************************************/ x = recv(s, rdata, TEXT, 0); if (x < 0) { if ((detail_code == EAGAIN) || (detail_code == EWOULDBLOCK)) { x = 0; usleep(TWARP); } else { printf("RX state %d\n", detail_code); break; } } if (x) break; } if (x) break; } if (x < 0) rdata[0] = 0; else rdata[x] = 0; if (flag['x'-'a']) { printf("recv state %d/%d\n", x, errno); for (y = 0; y < x; y++) printf("%2.2x", rdata[y]); if (y) putchar(10); } else { if ((uflag['Q'-'A'] == 0) || (x < 0)) printf("recv state %d/%d %s", x, errno, rdata); else if (x >= 0) printf("%s", rdata); } } #ifdef DOS closesocket(s); #else close(s); #endif return 0; }
int main(int argc, char *argv[]) { int _x; char text[72]; char *_p; #ifdef X86_MSW start_time = GetTickCount64(); #else pthread_attr_t asyncb; pthread_t asyncid; gettimeofday(&time1, NULL); start_time = time1.tv_sec * 1000 + time1.tv_usec / 1000; #endif int f, count, image_size = 0; word *load_address = memory.array; word data_word = { 0, 0, 0, 0 } ; argue(argc, argv); if (arguments) { #ifdef X86_MSW f = open(argument[0], O_RDONLY | O_BINARY, 0444); #else f = open(argument[0], O_RDONLY, 0444); #endif if (f < 0) { printf("rom image file not available\n"); return 0; } if (flag['v'-'a']) { printf("reading %s with options:\n", argument[0]); if (flag['s'-'a']) printf("-s\tsingle step\n"); if (flag['v'-'a']) printf("-v\tvocal\n"); if (flag['l'-'a']) printf("-l\tline per instruction\n"); } for (;;) { count = read(f, (void *) &data_word.t1, 3); if (count < 1) break; if (count ^ 3) printf("last load word incomplete\n"); *load_address++ = data_word; image_size++; } printf("rom image %d target words read\n", image_size); image_size += 4095; base[124] = image_size >> 12; /* ROM boundary port */ base[128] = PAGES_IN_MEMORY - 1; /* system memory size port */ close(f); } else {