void print(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vfprint(stdout, NULL, fmt, ap); va_end(ap); }
static void error(char *fmt, ...) { va_list arg; if(gzok) fprint(2, "gunzip: %s: corrupted data after byte %lld ignored\n", infile, gzok); else{ fprint(2, "gunzip: "); if(infile) fprint(2, "%s: ", infile); va_start(arg, fmt); vfprint(2, fmt, arg); va_end(arg); fprint(2, "\n"); if(delfile != nil){ fprint(2, "gunzip: removing output file %s\n", delfile); remove(delfile); delfile = nil; } } longjmp(zjmp, 1); }
static void taskdebug(char *fmt, ...) { va_list arg; char buf[128]; Task *t; char *p; static int fd = -1; return; va_start(arg, fmt); vfprint(1, fmt, arg); va_end(arg); return; if(fd < 0){ p = strrchr(argv0, '/'); if(p) p++; else p = argv0; snprint(buf, sizeof buf, "/tmp/%s.tlog", p); if((fd = open(buf, O_CREAT|O_WRONLY, 0666)) < 0) fd = open("/dev/null", O_WRONLY); } va_start(arg, fmt); vsnprint(buf, sizeof buf, fmt, arg); va_end(arg); t = taskrunning; if(t) fprint(fd, "%d.%d: %s\n", getpid(), t->id, buf); else fprint(fd, "%d._: %s\n", getpid(), buf); }
/* fprint - formatted output to f */ void fprint(FILE *f, const char *fmt, ...) { va_list ap; va_start(ap, fmt); vfprint(f, NULL, fmt, ap); va_end(ap); }
/* comment - emits an assembly language comment */ static void comment(char *fmt, ...) { va_list ap; print(leader); va_start(ap, fmt); vfprint(stdout, NULL, fmt, ap); va_end(ap); }
void sysfatal(char *fmt, ...) { va_list arg; va_start(arg, fmt); vfprint(2, fmt, arg); va_end(arg); }
void debug(int flag, const char *fmt, ...) { va_list ap; USED(flag); va_start(ap, fmt); vfprint(2, fmt, ap); va_end(ap); }
/* stringf - formatted output to a saved string */ char *stringf(const char *fmt, ...) { char buf[1024]; va_list ap; va_start(ap, fmt); vfprint(NULL, buf, fmt, ap); va_end(ap); return string(buf); }
static void cpperr(State *s, char *fmt, ...) { va_list arg; fprint(2, "%s %s:%d ", argv0, s->file, s->line); va_start(arg, fmt); vfprint(2, fmt, arg); va_end(arg); }
/* * print goes to fd 2 [sic] because fd 1 might be * otherwise preoccupied when the -s flag is given to kfs. */ int print(char *fmt, ...) { va_list arg; int n; va_start(arg, fmt); n = vfprint(2, fmt, arg); va_end(arg); return n; }
int fprint(int fd, char *fmt, ...) { int n; va_list args; va_start(args, fmt); n = vfprint(fd, fmt, args); va_end(args); return n; }
void debugPrint(int verb, const char * msg, ...) { if(verb <= verbosity) { va_list argptr; va_start(argptr, msg); vfprint(stdout, msg, argptr); va_end(argptr); } }
static void warn(char *fmt, ...) { va_list arg; va_start(arg, fmt); fprint(2, "vac: "); vfprint(2, fmt, arg); fprint(2, "\n"); va_end(arg); }
/* warning - issue warning error message */ void warning(const char *fmt, ...) { va_list ap; va_start(ap, fmt); if (wflag == 0) { errcnt--; error("warning: "); vfprint(stderr, NULL, fmt, ap); } va_end(ap); }
int print(char *fmt, ...) { int n; va_list args; va_start(args, fmt); n = vfprint(1, fmt, args); va_end(args); return n; }
void panic(char *fmt, ...) { va_list arg; va_start(arg, fmt); vfprint(2, fmt, arg); va_end(arg); fprint(2, "\n"); abort(); }
void chat(char *fmt, ...) { va_list arg; if(chatty){ va_start(arg, fmt); vfprint(2, fmt, arg); va_end(arg); } }
int chat(char *fmt, ...) { va_list arg; if(!chatty) return 0; va_start(arg, fmt); vfprint(2, fmt, arg); va_end(arg); return 1; }
void ctlprint(int fd, char *fmt, ...) { int n; va_list arg; va_start(arg, fmt); n = vfprint(fd, fmt, arg); va_end(arg); if(n <= 0) error("control file write error: %r"); }
static int32_t _iovfprint(va_list *arg) { int fd; char *fmt; va_list arg2; fd = va_arg(*arg, int); fmt = va_arg(*arg, char*); arg2 = va_arg(*arg, va_list); return vfprint(fd, fmt, arg2); }
void vtFatal(char *fmt, ...) { va_list arg; va_start(arg, fmt); fprint(2, "fatal error: "); vfprint(2, fmt, arg); fprint(2, "\n"); va_end(arg); exits("vtFatal"); }
BTGE_API void BTGE_BrushMap_SaveEntity( BTGE_BrushWorld *world, VFILE *fd, BTGE_SEntity *ent) { BTGE_SEntPair *epcur; BTGE_Brush *bcur; char *s; vfprint(fd, "{\n"); epcur=ent->keys; while(epcur) { vfprint(fd, "\"%s\" \"%s\"\n", epcur->name, epcur->value); epcur=epcur->next; } bcur=ent->brush; while(bcur) { BTGE_BrushMap_SaveBrush(world, fd, bcur); bcur=bcur->enext; } //any brushes w/o owners go to worldspawn s=BTGE_SEnt_GetStr(ent, "classname"); if(!strcmp(s, "worldspawn")) { bcur=world->brush; while(bcur) { if(!bcur->se_owner) { BTGE_BrushMap_SaveBrush(world, fd, bcur); } bcur=bcur->next; } } vfprint(fd, "}\n"); }
void ctlprint(int fd, char *fmt, ...) { int n; va_list arg; char buf[256]; va_start(arg, fmt); n = vfprint(fd, fmt, arg); va_end(arg); if(n < 0) error("control file write(%s) error: %r", buf); }
int pod_experiment(char* observed_data, char* heldout_data, char* model_root, char* out) { corpus *obs, *heldout; llna_model *model; llna_var_param *var; int i; gsl_vector *log_lhood, *e_theta; doc obs_doc, heldout_doc; char string[100]; double total_lhood = 0, total_words = 0, l; FILE* e_theta_file = fopen("/Users/blei/llna050_e_theta.txt", "w"); // load model and data obs = read_data(observed_data); heldout = read_data(heldout_data); assert(obs->ndocs == heldout->ndocs); model = read_llna_model(model_root); // run experiment init_temp_vectors(model->k-1); // !!! hacky log_lhood = gsl_vector_alloc(obs->ndocs + 1); e_theta = gsl_vector_alloc(model->k); for (i = 0; i < obs->ndocs; i++) { // get observed and heldout documents obs_doc = obs->docs[i]; heldout_doc = heldout->docs[i]; // compute variational distribution var = new_llna_var_param(obs_doc.nterms, model->k); init_var_unif(var, &obs_doc, model); var_inference(var, &obs_doc, model); expected_theta(var, &obs_doc, model, e_theta); vfprint(e_theta, e_theta_file); // approximate inference of held out data l = log_mult_prob(&heldout_doc, e_theta, model->log_beta); vset(log_lhood, i, l); total_words += heldout_doc.total; total_lhood += l; printf("hid doc %d log_lhood %5.5f\n", i, vget(log_lhood, i)); // save results? free_llna_var_param(var); } vset(log_lhood, obs->ndocs, exp(-total_lhood/total_words)); printf("perplexity : %5.10f", exp(-total_lhood/total_words)); sprintf(string, "%s-pod-llna.dat", out); printf_vector(string, log_lhood); return(0); }
void warn(char *fmt, ...) { va_list arg; if(++nwarn < 5){ va_start(arg, fmt); fprint(2, "warning: "); vfprint(2, fmt, arg); fprint(2, "\n"); va_end(arg); }else if(nwarn == 5) fprint(2, "[additional warnings elided...]\n"); }
BTGE_API void BTGE_BrushMap_SaveBrush( BTGE_BrushWorld *world, VFILE *fd, BTGE_Brush *brush) { float tv0[3], tv1[3], tv2[3]; float *sd, *td; int i; if(brush->patch) { BTGE_BrushMap_SaveBrushPatch(world, fd, brush); return; } vfprint(fd, " {\n"); for(i=0; i<brush->n_face; i++) { V3F_SCALE(brush->norm+i*4, brush->norm[i*4+3], tv0); Hull_AdjacentNormals(brush->norm+i*4, tv2, tv1); V3F_ADDSCALE(tv0, tv1, 128, tv1); V3F_ADDSCALE(tv0, tv2, 128, tv2); sd=brush->sdir+i*4; td=brush->tdir+i*4; vfprint(fd, " ( %.2f %.2f %.2f ) ( %.2f %.2f %.2f ) " "( %.2f %.2f %.2f ) %s " "[ %.4f %.4f %.4f %.4f ] [ %.4f %.4f %.4f %.4f ] " "0 1.00000 1.00000 0 0 0\n", tv0[0], tv0[1], tv0[2], tv1[0], tv1[1], tv1[2], tv2[0], tv2[1], tv2[2], brush->tex[i], sd[0], sd[1], sd[2], sd[3], td[0], td[1], td[2], td[3]); } vfprint(fd, " }\n"); }
void error(const char *fmt, ...) { va_list ap; if (errcnt++ >= errlimit) { errcnt = -1; error("too many errors\n"); exit(1); } va_start(ap, fmt); if (firstfile != file && firstfile && *firstfile) fprint(stderr, "%s: ", firstfile); fprint(stderr, "%w: ", &src); vfprint(stderr, NULL, fmt, ap); va_end(ap); }
void debuglog(char *fmt, ...) { va_list arg; static int logfd; if(debug == 0) return; if(logfd == 0) logfd = open("/sys/log/imap4d", OWRITE); if(logfd > 0){ va_start(arg, fmt); fprint(logfd, "%s: ", username); vfprint(logfd, fmt, arg); va_end(arg); } }
static int reporter(char *fmt, ...) { va_list ap; char buf[2000]; va_start(ap, fmt); if(logfile){ vsnprint(buf, sizeof buf, fmt, ap); syslog(0, logfile, "%s tls reports %s", remotesys, buf); }else{ fprint(2, "%s: %s tls reports ", argv0, remotesys); vfprint(2, fmt, ap); fprint(2, "\n"); } va_end(ap); return 0; }
static void error(char *fmt, ...) { va_list arg; fprint(2, "unzip: "); va_start(arg, fmt); vfprint(2, fmt, arg); va_end(arg); fprint(2, "\n"); if(delfile != nil){ fprint(2, "unzip: removing output file %s\n", delfile); remove(delfile); delfile = nil; } longjmp(zjmp, 1); }