void read_complete(const char *arg, struct session *ses) { FILE *myfile; char buffer[BUFFER_SIZE]; bool flag = true; struct completenode *tcomplete, *tcomp2; if (!(complete_head = (struct completenode *)(malloc(sizeof(struct completenode))))) { fprintf(stderr, "couldn't alloc completehead\n"); user_done(); exit(1); } tcomplete = complete_head; if (!(myfile = fopen("tab.txt", "r"))) { if (const char *cptr = getenv("HOME")) { snprintf(buffer, BUFFER_SIZE, "%s/.tab.txt", cptr); myfile = fopen(buffer, "r"); } } if (!myfile) { tintin_eprintf(0, "no tab.txt file, no completion list"); return; } while (fgets(buffer, sizeof(buffer), myfile)) { char *cptr; for (cptr = buffer; *cptr && *cptr != '\n'; cptr++) ; *cptr = '\0'; if (!(tcomp2 = (struct completenode *)(malloc(sizeof(struct completenode))))) { fprintf(stderr, "couldn't alloc completehead\n"); user_done(); exit(1); } if (!(cptr = (char *)(malloc(strlen(buffer) + 1)))) { fprintf(stderr, "couldn't alloc memory for string in complete\n"); user_done(); exit(1); } strcpy(cptr, buffer); tcomp2->strng = cptr; tcomplete->next = tcomp2; tcomplete = tcomp2; } tcomplete->next = NULL; fclose(myfile); tintin_printf(0, "tab.txt file loaded."); tintin_printf(0, ""); }
static void sigfpe(void) { if (ui_own_output) user_done(); fflush(0); /* write(2, "Floating point exception.\n", 26);*/ signal(SIGFPE, SIG_DFL); raise(SIGFPE); /* exit(SIGFPE);*/ }
static void sigsegv(void) { if (ui_own_output) user_done(); fflush(0); /* write(2, "Segmentation fault.\n", 20);*/ signal(SIGSEGV, SIG_DFL); raise(SIGSEGV); /* exit(SIGSEGV);*/ }
void syserr(const char *msg, ...) { va_list ap; if (ui_own_output) user_done(); if (errno) fprintf(stderr, "ERROR (%s): ", strerror(errno)); else fprintf(stderr, "ERROR: "); va_start(ap, msg); vfprintf(stderr, msg, ap); va_end(ap); fprintf(stderr, "\n"); exit(1); }
void test_user_done(struct event *e, struct sim_state *s){ user_done(e, s); log_info("Download done at %lfs\n", s->now); }