int input_data(void) { string input, test; int i; if (instr == NULL) { /* initialization only at first entry */ input = getparam("in"); /* get filename */ instr = stropen(input, "r"); /* open file */ test = getparam("test"); /* get name for testfile */ if (*test != 0) /* if testfile provided: */ tststr = stropen(test, "r"); /* ... open it */ } if (tststr==NULL) { /* if no testfile, data from in */ get_history(instr); i = read_snapshot(&massdata, &nmass, instr); /* read mass coord data */ if (i==0) return 0; testdata = massdata; /* use mass data for tests */ ntest = nmass; } else { /* else data from test */ if (massdata==NULL) { /* on first pass read masses */ get_history(instr); i=read_snapshot(&massdata, &nmass, instr); if (i==0) return 0; } get_history(tststr); /* read (next) testdata */ i=read_snapshot(&testdata, &ntest, tststr); if (i==0) return(0); } return 1; }
nemo_main() { stream instr, quadstr, outstr; Body *btab = NULL, *bp; int nbody, bits; real eps_r, eps_t, tsnap = 0.0; if (!hasvalue("out")) warning("No output supplied (out=)"); quadstr = stropen(getparam("quad"), "r"); get_history(quadstr); instr = stropen(getparam("in"), "r"); get_history(instr); get_quadfield(quadstr, &eps_r, &eps_t); get_snap(instr, &btab, &nbody, &tsnap, &bits); if (bits & PhaseSpaceBit == 0) error("not enuf info: bits = %o", bits); for (bp = btab; bp < btab+nbody; bp++) { CLRV(Acc(bp)); Phi(bp) = 0.0; } quadinter(btab, nbody, eps_r, eps_t); if (hasvalue("out")) { outstr = stropen(getparam("out"), "w"); put_history(outstr); bits = bits | PotentialBit | AccelerationBit; put_snap(outstr, &btab, &nbody, &tsnap, &bits); } }
int main(int argc, string argv[]) { stream istr; gsprof *tgsp, *mgsp; real beta_a, *sig2, rrange[2], lgrs, r; int np, i; initparam(argv, defv); istr = stropen(getparam("gsp"), "r"); get_history(istr); tgsp = get_gsprof(istr); strclose(istr); if (! strnull(getparam("grav"))) { istr = stropen(getparam("grav"), "r"); get_history(istr); mgsp = get_gsprof(istr); strclose(istr); } else mgsp = tgsp; beta_a = getdparam("beta_a"); sig2 = calc_sig2_gsp(tgsp, mgsp, beta_a); np = getiparam("npoint"); setrange(rrange, getparam("rrange")); lgrs = rlog2(rrange[1] / rrange[0]) / (np - 1); printf("%12s %12s\n", "radius", "sig_r^2"); for (i = 0; i < np; i++) { r = rrange[0] * rpow(2.0, lgrs * i); printf("%12.5f %12.7f\n", r, sig2_gsp(tgsp, mgsp, beta_a, sig2, r)); } return (0); }
void nemo_main() { stream instr, outstr; string times, ctypei, ctypeo; real tsnap; int i, nbody, bits, mode; Body *btab = NULL, *bp; proc transform, trans2; times = getparam("times"); ctypei = getparam("ctypei"); ctypeo = getparam("ctypeo"); if (streq(ctypei,"cart") && streq(ctypeo,"sph")) transform = cartesian_spherical; else if (streq(ctypei,"sph") && streq(ctypeo,"cart")) transform = spherical_cartesian; else if (streq(ctypei,"cart") && streq(ctypeo,"cyl")) transform = cartesian_cylindrical; else if (streq(ctypei,"cyl") && streq(ctypeo,"cart")) transform = cylindrical_cartesian; else error("Unimplemented ctype i/o : %s -> %s",ctypei,ctypeo); dprintf(0,"converting from %s to %s\n",ctypei,ctypeo); instr = stropen(getparam("in"), "r"); outstr = stropen(getparam("out"), "w"); get_history(instr); put_history(outstr); for (;;) { get_history(instr); /* skip over stuff we can forget */ if (!get_tag_ok(instr, SnapShotTag)) break; /* done with work in loop */ get_snap(instr, &btab, &nbody, &tsnap, &bits); if ((bits & MassBit) == 0 && (bits & PhaseSpaceBit) == 0) { continue; /* just skip it's probably a diagnostics */ } if ((bits & TimeBit) == 0) tsnap = 0.0; else if (!streq(times,"all") && !within(tsnap, times, TIMEFUZZ)) continue; dprintf (1,"Transforming snapshot at time= %f bits=0x%x\n",tsnap,bits); #if 0 Qmass = MassBit & bits; Qphase = PhaseSpaceBit & bits; Qacc = AccelerationBit & bits; Qaux = AuxBit & bits; Qkey = KeyBit & bits; #endif for (bp = btab; bp < btab+nbody; bp++) { (transform)(Pos(bp),Vel(bp),Acc(bp)); } put_snap(outstr, &btab, &nbody, &tsnap, &bits); } }
nemo_main() { stream instr; real tsnap, x, y, v, d; int i, nbody, bits, iy, ny, nout; Body *btab = NULL, *bp; Grid g; real yrange[MAXY], sumd[MAXY], sumvd[MAXY], sumxd[MAXY]; bool Qmass = getbparam("mass"); instr = stropen(getparam("in"), "r"); /* open input file */ ny = nemoinpr(getparam("y"),yrange,MAXY); if (ny<2) error("yrange syntax error or not enuf slices"); #if 0 inia_grid(&g, ny, yrange); #else inil_grid(&g, ny-1, yrange[0], yrange[ny-1]); #endif get_history(instr); /* accumulate data history */ for(;;) { /* loop for all times */ get_history(instr); /* for paranoidici */ if (!get_tag_ok(instr, SnapShotTag)) /* check if done */ break; get_snap(instr, &btab, &nbody, &tsnap, &bits); /* get one */ if ((bits & PhaseSpaceBit) == 0) continue; /* if no positions - skip */ for (i=0; i<ny; i++) sumd[i] = sumxd[i] = sumvd[i] = 0.0; for (bp = btab; bp < btab+nbody; bp++) { /* loop all bodies */ y = Pos(bp)[1]; iy = index_grid(&g, y); if (iy < 0) continue; d = Qmass ? Mass(bp) : Dens(bp); x = Pos(bp)[0]; v = Vel(bp)[1]; sumd[iy] += d; sumvd[iy] += v*d; sumxd[iy] += x*d; } break; /* for now just first snapshot */ } nout = 0; for (i=0; i<ny-1; i++) { if (sumd[i] > 0.0) { nout++; printf("%g %g %g %g\n",value_grid(&g, (real)i+0.5), sumxd[i]/sumd[i], sumvd[i]/sumd[i], sumd[i]); } } if (nout==0) warning("No densities found in slices %s",getparam("y")); } /* nemo_main() */
void readgsp(void) { stream istr; istr = stropen(getparam("gsp"), "r"); get_history(istr); gsp = ggsp = get_gsprof(istr); strclose(istr); if (! strnull(getparam("grav"))) { istr = stropen(getparam("grav"), "r"); get_history(istr); ggsp = get_gsprof(istr); strclose(istr); } }
/* * Helper function for 'player_birth()'. * * See "display_player" for screen layout code. */ static bool player_birth_aux(void) { /* Ask questions */ if (!player_birth_aux_1()) return (FALSE); /* Point-based stats */ if (!player_birth_aux_2()) return (FALSE); /* Point-based skills */ if (!gain_skills()) return (FALSE); /* Choose sex */ if (!get_sex()) return (FALSE); /* Roll for history */ if (!get_history()) return (FALSE); /* Roll for age/height/weight */ if (!get_ahw()) return (FALSE); /* Get a name, prepare savefile */ if (!get_name()) return (FALSE); // Reset the number of artefacts p_ptr->artefacts = 0; /* Accept */ return (TRUE); }
int main(int argc, string argv[]) { stream istr, ostr; real eps2, tnow; int nforce, nbody, i; bodyptr btab = NULL; string intags[MaxBodyFields]; initparam(argv, defv); layout_body(bodytags, Precision, NDIM); istr = stropen(getparam("in"), "r"); get_history(istr); ostr = stropen(getparam("out"), "w"); put_history(ostr); eps2 = rsqr(getdparam("eps")); nforce = -1; /* use nforce as flag... */ while (get_snap(istr, &btab, &nbody, &tnow, intags, FALSE)) { if (nforce == -1 && ! set_member(intags, MassTag)) error("%s: Mass data missing from 1st snapshot\n", getargv0()); if (! set_member(intags, PosTag)) error("%s: %s data missing\n", getargv0(), PosTag); if (nforce == -1) nforce = (strnull(getparam("nforce")) ? nbody : MIN(getiparam("nforce"), nbody)); for (i = 0; i < nforce; i++) sum1force(btab, nbody, i, eps2); put_snap(ostr, &btab, &nforce, &tnow, bodytags); } return (0); }
int main(int argc, string argv[]) { string prog, itags[MaxBodyFields]; stream xstr; int nprof, nbody, nsamp; real *prof1, *prof2, rrange[2], tnow; bodyptr btab = NULL; initparam(argv, defv); layout_body(fields, Precision, NDIM); prog = mktemp((string) copxstr("/tmp/sm_XXXXXX", sizeof(char))); xstr = execmap(prog); get_history(xstr); nprof = getiparam("nprof"); prof1 = (real *) allocate((2 + nprof) * sizeof(real)); prof2 = (real *) allocate((2 + nprof) * sizeof(real)); setrange(rrange, getparam("rrange")); nsamp = 0; while (get_snap(xstr, &btab, &nbody, &tnow, itags, FALSE)) { setprofile(prof1, prof2, nprof, rrange, btab, nbody); nsamp++; } if (unlink(prog) != 0) error("%s: can't unlink %s\n", getargv0(), prog); if (nsamp == 0) error("%s: no data in input\n", getargv0()); listdensity(prof1, prof2, nprof, rrange, nsamp); return (0); }
int main(int argc, string argv[]) { stream istr, ostr; string itags[MaxBodyFields]; initparam(argv, defv); new_field(&LinkField, IntType, LinkTag); /* use int's worth of space */ new_field(&LinkField + 1, NULL, NULL); layout_body(bodytags, Precision, NDIM); istr = stropen(getparam("in"), "r"); get_history(istr); if (! get_snap(istr, &btab, &nbody, &tnow, itags, TRUE)) error("%s: snapshot input failed\n", getargv0()); if (! set_member(itags, PosTag)) error("%s: %s data missing\n", getargv0(), PosTag); if (getbparam("subkey") && ! set_member(itags, KeyTag)) error("%s: %s data missing\n", getargv0(), KeyTag); findobj(getdparam("bcrit"), getiparam("nmin"), getbparam("subkey")); ostr = stropen(getparam("out"), "w"); put_history(ostr); put_snap(ostr, &btab, &nbody, &tnow, set_union(itags, set_cons(KeyTag, NULL))); strclose(ostr); return (0); }
void nemo_main(void) /* this replaces main(argc,argv) <--- required */ { stream instr, outstr; string times = getparam("times"); real tsnap; Body *btab = NULL, *bp; int i, nbody, bits; bool first = TRUE; instr = stropen(getparam("in"), "r"); outstr = stropen(getparam("out"), "w"); for (;;) { /* infinite loop, broken only when ran out of snapshots */ get_history(instr); /* read history */ if (!get_tag_ok(instr, SnapShotTag)) break; /* check if done */ get_snap(instr, &btab, &nbody, &tsnap, &bits); /* get next */ /* Operate on the snapshot here : */ for (bp=btab, i=0; i<nbody; bp++, i++) { /* all the work goes here */ } if (first) { put_history(outstr); first = FALSE; } put_snap(outstr, &btab, &nbody, &tsnap, &bits); /* output */ } strclose(instr); if (first) { warning("No snapshots processed"); strdelete(outstr,TRUE); } else strclose(outstr); }
int main(int argc, string argv[]) { string prog, itags[MaxBodyFields], otags[MaxBodyFields]; stream xstr, ostr; bodyptr btab = NULL; int nbody; real tnow; initparam(argv, defv); exprs[0] = getparam("weight"); prog = mktemp((string) copxstr("/tmp/sm_XXXXXX", sizeof(char))); buildmap(prog, names, exprs, types, NULL, Precision, NDIM, TRUE); xstr = execmap(prog); if (get_tag_ok(xstr, "History")) skip_item(xstr); get_history(xstr); ostr = stropen(getparam("out"), "w"); put_history(ostr); new_field(&WeightField, RealType, "Weight"); new_field(&WeightField + 1, NULL, NULL); while (get_snap(xstr, &btab, &nbody, &tnow, itags, TRUE)) { snaprect(btab, nbody); del_tag(otags, itags, "Weight"); put_snap(ostr, &btab, &nbody, &tnow, otags); } strclose(ostr); if (unlink(prog) != 0) error("%s: can't unlink %s\n", getargv0(), prog); return (0); }
/* ** find_chasing ** Find the client structure for a nick name (user) using history ** mechanism if necessary. If the client is not found, an error ** message (NO SUCH NICK) is generated. If the client was found ** through the history, chasing will be 1 and otherwise 0. */ aClient *find_chasing(aClient *sptr, char *user, int *chasing) { aClient *who = find_client(user, (aClient *)NULL); if (chasing) *chasing = 0; if (who) { if (!IsServer(who)) return who; else return NULL; } if (!(who = get_history(user, (long)KILLCHASETIMELIMIT))) { sendto_one(sptr, err_str(ERR_NOSUCHNICK), me.name, sptr->name, user); return NULL; } if (chasing) *chasing = 1; if (!IsServer(who)) return who; else return NULL; }
void *accept_connection(void *data) { char command; struct accept_connection_data *d = (struct accept_connection_data*)data; if(socket_read(d->fd, &command, 1) == 1) { switch(command) { case 'r': register_vehicle(d->fd, d->vehicles); break; case 'd': delete_vehicle(d->fd, d->vehicles); break; case 'h': get_history(d->fd, d->vehicles); break; case 't': calculate_distance(d->fd, d->vehicles); break; case 's': check_status(d->fd, d->vehicles); break; } } TEMP_FAILURE_RETRY(close(d->fd)); stop_detached_thread(&d->mutex, d); return NULL; }
int main(int argc, string argv[]) { string prog, itags[MaxBodyFields]; stream xstr, ostr; int nold = -1; initparam(argv, defv); exprs[0] = getparam("group"); prog = mktemp((string) copxstr("/tmp/sm_XXXXXX", sizeof(char))); buildmap(prog, names, exprs, types, NULL, Precision, NDIM, TRUE); xstr = execmap(prog); if (get_tag_ok(xstr, "History")) skip_item(xstr); get_history(xstr); ostr = stropen(getparam("out"), "w"); put_history(ostr); new_field(&GroupField, IntType, "Group"); new_field(&GroupField + 1, NULL, NULL); layout_body(btags, Precision, NDIM); while (get_snap(xstr, &bodytab, &nbody, &tbody, itags, FALSE)) { snaptrak(); put_snap(ostr, &traktab, &ntrak, &tbody, otags); if (ntrak != nold) eprintf("[%s: wrote %d groups at t = %f]\n", getprog(), ntrak, tbody); nold = ntrak; } strclose(ostr); if (unlink(prog) != 0) error("%s: can't unlink %s\n", getprog(), prog); return (0); }
int main(int argc, string argv[]) { stream istr, ostr; bodyptr btab = NULL; int nbody; real tnow; string intags[MaxBodyFields]; gsprof *gsp; initparam(argv, defv); layout_body(bodyfields, Precision, NDIM); istr = stropen(getparam("in"), "r"); get_history(istr); if (! get_snap(istr, &btab, &nbody, &tnow, intags, FALSE)) error("%s: snapshot input failed\n", getargv0()); if (! set_member(intags, PosTag)) error("%s: position data missing\n", getargv0()); if (! set_member(intags, MassTag)) error("%s: mass data missing\n", getargv0()); gsp = snapgsp(btab, nbody, getiparam("npoint"), getdparam("alpha"), getdparam("beta")); if (! strnull(getparam("out"))) { ostr = stropen(getparam("out"), "w"); put_history(ostr); put_gsprof(ostr, gsp); strclose(ostr); } return (0); }
int main(int argc, string argv[]) { stream istr, ostr; gsprof *gsp; int np, i; real r0, lgrs, r; initparam(argv, defv); istr = stropen(getparam("in"), "r"); get_history(istr); gsp = get_gsprof(istr); if (! strnull(getparam("out"))) { ostr = stropen(getparam("out"), "w"); put_history(ostr); put_gsprof(ostr, gsp); strclose(ostr); } np = getiparam("npoint"); r0 = 1.0 / getdparam("r0inv"); lgrs = getdparam("lgrstep"); printf("%12s%12s%12s%12s%12s%12s\n", "radius", "log rho", "drho/dr", "mass", "mtot-mass", "radius(m)"); for (i = 0; i < np; i++) { r = r0 * rpow(2.0, lgrs * i); printf("%12.5f%12.7f%12.3e%12.8f%12.8f%12.5f\n", r, rlog10(rho_gsp(gsp, r)), drho_gsp(gsp, r), mass_gsp(gsp, r), gsp->mtot - mass_gsp(gsp, r), r_mass_gsp(gsp, mass_gsp(gsp, r))); } free_gsprof(gsp); return (0); }
int main(int argc, string argv[]) { string *datafields, *bodyfields, times, ifmt, rfmt; stream istr; bodyptr btab = NULL; int nbody; real tnow; string intags[MaxBodyFields]; initparam(argv, defv); istr = stropen(getparam("in"), "r"); get_history(istr); datafields = burststring(getparam("fields"), ", "); if (set_member(datafields, TimeTag)) bodyfields = set_diff(datafields, set_cons(TimeTag, NULL)); else bodyfields = datafields; layout_body(bodyfields, Precision, NDIM); times = getparam("times"); ifmt = getparam("ifmt"); rfmt = getparam("rfmt"); print_header(datafields, getparam("hfmt"), getparam("keyhead"), burststring(getparam("auxhead"), ", ")); while (get_snap_t(istr, &btab, &nbody, &tnow, intags, FALSE, times)) { if (! set_subset(intags, bodyfields)) error("%s: one or more required fields not found\n", getargv0()); print_data(btab, nbody, tnow, datafields, ifmt, rfmt); skip_history(istr); } return (0); }
int main(int argc, string argv[]) { stream istr, ostr; string times, *vecs, *produce, iotags[MaxBodyFields]; bool expand; snapshot snap = { NULL, 0, 0.0 }; initparam(argv, defv); istr = stropen(getparam("in"), "r"); get_history(istr); ostr = stropen(getparam("out"), "w"); put_history(ostr); times = getparam("times"); vecs = burststring(getparam("vectors"), ", "); expand = streq(getparam("produce"), "*"); if (! expand) { produce = burststring(getparam("produce"), ", "); layout_body(produce, Precision, NDIM); } while (get_snapshot_timed(istr, snap, iotags, expand, times)) { eprintf("[%s: rotating time %f]\n", getprog(), snap.time); snaprotate(&snap, iotags, vecs, getparam("order"), getbparam("invert"), getdparam("thetax"), getdparam("thetay"), getdparam("thetaz")); put_snapshot(ostr, snap, iotags); skip_history(istr); } strclose(ostr); return (0); }
read_snap() { int bits; get_history(instr); get_snap(instr,&btab,&nobj,&tsnap,&bits); }
int sh21(void) { t_sh sh; ft_bzero(&sh.l, sizeof(t_line)); srand(time(NULL)); sh.nbr = rand(); get_history(&g_hist); sh.av = NULL; handle_var(KV_SET, "?", "0"); while (1) { g_toto = g_titi = 1; g_tata = 0; g_prompt.onshell = 1; catch_signal(); g_prompt.son == 0 ? print_prompt(sh.nbr, g_env, g_lenv, &sh.l) : 0; g_prompt = (t_prompt){sh.nbr, g_env, g_lenv, 0, &sh.l, 1}; g_line = NULL; if ((sh.av = read_init(&sh.l, &g_hist)) != NULL) { g_line = NULL; g_prompt.onshell = 0; sh.o = shell(sh.av, 0); g_prompt.onshell = 1; } xmasterfree(); } return (1); }
int main( int argc, char** argv) { int ch = 0; char buf[STR_SIZE] = {}; char* hisBuf = NULL; char str[STR_SIZE] = {}; char historyArr[HISTORY_SIZE][STR_SIZE] = {}; int inHistory = 0; int cmd = -1; List_t* list = new_list( ); while( true) { getcwd( str, STR_SIZE); printf( "%s> ", str); fgets( buf, STR_SIZE, stdin); if( feof( stdin)) { printf( "logout\n"); break; } if( buf[0] == '\n') continue; parse_program( list, buf); if( (cmd = commands( list->head->next->program)) >= 0) { switch( cmd) { case logout: goto finish; break; case cd: if( chdir( list->head->next->program->arguments[0]) < 0) warn( "Error while changing dir"); break; case history: if( list->head->next->program->arguments[0][0]) { hisBuf = get_history( historyArr, atoi( list->head->next->program->arguments[0]), inHistory); if( hisBuf) { strcpy( buf, hisBuf); clear_list( list); parse_program( list, buf); printf( "%s\n", buf); execute( list); } } else dump_history( historyArr, inHistory); break; } } else execute( list); if( cmd != history) inHistory = add_in_history( historyArr, buf, inHistory); clear_list( list); } finish: destroy_list( list); return 0; }
void readgsp(void) { stream istr; istr = stropen(getparam("gsp"), "r"); get_history(istr); spheroid = gsp_read(istr); }
void nemo_main(void) { stream instr, outstr; real tsnap; string times; Body *btab = NULL, *bp; float mass, pos[NDIM], vel[NDIM], t; int j, nbody, bits; instr = stropen(getparam("in"), "r"); /* open input file */ outstr = stropen(getparam("out"), "w"); /* open output file */ times = getparam("times"); get_history(instr); /* read history */ for(;;) { /* repeating until first or all times are read */ get_history(instr); if (!get_tag_ok(instr, SnapShotTag)) break; /* done with work */ get_snap(instr, &btab, &nbody, &tsnap, &bits); if (!streq(times,"all") && !within(tsnap,times,0.0001)) continue; /* skip work on this snapshot */ if ( (bits & PhaseSpaceBit) == 0) continue; /* skip work, only diagnostics here */ dprintf(0,"Converting time=%f to RV format",tsnap); fwrite(&nbody,sizeof(int),1,outstr); for (bp = btab; bp < btab+nbody; bp++) { mass = Mass(bp); fwrite(&mass,sizeof(float),1,outstr); } t = tsnap; fwrite(&t,sizeof(float),1,outstr); for (bp = btab; bp < btab+nbody; bp++) { for(j = 0; j < NDIM; j++) { pos[j] = Pos(bp)[j]; vel[j] = Vel(bp)[j]; } fwrite(pos,sizeof(float),NDIM,outstr); fwrite(vel,sizeof(float),NDIM,outstr); } } strclose(instr); strclose(outstr); }
void Settings::save() { settings.beginGroup("servers"); settings.remove(""); for ( const auto& server : saved_servers ) { settings.beginGroup(QString::fromStdString(server.name)); settings.setValue("host",QString::fromStdString(server.server.host)); settings.setValue("port",uint(server.server.port)); settings.setValue("password",QString::fromStdString(server.rcon_password)); settings.setValue("secure",int(server.rcon_secure)); settings.setValue("console_history",get_history(server.name)); settings.endGroup(); } settings.endGroup(); settings.beginGroup("console"); settings.setValue("foreground",console_foreground.name()); settings.setValue("background",console_background.name()); settings.setValue("brightness_max",console_brightness_max); settings.setValue("brightness_min",console_brightness_min); settings.setValue("font",console_font.toString()); settings.setValue("history",console_max_history); settings.setValue("cvar",cvar_expansion_to_string(console_expansion)); settings.setValue("attach_log",console_attach_command); settings.setValue("detach_log",console_detach_command); settings.endGroup(); settings.beginGroup("behaviour"); settings.setValue("cmd_status", cmd_status); settings.setValue("cmd_cvarlist", cmd_cvarlist); settings.setValue("cmd_chmap", cmd_chmap); settings.beginWriteArray("quick_commands"); settings.remove(""); settings.setValue("cvar",cvar_expansion_to_string(quick_commands_expansion)); for ( uint i = 0; i < quick_commands.size(); i++ ) { settings.setArrayIndex(i); settings.setValue("label", quick_commands[i].first); settings.setValue("command", quick_commands[i].second); } settings.endArray(); settings.beginWriteArray("player"); settings.remove(""); settings.setValue("cvar",cvar_expansion_to_string(player_actions_expansion)); for ( int i = 0; i < player_actions.size(); i++ ) { settings.setArrayIndex(i); settings.setValue("label", player_actions[i].name()); settings.setValue("command",player_actions[i].command()); settings.setValue("icon", player_actions[i].icon_name()); } settings.endArray(); settings.endGroup(); }
int main(int argc, string argv[]) { string prog, coords, itags[MaxBodyFields], otags[MaxBodyFields]; stream xstr, ostr; bodyptr btab = NULL, bp; int nbody; real tnow; vector cmpos, cmvel, cmacc; initparam(argv, defv); exprs[0] = getparam("weight"); prog = mktemp((string) copxstr("/tmp/sm_XXXXXX", sizeof(char))); buildmap(prog, names, exprs, types, NULL, Precision, NDIM, TRUE); xstr = execmap(prog); if (get_tag_ok(xstr, "History")) skip_item(xstr); get_history(xstr); ostr = stropen(getparam("out"), "w"); put_history(ostr); coords = getparam("coords"); new_field(&WeightField, RealType, "Weight"); new_field(&WeightField + 1, NULL, NULL); while (get_snap(xstr, &btab, &nbody, &tnow, itags, TRUE, NULL)) { if (scanopt(coords, PosTag) && set_member(itags, PosTag)) { snapcmpos(cmpos, btab, nbody, WeightField.offset); for (bp = btab; bp < NthBody(btab, nbody); bp = NextBody(bp)) { SUBV(Pos(bp), Pos(bp), cmpos); } eprintf("[%s: centroid position: %f,%f,%f]\n", getprog(), cmpos[0], cmpos[1], cmpos[2]); } if (scanopt(coords, VelTag) && set_member(itags, VelTag)) { snapcmvel(cmvel, btab, nbody, WeightField.offset); for (bp = btab; bp < NthBody(btab, nbody); bp = NextBody(bp)) { SUBV(Vel(bp), Vel(bp), cmvel); } eprintf("[%s: centroid velocity: %f,%f,%f]\n", getprog(), cmvel[0], cmvel[1], cmvel[2]); } if (scanopt(coords, AccTag) && set_member(itags, AccTag)) { snapcmacc(cmacc, btab, nbody, WeightField.offset); for (bp = btab; bp < NthBody(btab, nbody); bp = NextBody(bp)) { SUBV(Acc(bp), Acc(bp), cmacc); } eprintf("[%s: cen. acceleration: %f,%f,%f]\n", getprog(), cmacc[0], cmacc[1], cmacc[2]); } del_tag(otags, itags, "Weight"); put_snap(ostr, &btab, &nbody, &tnow, otags); } strclose(ostr); if (unlink(prog) != 0) error("%s: can't unlink %s\n", getprog(), prog); return (0); }
int main(int argc, string argv[]) { stream fstr, istr, ostr; gsprof *gsp; bodyptr btab = NULL, p; int nbody; real tnow, r; string intags[MaxBodyFields]; initparam(argv, defv); layout_body(bodyfields, Precision, NDIM); fstr = stropen(getparam("gsp"), "r"); get_history(fstr); gsp = get_gsprof(fstr); istr = stropen(getparam("in"), "r"); get_history(istr); if (! get_snap(istr, &btab, &nbody, &tnow, intags, TRUE)) error("%s: snapshot input failed\n", getargv0()); if (! set_member(intags, PosTag)) error("%s: position data missing\n", getargv0()); if (streq(getparam("option"), "rho")) for (p = btab; p < NthBody(btab, nbody); p = NextBody(p)) Aux(p) = rho_gsp(gsp, absv(Pos(p))); else if (streq(getparam("option"), "drho")) for (p = btab; p < NthBody(btab, nbody); p = NextBody(p)) Aux(p) = drho_gsp(gsp, absv(Pos(p))); else if (streq(getparam("option"), "mass")) for (p = btab; p < NthBody(btab, nbody); p = NextBody(p)) Aux(p) = mass_gsp(gsp, absv(Pos(p))); else if (streq(getparam("option"), "phi")) for (p = btab; p < NthBody(btab, nbody); p = NextBody(p)) Aux(p) = phi_gsp(gsp, absv(Pos(p))); else error("%s: unknown option %s\n", getargv0(), getparam("option")); if (! strnull(getparam("out"))) { ostr = stropen(getparam("out"), "w"); put_history(ostr); put_snap(ostr, &btab, &nbody, &tnow, set_union(bodyfields, intags)); strclose(ostr); } return (0); }
/* implementazione funzioni */ void update_log() { int i; char *str; wclear(log_win); for (i=WIN_LOG_HEIGH; i>0; i--) { str = get_history(i); if (strlen(str)>0) wprintw(log_win, "%s\n", str); } wrefresh(log_win); }
/* * mo_kill - oper message handler * * NOTE: IsPrivileged(sptr), IsAnOper(sptr) == true * IsServer(cptr), IsServer(sptr) == false * * parv[0] = sender prefix * parv[1] = kill victim * parv[parc-1] = kill path */ int mo_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { struct Client* victim; char* user; char msg[TOPICLEN + 3]; /* (, ), and \0 */ assert(0 != cptr); assert(0 != sptr); /* * oper connection to this server, cptr is always sptr */ assert(cptr == sptr); assert(IsAnOper(sptr)); if (parc < 3 || EmptyString(parv[parc - 1])) return need_more_params(sptr, "KILL"); user = parv[1]; ircd_snprintf(0, msg, sizeof(msg), "(%.*s)", TOPICLEN, parv[parc - 1]); if (!(victim = FindClient(user))) { /* * If the user has recently changed nick, we automaticly * rewrite the KILL for this new nickname--this keeps * servers in synch when nick change and kill collide */ if (!(victim = get_history(user, (long)15))) return send_reply(sptr, ERR_NOSUCHNICK, user); sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :Changed KILL %s into %s", sptr, user, cli_name(victim)); } if (!HasPriv(sptr, MyConnect(victim) ? PRIV_LOCAL_KILL : PRIV_KILL)) return send_reply(sptr, ERR_NOPRIVILEGES); if (IsServer(victim) || IsMe(victim)) { return send_reply(sptr, ERR_CANTKILLSERVER); } /* * if the user is +k, prevent a kill from local user */ if (IsChannelService(victim)) return send_reply(sptr, ERR_ISCHANSERVICE, "KILL", cli_name(victim)); if (!MyConnect(victim) && !HasPriv(sptr, PRIV_KILL)) { sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :Nick %s isnt on your server", sptr, cli_name(victim)); return 0; } return do_kill(cptr, sptr, victim, cli_user(sptr)->host, cli_name(sptr), msg); }
int main(int argc, string argv[]) { stream istr, ostr; string times, *produce, itags[MaxBodyFields], atags[MaxBodyFields]; bodyptr btab = NULL; int nbody, ntag, i; real tsnap; bool expand; initparam(argv, defv); istr = stropen(getparam("in"), "r"); get_history(istr); times = getparam("times"); expand = streq(getparam("produce"), "*"); if (! expand) { produce = burststring(getparam("produce"), ", "); layout_body(produce, Precision, NDIM); } atags[ntag = 0] = NULL; while (get_snap_t(istr, &btab, &nbody, &tsnap, itags, expand, times)) { for (i = 0; itags[i] != NULL; i++) if (! set_member(atags, itags[i])) { atags[ntag++] = itags[i]; atags[ntag] = NULL; } get_history(istr); } if (! expand) { for (i = 0; produce[i] != 0; i++) if (! set_member(atags, produce[i])) error("%s: field %s missing\n", getargv0(), produce[i]); } else produce = atags; ostr = stropen(getparam("out"), "w"); put_history(ostr); put_snap(ostr, &btab, &nbody, &tsnap, produce); strclose(ostr); return (0); }