void js_of_file(char *path_in, char *path_out){ FILE *in, *out; char tmp[PATH_MAX]; char js[PATH_MAX]; int n; n = nlines(path_in); in = fopen(path_in, "r"); out = fopen(path_out, "w+"); fputs("var shiva = [\n", out); while (fgets(tmp, PATH_MAX, in)){ n--; tmp[strlen(tmp) - 1] = '\0'; json_of_line(tmp, js); fputs(js, out); if (n) fputs(",\n", out); } fputs("\n];", out); fclose(in); fclose(out); }
static int setsize() { static int oldn = 0; int n; if (opts.o_outpmode & OPT_FULLSCREEN) { n = nlines(); if (n == oldn) return (0); oldn = n; if (n == -1) { opts.o_outpmode &= ~OPT_USEHOME; setmovecur(); /* set default window size */ return (1); } n = n - 3; /* minus header, total and cursor lines */ if (n < 1) Die(gettext("window is too small (try -n)\n")); if (opts.o_outpmode & OPT_SPLIT) { if (n < 8) { Die(gettext("window is too small (try -n)\n")); } else { opts.o_ntop = (n / 4) * 3; opts.o_nbottom = n - 1 - opts.o_ntop; } } else { if (opts.o_outpmode & OPT_USERS) opts.o_nbottom = n; else opts.o_ntop = n; } } setmovecur(); return (1); }