int main (int argc, char **argv) { FILE *ofile; int nlambda = 0; int i, m; double zn, zvar, tw, tail; double *xx[0], *lambda; readcommands (argc, argv); settwxtable (twxtab); if (oname == NULL) ofile = stdout; else openit (oname, &ofile, "w"); if (iname == NULL) fatalx ("i paraameter compulsory\n"); nlambda = numlines (iname); ZALLOC(lambda, nlambda, double); xx[0] = lambda; nlambda = getxx (xx, nlambda, 1, iname); vst (lambda, lambda, -1.0, nlambda); sortit (lambda, NULL, nlambda); vst (lambda, lambda, -1.0, nlambda); m = numgtz (lambda, nlambda); fprintf (ofile, "%4s %12s", "#N", "eigenvalue"); fprintf (ofile, "%12s", "difference"); fprintf (ofile, " %9s %12s", "twstat", "p-value"); fprintf (ofile, " %9s", "effect. n"); fprintf (ofile, "\n"); for (i = 0; i < m; ++i) { zn = nval; tail = dotwcalc (lambda + i, m - i, &tw, &zn, &zvar, minleneig); fprintf (ofile, "%4d %12.6f", i + 1, lambda[i]); if (i == 0) fprintf (ofile, "%12s", "NA"); else fprintf (ofile, "%12.6f", lambda[i] - lambda[i - 1]); if (tail >= 0.0) fprintf (ofile, " %9.3f %12.6g", tw, tail); else fprintf (ofile, " %9s %12s", "NA", "NA"); if (zn > 0.0) { fprintf (ofile, " %9.3f", zn); } else { fprintf (ofile, " %9s", "NA"); } fprintf (ofile, "\n"); } return 0; }
void gettw(double x, double *tailp, double *densp) // main routine for accessing twtable { int k, n ; double x0, x1, f0, f1, f0p, f1p ; double *xx[3] ; if (twtabsize = -1) { if (settwxtable(TWXTABLE) < 0) fatalx("twtable not readable %s\n", TWXTABLE) ; k = numlines(twxtable) ; ZALLOC(twxval, k, double) ; ZALLOC(twxpdf, k, double) ; ZALLOC(twxtail, k, double) ; xx[0] = twxval ; xx[1] = twxtail ; xx[2] = twxpdf ; twtabsize = getxx(xx, k, 3, twxtable) ; } n = twtabsize ; k = firstgtx(x, twxval, n) ; if (k<=0) { *tailp = 1.0 ; *densp = 0.0 ; return ; } if (k>=n) { *tailp = twdensx(x) ; *densp = twtailx(x) ; return ; } x0 = twxval[k-1] ; x1 = twxval[k] ; f0 = twxtail[k-1] ; f0p = twxpdf[k-1] ; f1 = twxtail[k] ; f1p = twxpdf[k] ; // now do cubic interpolation cinterp(x, x0, x1, f0, -f0p, f1, -f1p, tailp, densp) ; *densp = - *densp ; /** printf("zzz %9.3f %9.3f %9.3f\n", x0, x1, x) ; printf("zz1 %9.3f %9.3f %9.3f\n", f0, f1, *tailp) ; printf("zz2 %9.3f %9.3f %9.3f\n", f0p, f1p, *densp) ; */ }
int fnumlines(char const *filename) { int len = filelen(filename); if (len == ERROR) return ERROR; else { char buf[len]; getfile(filename,sizeof buf,buf); return numlines(sizeof buf,buf); } }
void callwtjack(char *iname, char *oname) { FILE *ifile, *ofile ; char line[MAXSTR]; char *sx; char *spt[MAXFF]; int nsplit, len, i, k; char c; openit(iname, &ifile, "r") ; openit(oname, &ofile, "w") ; double *jwt, *jmean; /* output variable */ double est, sig; // NB est =0; sig=0; /*input variables */ len = numlines(iname); ZALLOC(jwt, len, double); ZALLOC(jmean, len, double); k = 0; /* read input file and store data */ while (fgets(line,MAXSTR,ifile) != NULL) { nsplit = splitup(line, spt, MAXFF); sx = spt[0]; c = sx[0]; if (c == '#') { freeup(spt, nsplit); continue; } jwt[k] = atof(spt[1]); jmean[k] = atof(spt[2]); //printf("mean: %9.3f len: %9.3f\n", jmean[k], jwt[k]) ; k++; freeup(spt, nsplit); } len = k ; // better style who knows how numlines handles commas fclose(ifile) ; // printf("mean: %9.3f len: %d\n", mean, len) ; /*call weightjack */ weightjack(&est, &sig, mean, jmean, jwt, len); fprintf(ofile,"%9.3f", est); // d format ?? fprintf(ofile,"%9.3f", sig); fprintf(ofile,"\n"); free(jmean); free(jwt); fclose(ofile) ; }
/***************************************************************************** Name: string_append Purpose: Puts player into append mode for given string. Called by: (many)olc_act.c ****************************************************************************/ void string_append(CHAR_DATA * ch, char **pString) { send_to_char("-=======- Entering APPEND Mode -========-\r\n", ch); send_to_char(" Type .h on a new line for help\r\n", ch); send_to_char(" Terminate with a ~ or @ on a blank line.\r\n", ch); send_to_char("-=======================================-\r\n", ch); if (*pString == NULL) { *pString = str_dup(""); } send_to_char(numlines(*pString), ch); /* numlines sends the string with \r\n */ /* if ( *(*pString + strlen( *pString ) - 1) != '\r' ) send_to_char( "\r\n", ch ); */ ch->desc->pString = pString; return; }
static gpointer external_editor_thread (gpointer user_data) { EMsgComposer *composer = user_data; gchar *filename = NULL; gint status = 0; GSettings *settings; gchar *editor_cmd_line = NULL, *editor_cmd = NULL, *content; gint fd, position = -1, offset = -1; /* prefix temp files with evo so .*vimrc can be setup to recognize them */ fd = g_file_open_tmp ("evoXXXXXX", &filename, NULL); if (fd > 0) { gsize length = 0; close (fd); d (printf ("\n\aTemporary-file Name is : [%s] \n\a", filename)); /* Push the text (if there is one) from the composer to the file */ content = gtkhtml_editor_get_text_plain (GTKHTML_EDITOR (composer), &length); g_file_set_contents (filename, content, length, NULL); } else { struct run_error_dialog_data *data; data = g_new0 (struct run_error_dialog_data, 1); data->composer = composer; data->text = "org.gnome.evolution.plugins.external-editor:no-temp-file"; g_warning ("Temporary file fd is null"); /* run_error_dialog also calls enable_composer */ g_idle_add ((GSourceFunc) run_error_dialog, data); goto finished; } settings = g_settings_new ("org.gnome.evolution.plugin.external-editor"); editor_cmd = g_settings_get_string (settings, "command"); if (!editor_cmd) { if (!(editor_cmd = g_strdup (g_getenv ("EDITOR")))) /* Make gedit the default external editor, * if the default schemas are not installed * and no $EDITOR is set. */ editor_cmd = g_strdup ("gedit"); } g_object_unref (settings); if (g_strrstr (editor_cmd, "vim") != NULL && gtk_html_get_cursor_pos ( gtkhtml_editor_get_html ( GTKHTML_EDITOR (composer)), &position, &offset) && position >= 0 && offset >= 0) { gchar *tmp = editor_cmd; gint lineno; gboolean set_nofork; set_nofork = g_strrstr (editor_cmd, "gvim") != NULL; /* Increment 1 so that entering vim insert mode places you * in the same entry position you were at in the html. */ offset++; /* calculate the line number that the cursor is in */ lineno = numlines (content, position); editor_cmd = g_strdup_printf ( "%s \"+call cursor(%d,%d)\"%s%s", tmp, lineno, offset, set_nofork ? " " : "", set_nofork ? "--nofork" : ""); g_free (tmp); } g_free (content); editor_cmd_line = g_strconcat (editor_cmd, " ", filename, NULL); if (!g_spawn_command_line_sync (editor_cmd_line, NULL, NULL, &status, NULL)) { struct run_error_dialog_data *data; g_warning ("Unable to launch %s: ", editor_cmd_line); data = g_new0 (struct run_error_dialog_data, 1); data->composer = composer; data->text = "org.gnome.evolution.plugins.external-editor:editor-not-launchable"; /* run_error_dialog also calls enable_composer */ g_idle_add ((GSourceFunc) run_error_dialog, data); g_free (filename); g_free (editor_cmd_line); g_free (editor_cmd); goto finished; } g_free (editor_cmd_line); g_free (editor_cmd); #ifdef HAVE_SYS_WAIT_H if (WEXITSTATUS (status) != 0) { #else if (status) { #endif d (printf ("\n\nsome problem here with external editor\n\n")); g_idle_add ((GSourceFunc) enable_composer, composer); goto finished; } else { gchar *buf; if (g_file_get_contents (filename, &buf, NULL, NULL)) { gchar *htmltext; GArray *array; htmltext = camel_text_to_html ( buf, CAMEL_MIME_FILTER_TOHTML_PRE, 0); array = g_array_sized_new ( TRUE, TRUE, sizeof (gpointer), 2 * sizeof (gpointer)); array = g_array_append_val (array, composer); array = g_array_append_val (array, htmltext); g_idle_add ((GSourceFunc) update_composer_text, array); /* We no longer need that temporary file */ if (g_remove (filename) == -1) g_warning ( "%s: Failed to remove file '%s': %s", G_STRFUNC, filename, g_strerror (errno)); g_free (filename); } } finished: g_mutex_lock (&external_editor_running_lock); external_editor_running = FALSE; g_mutex_unlock (&external_editor_running_lock); return NULL; } static void launch_editor (GtkAction *action, EMsgComposer *composer) { d (printf ("\n\nexternal_editor plugin is launched \n\n")); if (editor_running ()) { d (printf ("not opening editor, because it's still running\n")); return; } disable_composer (composer); g_mutex_lock (&external_editor_running_lock); external_editor_running = TRUE; g_mutex_unlock (&external_editor_running_lock); editor_thread = g_thread_new ( NULL, external_editor_thread, composer); g_thread_unref (editor_thread); }
static int compute_pedal(struct state *st, XPoint *points, int maxpoints) /* * Description: * * Basically, it's combination spirograph and string art. * Instead of doing lines, we just use a complex polygon, * and use an even/odd rule for filling in between. * * The spirograph, in mathematical terms is a polar * plot of the form r = sin (theta * c); * The string art of this is that we evaluate that * function only on certain multiples of theta. That is * we let theta advance in some random increment. And then * we draw a straight line between those two adjacent points. * * Eventually, the lines will start repeating themselves * if we've evaluated theta on some rational portion of the * whole. * * The number of lines generated is limited to the * ratio of the increment we put on theta to the whole. * If we say that there are 360 degrees in a circle, then we * will never have more than 360 lines. * * Return: * * The number of points. * */ { int a, b, d; /* These describe a unique pedal */ double r; int theta = 0; XPoint *pp = st->points; int count; int numpoints; /* Just to make sure that this division is not done inside the loop */ int h_width = st->sizex / 2, h_height = st->sizey / 2 ; for (;;) { d = rand_range (MINLINES, st->maxlines); a = rand_range (1, d); b = rand_range (1, d); numpoints = numlines(a, b, d); if (numpoints > MINLINES) break; } /* it might be nice to try to move as much sin and cos computing * (or at least the argument computing) out of the loop. */ for (count = numpoints; count-- ; ) { r = mysin (theta * a, d); /* Convert from polar to cartesian coordinates */ /* We could round the results, but coercing seems just fine */ pp->x = mysin (theta, d) * r * h_width + h_width; pp->y = mycos (theta, d) * r * h_height + h_height; /* Advance index into array */ pp++; /* Advance theta */ theta += b; theta %= d; } return(numpoints); }
int main(int argc, char **argv) { char sss[MAXSTR] ; int **snppos ; int *snpindx ; char **snpnamelist, **indnamelist ; int lsnplist, lindlist ; int i, j, k, k1, k2, k3, k4, kk ; SNP *cupt, *cupt1, *cupt2, *cupt3 ; Indiv *indx ; double y1, y2, y, sig, tail, yy1, yy2 ; char ss[11] ; int *blstart, *blsize, nblocks ; int xnblocks ; /* for xsnplist */ int *bcols ; int **subsets ; double maxgendis ; char **eglist ; int numeg ; int ch1, ch2 ; int fmnum , lmnum ; int num, n1, n2 ; int nindiv = 0, e, f, lag=1 ; double xc[9], xd[4], xc2[9] ; int nignore, numrisks = 1 ; double *xrow, *xpt ; SNP **xsnplist ; int *tagnums ; Indiv **xindlist ; int *xindex, *xtypes ; int nedge, m, nc ; double zn, zvar ; int weightmode = NO ; double chisq, ynrows ; int *numhits, t ; double *xmean, *xfancy ; double *divans, *divsd ; double *hettop, *hetbot ; int chrom, numclear ; double gdis ; int outliter, *badlist, nbad ; int ***counts ; char ***plists ; int nplist, trun ; int nrows, ncols ; readcommands(argc, argv) ; printf("## qpBound version: %s\n", WVERSION) ; if (parname == NULL) return 0 ; if (xchrom == 23) noxdata = NO ; if (outpop == NULL) fatalx("no outpop\n") ; setinbreed(inbreed) ; numsnps = getsnps(snpname, &snpmarkers, 0.0, badsnpname, &nignore, numrisks) ; numindivs = getindivs(indivname, &indivmarkers) ; setindm(indivmarkers) ; k = getgenos(genotypename, snpmarkers, indivmarkers, numsnps, numindivs, nignore) ; for (i=0; i<numsnps; i++) { cupt = snpmarkers[i] ; chrom = cupt -> chrom ; if ((xchrom>0) && (chrom != xchrom)) cupt -> ignore = YES ; if ((noxdata) && (chrom == 23)) cupt-> ignore = YES ; if (chrom == 0) cupt -> ignore = YES ; if (chrom > 23) cupt -> ignore = YES ; if (chrom == zchrom) cupt -> ignore = YES ; } nplist = numlines(popfilename) ; ZALLOC(plists, nplist, char **) ; ZALLOC(lines, nplist, char *) ; num = readpopx(popfilename, plists, 3) ; nplist = num ; printf("nplist: %d\n", nplist) ; if (nplist == 0) return 0; ZALLOC(eglist, nplist*3, char *) ; numeg = 0 ; for (trun=0; trun<nplist; ++trun) { for (k=0; k<3; ++k) { t = indxindex(eglist, numeg, plists[trun][k]) ; if (t<0) { eglist[numeg] = strdup(plists[trun][k]) ; ++numeg ; } } } if (popsizelimit > 0) { setplimit(indivmarkers, numindivs, eglist, numeg, popsizelimit) ; } if (outputname != NULL) openit (outputname, &ofile, "w") ; outnum = 0 ; ZALLOC(xindex, numindivs, int) ; ZALLOC(xindlist, numindivs, Indiv *) ; nrows = loadindx(xindlist, xindex, indivmarkers, numindivs) ; ZALLOC(xtypes, nrows, int) ; for (i=0; i<nrows; i++) { indx = xindlist[i] ; k = indxindex(eglist, numeg, indx -> egroup) ; xtypes[i] = k+1 ; // dangerous bend t = strcmp(indx -> egroup, outpop) ; if (t==0) xtypes[i] = outnum ; else fatalx("outpop bug\n") ; } ZALLOC(xsnplist, numsnps, SNP *) ; ncols = loadsnpx(xsnplist, snpmarkers, numsnps, indivmarkers) ; /** ZALLOC(counts, ncols, int **) ; for (k=0; k<ncols; ++k) { counts[k] = initarray_2Dint( numeg, 2, 0) ; } countpops(counts, xsnplist, xindex, xtypes, nrows, ncols) ; */ for (trun=0; trun<nplist; ++trun) { dopop3out(plists[trun], xsnplist, ncols, lines[trun], outpop) ; } if (outputname != NULL) fclose(ofile) ; printf("##end of qpBound\n") ; return 0 ; }
static int compute_petal(XPoint * points, int lines, int sizex, int sizey) /*- * Description: * * Basically, it's combination spirograph and string art. * Instead of doing lines, we just use a complex polygon, * and use an even/odd rule for filling in between. * * The spirograph, in mathematical terms is a polar * plot of the form r = sin (theta * c); * The string art of this is that we evaluate that * function only on certain multiples of theta. That is * we let theta advance in some random increment. And then * we draw a straight line between those two adjacent points. * * Eventually, the lines will start repeating themselves * if we've evaluated theta on some rational portion of the * whole. * * The number of lines generated is limited to the * ratio of the increment we put on theta to the whole. * If we say that there are 360 degrees in a circle, then we * will never have more than 360 lines. * * Return: * * The number of points. * */ { int a, b, d; /* These describe a unique petal */ double r; int theta = 0; XPoint *p = points; int count; int npoints; for (;;) { d = lines; a = rand_range(1, d); b = rand_range(1, d); npoints = numlines(a, b, d); if (npoints >= MINLINES) break; } /* it might be nice to try to move as much sin and cos computing * (or at least the argument computing) out of the loop. */ for (count = npoints; count--;) { r = sine(theta * a, d); /* Convert from polar to cartesian coordinates */ /* We could round the results, but coercing seems just fine */ p->x = (int) (sine(theta, d) * r * sizex + sizex); p->y = (int) (cosine(theta, d) * r * sizey + sizey); /* Advance index into array */ p++; /* Advance theta */ theta += b; theta %= d; } *p = points[0]; /* Tack on another for XDrawLines */ return (npoints); }
int main(int argc, char **argv) { char sss[MAXSTR] ; int **snppos ; int *snpindx ; char **snpnamelist, **indnamelist ; char **eglist ; int *nsamppops ; int *ztypes ; int lsnplist, lindlist, numeg ; int i, j, k, k1, k2, k3, k4, kk; SNP *cupt, *cupt1, *cupt2, *cupt3 ; Indiv *indx ; double y1, y2, y, sig, tail, yy1, yy2 ; char ss[11] ; int *blstart, *blsize, nblocks ; int xnblocks ; /* for xsnplist */ int *bcols ; double maxgendis ; int xind[4] ; int ch1, ch2 ; int fmnum , lmnum ; int num, n1, n2 ; int nindiv = 0, e, f, lag=1 ; double xc[9], xd[4], xc2[9] ; int nignore, numrisks = 1 ; double *xrow, *xpt ; SNP **xsnplist ; int *tagnums ; Indiv **xindlist ; int *xindex, *xtypes ; int nrows, ncols, m, nc ; double zn, zvar ; int weightmode = NO ; double chisq, ynrows ; int *numhits, t ; double *xmean, *xfancy ; double *divans, *divsd ; double *hettop, *hetbot ; int chrom, numclear ; double gdis ; int outliter, *badlist, nbad ; double **zdata, *z1, *z2 ; int maxtag = -1 ; double **zz ; double *pmean, *pnum, rscore[3], dstat[3], hscore[3], rrr[3], ww[3], serr[3] ; int ssize[3][3], *sz ; int tpat[3][4] , rpat[3][4], *rrtmp, *rp ; int *rawcol ; ; int a, b, c, d, col ; int aa, bb, cc, dd ; double *qpscores ; double *hest, *hsig ; double mingenpos, maxgenpos ; int *qhit ; /* number of times pair is clade in quartet */ int *qmiss ; /* number of times pair migration event implied */ int **qplist, numqp = 0, maxqp=10000 ; double *qpscore ; char ***qlist, *sx ; int nqlist = 0 ; int bbest[3] ; double absscore[3] ; double ascore[4], astat[4] ; double **dsctop, **dscbot ; double **abx, **bax, **f2 ; int popx[4] ; double tn[4*5], td[4*4] ; double zzsig[5], zzest[5], zsc[5] ; double ymin ; double *f3, *f4, *f3sig, *f4sig ; int t1, t2, tt ; int ***counts, **ccc ; double tlenz[5], tlen[5] ; int lenz[5] ; readcommands(argc, argv) ; printf("## qpDstat version: %s\n", WVERSION) ; if (parname == NULL) return 0 ; if ((poplistname == NULL) && (popfilename == NULL)) fatalx("poplistname, popfilename both null\n") ; if (!bankermode) forceclade = NO ; //if (fancynorm) printf("fancynorm used\n") ; //else printf("no fancynorm used\n") ; setjquart(NO, jackweight, jackquart) ; nostatslim = MAX(nostatslim, 3) ; setinbreed(inbreed) ; if (outputname != NULL) openit(outputname, &ofile, "w") ; numsnps = getsnps(snpname, &snpmarkers, 0.0, badsnpname, &nignore, numrisks) ; numindivs = getindivs(indivname, &indivmarkers) ; if (id2pops != NULL) { setid2pops(id2pops, indivmarkers, numindivs) ; } setindm(indivmarkers) ; k = getgenos(genotypename, snpmarkers, indivmarkers, numsnps, numindivs, nignore) ; for (i=0; i<numsnps; i++) { cupt = snpmarkers[i] ; if (cupt -> chrom >= 23) cupt -> ignore = YES ; if (cupt -> chrom == zchrom) cupt -> ignore = YES ; } ZALLOC(eglist, numindivs, char *) ; ZALLOC(ztypes, numindivs, int) ; if (popfilename == NULL) { if (bankermode == NO) numeg = loadlist(eglist, poplistname) ; else { numeg = loadlist_type(eglist, poplistname, ztypes, 0) ; numbanker = 0 ; for (k=0; k<numeg; ++k) { if (ztypes[k] == 2) ++numbanker ; } printf("bankermode: ") ; printimat(ztypes, 1, numeg) ; } } if (popfilename != NULL) { bbestmode = NO ; nqlist = numlines(popfilename) ; ZALLOC(qlist, 4, char **) ; for (k=0; k<4; ++k) { ZALLOC(qlist[k], nqlist, char *) ; } nqlist = getnamesstripcolon(&qlist, nqlist, 4, popfilename, locount, hicount) ; numeg = 0 ; printf("number of quadruples %d\n", nqlist) ; fflush(stdout) ; for (k=0; k<4; ++k) { for (j=0; j<nqlist; ++j) { sx = qlist[k][j] ; t1 = indxstring(eglist, numeg, sx) ; if (t1 >=0) continue ; eglist[numeg] = strdup(sx) ; ++numeg ; setstatus(indivmarkers, numindivs, sx) ; } } }
int main(int argc, char *argv[]) { unsigned int repeat=0; char **tags; int i; int a; int b; float gdivide_a; float gdivide_b; char are_you_sure[100]; #ifdef NAJI_DEBUG fprintf(stderr, "\n\n"); fprintf(stderr, "NAJI_DEBUG - check if two commands are displayed as one joined string,\n"); fprintf(stderr, " you might have missed a , in najitool_valid_commands[]\n\n"); for (i=0; i<NAJITOOL_MAX_COMMANDS; i++) fprintf(stderr, "%s ", najitool_valid_commands[i]); fgetc(stdin); #endif /* NAJI_DEBUG */ #ifdef NAJI_DEBUG fprintf(stderr, "\n\nNAJI_DEBUG - YOUR PARAMETERS/ARGUMENTS:\n\n"); for (i=0; i<argc; i++) fprintf(stderr, "%s ", argv[i]); fprintf(stderr, "\n\n"); fgetc(stdin); #endif /* NAJI_DEBUG */ if (argc >= 2) { tolowers(argv[1]); najitool_check_command(argv[1]); } if (argc == 1) { printf("\n\n"); /* printf(" __ | \n"); printf(" / \\ | \n"); printf(" / _____| | o \\ \n"); printf(" | \\ o |___| \n"); printf(" \\____\\ \n"); printf(" o o T O O L \n"); */ printf(" __ | ********************************************\n"); printf(" / \\ | najitool 0.8.4 using libnaji 0.6.4 \n"); printf(" / _____| | o \\ both written by NECDET COKYAZICI \n"); printf(" | \\ o |___| and contributors \n"); printf(" \\____\\ ********************************************\n"); printf(" o o T O O L No warranty, to view the license type: \n"); printf(" najitool license \n"); printf(" http://najitool.sf.net/ ********************************************\n"); printf(" To view the credits type: najitool credits \n"); printf(" Public Domain, 2003-2011 ********************************************\n"); printf("\n"); forhelp(); return 0; } if (argc >= 2) { if (!strcmp(argv[1], "mp3taged")) { if ((argc % 2 != 1) | (argc == 3)) { printf("mp3taged: too few arguments '%s'\n", argv[1]); return 1; } /* * we save the tags' options: * tags[i] = <tag name> * tags[i+1] = <user content> * .. */ tags = (char**) malloc (sizeof(char*)*(argc-3)*2); for (i=0; i<(argc-3)*2; i+=2) tags[i] = (char*) malloc(7*sizeof(char)); for (i=1; i<(argc-3)*2; i+=2) tags[i] = argv[i+2]; for (i=0; i<(argc-3)*2; i+=2) memcpy (tags[i], argv[i+2], 7); mp3editag (argv[argc-1], tags, argc-3); for (i=0; i<(argc-3)*2; i+=2) free(tags[i]); free(tags); return 0; } if (!strcmp(argv[1], "credits")) { if (argc > 2) tooparam("credits"); naji_credits(); return 0; } if (!strcmp(argv[1], "asctable")) { if (argc > 2) tooparam("asctable"); asctable(); return 0; } if (!strcmp(argv[1], "engnum")) { if (argc > 2) tooparam("engnum"); engnum(); return 0; } if (!strcmp(argv[1], "turnum")) { if (argc > 2) tooparam("turnum"); turnum(); return 0; } if (!strcmp(argv[1], "najcrypt")) { if (argc > 2) tooparam("najcrypt"); najcrypt(); return 0; } if (!strcmp(argv[1], "database")) { if (argc > 2) tooparam("database"); naji_database(); return 0; } if (!strcmp(argv[1], "html_db")) { if (argc > 2) tooparam("html_db"); naji_html_database(); return 0; } if (!strcmp(argv[1], "calc")) { if (argc > 2) tooparam("calc"); naji_calc(); return 0; } if (!strcmp(argv[1], "length")) { if (argc > 2) tooparam("length"); length(); return 0; } if (!strcmp(argv[1], "mathgame")) { if (argc > 2) tooparam("mathgame"); mathgame(); return 0; } if (!strcmp(argv[1], "license")) { if (argc > 2) tooparam("license"); naji_license(); return 0; } if (!strcmp(argv[1], "ttt")) { if (argc > 2) tooparam("ttt"); ttt(); return 0; } if (!strcmp(argv[1], "naji_bmp")) { if (argc > 2) tooparam("naji_bmp"); naji_bmp(); return 0; } if (!strcmp(argv[1], "unihtml")) { if (argc > 2) tooparam("unihtml"); naji_gen_unicode_html_pages(); return 0; } if (!strcmp(argv[1], "rmunihtm")) { if (argc > 2) tooparam("rmunihtm"); naji_del_gen_unicode_html_pages(); return 0; } if (!strcmp(argv[1], "cat_text")) { if (argc == 2) { naji_stdin_msg(); cat_text_stdin(); return 0; } if (argc == 3) { cat_text(argv[2]); return 0; } if (argc > 3) tooparam("cat_text"); return 0; } if (!strcmp(argv[1], "kitten")) { if (argc == 2) { naji_stdin_msg(); kitten_stdin(); return 0; } if (argc == 3) { kitten(argv[2]); return 0; } if (argc > 3) tooparam("kitten"); return 0; } if (!strcmp(argv[1], "genlic")) { if (argc > 2) tooparam("genlic"); naji_genlic(); return 0; } if (!strcmp(argv[1], "genhelp")) { if (argc > 2) tooparam("genhelp"); najitool_generate_help(); return 0; } if (!strcmp(argv[1], "htmlhelp")) { if (argc > 2) tooparam("htmlhelp"); najitool_generate_help_html(); return 0; } if (!strcmp(argv[1], "systemdt")) { if (argc > 2) tooparam("systemdt"); systemdt(); return 0; } if (!strcmp(argv[1], "datetime")) { if (argc > 2) tooparam("datetime"); datetime(); return 0; } if (!strcmp(argv[1], "telltime")) { if (argc > 2) tooparam("telltime"); printf("\n\n"); telltime(); printf("\n\n"); return 0; } if (!strcmp(argv[1], "today")) { if (argc > 2) tooparam("today"); printf("\n\n"); today(); printf("\n\n"); return 0; } if (!strcmp(argv[1], "dayofmon")) { if (argc > 2) tooparam("dayofmon"); printf("\n\n"); dayofmon(); printf("\n\n"); return 0; } if (!strcmp(argv[1], "month")) { if (argc > 2) tooparam("month"); printf("\n\n"); month(); printf("\n\n"); return 0; } if (!strcmp(argv[1], "year")) { if (argc > 2) tooparam("year"); printf("\n\n"); year(); printf("\n\n"); return 0; } if (!strcmp(argv[1], "saatarih")) { if (argc > 2) tooparam("saatarih"); saatarih(); return 0; } if (!strcmp(argv[1], "saat")) { if (argc > 2) tooparam("saat"); printf("\n\n"); saat(); printf("\n\n"); return 0; } if (!strcmp(argv[1], "bugun")) { if (argc > 2) tooparam("bugun"); printf("\n\n"); bugun(); printf("\n\n"); return 0; } if (!strcmp(argv[1], "ayinkaci")) { if (argc > 2) tooparam("ayinkaci"); printf("\n\n"); ayinkaci(); printf("\n\n"); return 0; } if (!strcmp(argv[1], "ay")) { if (argc > 2) tooparam("ay"); printf("\n\n"); ay(); printf("\n\n"); return 0; } if (!strcmp(argv[1], "yil")) { if (argc > 2) tooparam("yil"); printf("\n\n"); yil(); printf("\n\n"); return 0; } if (!strcmp(argv[1], "allbmp16")) { if (argc > 2) tooparam("allbmp16"); printf("\n\n"); allbmp16(); printf("\n\n"); return 0; } if (!strcmp(argv[1], "help")) { if (argc == 2) { printf("\n\nAvailable help catagories:\n\n"); printf("commands\n"); printf("\n\n"); forhelp(); return 0; } if (argc == 3) { if (!strcmp(argv[2], "commands")) najitool_help_commands(); else najitool_command_help(argv[2]); return 0; } if (argc > 3) tooparam("help"); return 0; } begin_cmd("mergline", 7) mergline(argv[2], argv[3], argv[4], argv[5], argv[6]); end_cmd() begin_cmd("mp3split", 6) mp3split(argv[4], argv[5], atoi(argv[2]), atoi(argv[3])); end_cmd() begin_cmd("rrrchars", 6) rrrchars(argv[2], argv[3], atoi(argv[4]), atoi(argv[5])); end_cmd() begin_cmd("chstr", 6) chstr(argv[2], argv[3], argv[4], argv[5]); end_cmd() begin_cmd("chchars", 6) chchars(argv[2], argv[3], argv[4], argv[5]); end_cmd() begin_cmd("chchar", 6) chchar(argv[2], argv[3], argv[4][0], argv[5][0]); end_cmd() begin_cmd("filechop", 6) filechop( (strtol(argv[2], NULL, 0)), argv[3], argv[4], argv[5]); end_cmd() begin_cmd("putlines", 6) putlines(argv[2], argv[3], argv[4], argv[5]); end_cmd() begin_cmd("copyoffs", 6) copyoffs(argv[2], strtoul(argv[3], NULL, 0), strtoul(argv[4], NULL, 0), argv[5]); end_cmd() begin_cmd("istrael", 6) istrael(argv[2], atoi(argv[3]), argv[4], argv[5]); end_cmd() begin_cmd("addline", 6) addline(argv[2], argv[3], argv[4], strtoul(argv[5], NULL, 0)); end_cmd() begin_cmd("replacel", 6) replacel(argv[2], argv[3], argv[4], strtoul(argv[5], NULL, 0)); end_cmd() begin_cmd("bremline", 5) bremline(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("eremline", 5) eremline(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("remline", 5) remline(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("skipstr", 5) skipstr(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("makarray", 5) makarray(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("streline", 5) streline(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("strbline", 5) strbline(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("swapfeb", 5) swapfeb(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("filbreed", 5) filbreed(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("skipchar", 5) skipchar(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("onlychar", 5) onlychar(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("repchar", 5) repeat = (unsigned int) atoi(argv[4]); repchar(argv[2], argv[3], repeat); end_cmd() begin_cmd("linesnip", 5) repeat = (unsigned int) atoi(argv[2]); linesnip(repeat, argv[3], argv[4]); end_cmd() begin_cmd("charwarp", 5) repeat = (unsigned int) atoi(argv[4]); charwrap(repeat, argv[2], argv[3]); end_cmd() begin_cmd("repcharp", 5) repeat = (unsigned int) atoi(argv[4]); repcharp(argv[2], argv[3], repeat); end_cmd() begin_cmd("coffset", 5) coffset(argv[2], strtoul(argv[3], NULL, 0), strtoul(argv[4], NULL, 0)); end_cmd() begin_cmd("dumpoffs", 5) dumpoffs(argv[2], strtoul(argv[3], NULL, 0), strtoul(argv[4], NULL, 0)); end_cmd() begin_cmd("bin2c", 5) bin2c(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("filejoin", 5) filejoin(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("mkpatch", 5) mkpatch(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("charfile", 5) repeat = (unsigned int) atoi(argv[3]); charfile(argv[2], repeat, argv[4][0]); end_cmd() begin_cmd("strfile", 5) repeat = (unsigned int) atoi(argv[3]); strfile(argv[2], repeat, argv[4]); end_cmd() begin_cmd("tabspace", 5) repeat = atoi(argv[2]); tabspace(repeat, argv[3], argv[4]); end_cmd() begin_cmd("charaftr", 5) charaftr(argv[2], argv[3], argv[4][0]); end_cmd() begin_cmd("charbefr", 5) charbefr(argv[2], argv[3], argv[4][0]); end_cmd() begin_cmd("strachar", 5) strachar(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("strbchar", 5) strbchar(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("rstrach", 5) rstrach(atoi(argv[2]), argv[3], argv[4]); end_cmd() begin_cmd("rstrbch", 5) rstrbch(atoi(argv[2]), argv[3], argv[4]); end_cmd() begin_cmd("cpfroml", 5) cpfroml(atoi(argv[2]), argv[3], argv[4]); end_cmd() begin_cmd("cptiline", 5) cptiline(atoi(argv[2]), argv[3], argv[4]); end_cmd() begin_cmd("n2ch", 5) n2ch(argv[2][0], argv[3], argv[4]); end_cmd() begin_cmd("n2str", 5) n2str(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("weakrypt", 5) weakrypt(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("sp2ce2sp", 5) sp2ce2sp(argv[2][0], argv[3], argv[4]); end_cmd() begin_cmd("istreml", 5) istreml(argv[2], argv[3], argv[4]); end_cmd() begin_cmd("removel", 5) removel(argv[2], argv[3], strtoul(argv[4], NULL, 0)); end_cmd() begin_cmd("printftx", 4) printftx(argv[2], argv[3]); end_cmd() begin_cmd("lensorts", 4) lensorts(argv[2], argv[3]); end_cmd() begin_cmd("lensortl", 4) lensortl(argv[2], argv[3]); end_cmd() begin_cmd("find", 4) find(argv[2], argv[3]); end_cmd() begin_cmd("findi", 4) findi(argv[2], argv[3]); end_cmd() begin_cmd("cfind", 4) cfind(argv[2], argv[3]); end_cmd() begin_cmd("cfindi", 4) cfindi(argv[2], argv[3]); end_cmd() begin_cmd("showline", 4) showline(argv[2], atoi(argv[3])); end_cmd() begin_cmd("cat_tail", 4) cat_tail(argv[2], atoi(argv[3])); end_cmd() begin_cmd("cat_head", 4) cat_head(argv[2], atoi(argv[3])); end_cmd() begin_cmd("getlinks", 4) getlinks(argv[2], argv[3]); end_cmd() begin_cmd("f2upper", 4) f2upper(argv[2], argv[3]); end_cmd() begin_cmd("f2lower", 4) f2lower(argv[2], argv[3]); end_cmd() begin_cmd("fswpcase", 4) fswpcase(argv[2], argv[3]); end_cmd() begin_cmd("downlist", 4) downlist(argv[2], argv[3]); end_cmd() begin_cmd("hilist", 4) hilist(argv[2], argv[3]); end_cmd() begin_cmd("rtcafter", 4) rtcafter(argv[2], argv[3]); end_cmd() begin_cmd("rtcbefor", 4) rtcbefor(argv[2], argv[3]); end_cmd() begin_cmd("rbcafter", 4) rbcafter(argv[2], argv[3]); end_cmd() begin_cmd("rbcbefor", 4) rbcbefor(argv[2], argv[3]); end_cmd() begin_cmd("numlines", 4) numlines(argv[2], argv[3]); end_cmd() begin_cmd("file2dec", 4) file2dec(argv[2], argv[3]); end_cmd() begin_cmd("file2hex", 4) file2hex(argv[2], argv[3]); end_cmd() begin_cmd("file2bin", 4) file2bin(argv[2], argv[3]); end_cmd() begin_cmd("wordline", 4) wordline(argv[2], argv[3]); end_cmd() begin_cmd("8bit256", 4) repeat = (unsigned int) atoi(argv[3]); _8bit256(argv[2], repeat); end_cmd() begin_cmd("eng2arab", 4) eng2arab(argv[2], argv[3]); end_cmd() begin_cmd("arab2eng", 4) arab2eng(argv[2], argv[3]); end_cmd() begin_cmd("e2ahtml", 4) e2ahtml(argv[2], argv[3]); end_cmd() begin_cmd("freverse", 4) freverse(argv[2], argv[3]); end_cmd() begin_cmd("repcat", 4) repeat = (unsigned int) atoi(argv[3]); repcat(argv[2], repeat); end_cmd() begin_cmd("repcatpp", 4) repeat = (unsigned int) atoi(argv[3]); repcatpp(argv[2], repeat); end_cmd() begin_cmd("copyfile", 4) copyfile(argv[2], argv[3]); end_cmd() begin_cmd("qpatch", 4) qpatch(argv[2], argv[3]); end_cmd() begin_cmd("flipcopy", 4) flipcopy(argv[2], argv[3]); end_cmd() begin_cmd("fillfile", 4) fillfile(argv[2], argv[3][0]); end_cmd() begin_cmd("bin2text", 4) bin2text(argv[2], argv[3]); end_cmd() begin_cmd("bin2hexi", 4) bin2hexi(argv[2], argv[3]); end_cmd() begin_cmd("rndbfile", 4) rndbfile(argv[2], strtoul(argv[3], NULL, 0)); end_cmd() begin_cmd("rndtfile", 4) rndtfile(argv[2], strtoul(argv[3], NULL, 0)); end_cmd() begin_cmd("skipcat", 4) skipcat(argv[2], argv[3]); end_cmd() begin_cmd("onlycat", 4) onlycat(argv[2], argv[3]); end_cmd() begin_cmd("bigascif", 4) bigascif(argv[2], argv[3]); end_cmd() begin_cmd("leetfile", 4) leetfile(argv[2], argv[3]); end_cmd() begin_cmd("asc2ebc", 4) asc2ebc(argv[2], argv[3]); end_cmd() begin_cmd("ebc2asc", 4) ebc2asc(argv[2], argv[3]); end_cmd() begin_cmd("unix2dos", 4) unix2dos(argv[2], argv[3]); end_cmd() begin_cmd("dos2unix", 4) dos2unix(argv[2], argv[3]); end_cmd() begin_cmd("uuencode", 4) uuencode(argv[2], argv[3]); end_cmd() begin_cmd("uudecode", 4) uudecode(argv[2], argv[3]); end_cmd() begin_cmd("wordwrap", 4) wordwrap(argv[2], argv[3]); end_cmd() begin_cmd("compare", 4) compare(argv[2], argv[3]); end_cmd() begin_cmd("ccompare", 4) ccompare(argv[2], argv[3]); end_cmd() begin_cmd("hmakerf", 4) hmakerf(argv[2], argv[3]); end_cmd() begin_cmd("qcrypt", 4) qcrypt(argv[2], argv[3]); end_cmd() begin_cmd("revlines", 4) revlines(argv[2], argv[3]); end_cmd() begin_cmd("html2txt", 4) html2txt(argv[2], argv[3]); end_cmd() begin_cmd("txt2html", 4) txt2html(argv[2], argv[3]); end_cmd() begin_cmd("htmlfast", 4) htmlfast(argv[2], argv[3]); end_cmd() begin_cmd("onlalnum", 4) onlalnum(argv[2], argv[3]); end_cmd() begin_cmd("onlalpha", 4) onlalpha(argv[2], argv[3]); end_cmd() begin_cmd("onlcntrl", 4) onlcntrl(argv[2], argv[3]); end_cmd() begin_cmd("onldigit", 4) onldigit(argv[2], argv[3]); end_cmd() begin_cmd("onlgraph", 4) onlgraph(argv[2], argv[3]); end_cmd() begin_cmd("onllower", 4) onllower(argv[2], argv[3]); end_cmd() begin_cmd("onlprint", 4) onlprint(argv[2], argv[3]); end_cmd() begin_cmd("onlpunct", 4) onlpunct(argv[2], argv[3]); end_cmd() begin_cmd("onlspace", 4) onlspace(argv[2], argv[3]); end_cmd() begin_cmd("onlupper", 4) onlupper(argv[2], argv[3]); end_cmd() begin_cmd("onlxdigt", 4) onlxdigt(argv[2], argv[3]); end_cmd() begin_cmd("skpalnum", 4) skpalnum(argv[2], argv[3]); end_cmd() begin_cmd("skpalpha", 4) skpalpha(argv[2], argv[3]); end_cmd() begin_cmd("skpcntrl", 4) skpcntrl(argv[2], argv[3]); end_cmd() begin_cmd("skpdigit", 4) skpdigit(argv[2], argv[3]); end_cmd() begin_cmd("skpgraph", 4) skpgraph(argv[2], argv[3]); end_cmd() begin_cmd("skplower", 4) skplower(argv[2], argv[3]); end_cmd() begin_cmd("skpprint", 4) skpprint(argv[2], argv[3]); end_cmd() begin_cmd("skppunct", 4) skppunct(argv[2], argv[3]); end_cmd() begin_cmd("skpspace", 4) skpspace(argv[2], argv[3]); end_cmd() begin_cmd("skpupper", 4) skpupper(argv[2], argv[3]); end_cmd() begin_cmd("skpxdigt", 4) skpxdigt(argv[2], argv[3]); end_cmd() begin_cmd("ftothe", 4) ftothe(argv[2], argv[3]); end_cmd() begin_cmd("blanka", 4) blanka(argv[2], argv[3]); end_cmd() begin_cmd("unblanka", 4) unblanka(argv[2], argv[3]); end_cmd() begin_cmd("najirle", 4) najirle(argv[2], argv[3]); end_cmd() begin_cmd("unajirle", 4) unajirle(argv[2], argv[3]); end_cmd() begin_cmd("gplus", 4) a = atoi(argv[2]); b = atoi(argv[3]); gplus(a, b); end_cmd() begin_cmd("gminus", 4) a = atoi(argv[2]); b = atoi(argv[3]); gminus(a, b); end_cmd() begin_cmd("gtimes", 4) a = atoi(argv[2]); b = atoi(argv[3]); gtimes(a, b); end_cmd() begin_cmd("gdivide", 4) gdivide_a = atof(argv[2]); gdivide_b = atof(argv[3]); gdivide(gdivide_a, gdivide_b); end_cmd() begin_cmd("bytsplit", 4) bytsplit(argv[2], atol(argv[3])); end_cmd() begin_cmd("kbsplit", 4) kbsplit(argv[2], atol(argv[3])); end_cmd() begin_cmd("mbsplit", 4) mbsplit(argv[2], atol(argv[3])); end_cmd() begin_cmd("gbsplit", 4) gbsplit(argv[2], atol(argv[3])); end_cmd() begin_cmd("mjoin", 4) mjoin(argv[2], argv[3]); end_cmd() begin_cmd("listdigt", 4) listdigt(atoi(argv[2]), argv[3]); end_cmd() begin_cmd("listlowr", 4) listlowr(atoi(argv[2]), argv[3]); end_cmd() begin_cmd("listprnt", 4) listprnt(atoi(argv[2]), argv[3]); end_cmd() begin_cmd("listuppr", 4) listuppr(atoi(argv[2]), argv[3]); end_cmd() begin_cmd("charsort", 4) charsort(argv[2], argv[3]); end_cmd() begin_cmd("sp2re2sp", 4) sp2re2sp(argv[2], argv[3]); end_cmd() begin_cmd("lcvfiles", 3) lcvfiles(argv[2]); end_cmd() begin_cmd("rcvfiles", 3) rcvfiles(argv[2]); end_cmd() begin_cmd("mp3tagnf", 3) mp3info(argv[2]); end_cmd() begin_cmd("catrandl", 3) catrandl(argv[2]); end_cmd() begin_cmd("leetstr", 3) printf("\n\n"); leetstr(argv[2]); printf("\n\n"); end_cmd() begin_cmd("lcharvar", 3) lcharvar(argv[2]); end_cmd() begin_cmd("rcharvar", 3) rcharvar(argv[2]); end_cmd() begin_cmd("hexicat", 3) hexicat(argv[2]); end_cmd() begin_cmd("rndffill", 3) rndffill(argv[2]); end_cmd() begin_cmd("zerokill", 3) zerokill(argv[2]); end_cmd() begin_cmd("randkill", 3) randkill(argv[2]); end_cmd() begin_cmd("najisum", 3) najisum(argv[2]); end_cmd() begin_cmd("rndbsout", 3) rndbsout(strtoul(argv[2], NULL, 0)); end_cmd() begin_cmd("rndtsout", 3) rndtsout(strtoul(argv[2], NULL, 0)); end_cmd() begin_cmd("patch", 3) patch(argv[2]); end_cmd() begin_cmd("revcat", 3) revcat(argv[2]); end_cmd() begin_cmd("copyself", 3) copyfile(argv[0], argv[2]); end_cmd() begin_cmd("bigascii", 3) bigascii(argv[2]); end_cmd() begin_cmd("hmaker", 3) hmaker(argv[2]); end_cmd() begin_cmd("wrdcount", 3) printf("\n\n%i\n\n", wrdcount(argv[2])); end_cmd() begin_cmd("addim", 3) addim(atoi(argv[2])); end_cmd() begin_cmd("allfiles", 3) fprintf(stderr, "\n" "NOTE: On most systems you can stop with Ctrl+C\n" "WARNING: This will make a lot of files.\n" "Are you sure? type YES to continue\n" "or anything else to quit.\n" ); safegets(are_you_sure, 80); if (!strcmp(are_you_sure, "YES")) allfiles(atol(argv[2])); end_cmd(); begin_cmd("tothe", 3) tothe(argv[2]); end_cmd() begin_cmd("vowelwrd", 3) vowelwrd(argv[2]); end_cmd() begin_cmd("gigabyte", 3) gigabyte(strtoul(argv[2], NULL, 0)); end_cmd() begin_cmd("sort", 3) sort(argv[2]); end_cmd() begin_cmd("sortlast", 3) sortlast(argv[2]); end_cmd() begin_cmd("lineback", 3) lineback(argv[2]); end_cmd() begin_cmd("longline", 3) longline(argv[2]); end_cmd() begin_cmd("howline", 3) howline(argv[2]); end_cmd() begin_cmd("rndlines", 3) rndlines(argv[2]); end_cmd() begin_cmd("spyramid", 3) spyramid(argv[2]); end_cmd() } /* if (argc >= 2) */ return 0; }