void mbhelp_t::charstr (int number, char character) //************************************************************************* // //************************************************************************* { int i; for (i = 0; i < number; i++) putv(character); putv(LF); }
int r_cone( /* put out a cone */ int ac, char **av ) { static int ncones; char *mat; double r1, r2; C_VERTEX *cv1, *cv2; FVECT p1, p2; int inv; /* check argument count and type */ if (ac != 5) return(MG_EARGC); if (!isflt(av[2]) || !isflt(av[4])) return(MG_ETYPE); /* get the endpoint vertices */ if ((cv1 = c_getvert(av[1])) == NULL || (cv2 = c_getvert(av[3])) == NULL) return(MG_EUNDEF); xf_xfmpoint(p1, cv1->p); /* transform endpoints */ xf_xfmpoint(p2, cv2->p); r1 = xf_scale(atof(av[2])); /* scale radii */ r2 = xf_scale(atof(av[4])); inv = r1 < 0.; /* check for inverted cone */ if (r1 == 0.) { /* check for illegal radii */ if (r2 == 0.) return(MG_EILL); inv = r2 < 0.; } else if (r2 != 0. && inv ^ (r2 < 0.)) return(MG_EILL); if (inv) { r1 = -r1; r2 = -r2; } if ((mat = material()) == NULL) /* get material */ return(MG_EBADMAT); /* spit the sucker out */ printf("\n%s %s %sc%d\n", mat, inv ? "cup" : "cone", object(), ++ncones); printf("0\n0\n8\n"); putv(p1); putv(p2); printf("%18.12g %18.12g\n", r1, r2); return(MG_OK); }
void do_tri( /* put out smoothed triangle */ char *mat, C_VERTEX *cv1, C_VERTEX *cv2, C_VERTEX *cv3, int iv ) { static int ntris; BARYCCM bvecs; RREAL bcoor[3][3]; C_VERTEX *cvt; FVECT v1, v2, v3; FVECT n1, n2, n3; register int i; if (iv) { /* swap vertex order if inverted */ cvt = cv1; cv1 = cv3; cv3 = cvt; } xf_xfmpoint(v1, cv1->p); xf_xfmpoint(v2, cv2->p); xf_xfmpoint(v3, cv3->p); /* compute barycentric coords. */ if (comp_baryc(&bvecs, v1, v2, v3) < 0) return; /* degenerate triangle! */ printf("\n%s texfunc T-nor\n", mat); /* put out texture */ printf("4 dx dy dz %s\n0\n", TCALNAME); xf_rotvect(n1, cv1->n); xf_rotvect(n2, cv2->n); xf_rotvect(n3, cv3->n); for (i = 0; i < 3; i++) { bcoor[i][0] = n1[i]; bcoor[i][1] = n2[i]; bcoor[i][2] = n3[i]; } put_baryc(&bvecs, bcoor, 3); /* put out triangle */ printf("\nT-nor polygon %st%d\n", object(), ++ntris); printf("0\n0\n9\n"); putv(v1); putv(v2); putv(v3); }
int r_face( /* convert a face */ int ac, char **av ) { static int nfaces; int myi = invert; char *mat; register int i; register C_VERTEX *cv; FVECT v; /* check argument count and type */ if (ac < 4) return(MG_EARGC); if ((mat = material()) == NULL) /* get material */ return(MG_EBADMAT); if (ac <= 5) { /* check for smoothing */ C_VERTEX *cva[5]; for (i = 1; i < ac; i++) { if ((cva[i-1] = c_getvert(av[i])) == NULL) return(MG_EUNDEF); if (is0vect(cva[i-1]->n)) break; } if (i < ac) i = ISFLAT; else i = flat_tri(cva[0]->p, cva[1]->p, cva[2]->p, cva[0]->n, cva[1]->n, cva[2]->n); if (i == DEGEN) return(MG_OK); /* degenerate (error?) */ if (i == RVBENT) { myi = !myi; i = ISBENT; } else if (i == RVFLAT) { myi = !myi; i = ISFLAT; } if (i == ISBENT) { /* smoothed triangles */ do_tri(mat, cva[0], cva[1], cva[2], myi); if (ac == 5) do_tri(mat, cva[2], cva[3], cva[0], myi); return(MG_OK); } } /* spit out unsmoothed primitive */ printf("\n%s polygon %sf%d\n", mat, object(), ++nfaces); printf("0\n0\n%d\n", 3*(ac-1)); for (i = 1; i < ac; i++) { /* get, transform, print each vertex */ if ((cv = c_getvert(av[myi ? ac-i : i])) == NULL) return(MG_EUNDEF); xf_xfmpoint(v, cv->p); putv(v); } return(MG_OK); }
void Put(struct ocx *ocx, enum ocx_chan chan, const char *fmt, ...) { va_list ap; AZ(ocx); va_start(ap, fmt); putv(ocx, chan, fmt, ap); va_end(ap); }
int r_cyl( /* put out a cylinder */ int ac, char **av ) { static int ncyls; char *mat; double rad; C_VERTEX *cv1, *cv2; FVECT p1, p2; int inv; /* check argument count and type */ if (ac != 4) return(MG_EARGC); if (!isflt(av[2])) return(MG_ETYPE); /* get the endpoint vertices */ if ((cv1 = c_getvert(av[1])) == NULL || (cv2 = c_getvert(av[3])) == NULL) return(MG_EUNDEF); xf_xfmpoint(p1, cv1->p); /* transform endpoints */ xf_xfmpoint(p2, cv2->p); rad = xf_scale(atof(av[2])); /* scale radius */ if ((inv = rad < 0.)) /* check for inverted cylinder */ rad = -rad; if ((mat = material()) == NULL) /* get material */ return(MG_EBADMAT); /* spit out the primitive */ printf("\n%s %s %scy%d\n", mat, inv ? "tube" : "cylinder", object(), ++ncyls); printf("0\n0\n7\n"); putv(p1); putv(p2); printf("%18.12g\n", rad); return(MG_OK); }
int r_ring( /* put out a ring */ int ac, char **av ) { static int nrings; char *mat; double r1, r2; C_VERTEX *cv; FVECT cent, norm; /* check argument count and type */ if (ac != 4) return(MG_EARGC); if (!isflt(av[2]) || !isflt(av[3])) return(MG_ETYPE); if ((cv = c_getvert(av[1])) == NULL) /* get center vertex */ return(MG_EUNDEF); if (is0vect(cv->n)) /* make sure we have normal */ return(MG_EILL); xf_xfmpoint(cent, cv->p); /* transform center */ xf_rotvect(norm, cv->n); /* rotate normal */ r1 = xf_scale(atof(av[2])); /* scale radii */ r2 = xf_scale(atof(av[3])); if ((r1 < 0.) | (r2 <= r1)) return(MG_EILL); if ((mat = material()) == NULL) /* get material */ return(MG_EBADMAT); /* spit out primitive */ printf("\n%s ring %sr%d\n", mat, object(), ++nrings); printf("0\n0\n8\n"); putv(cent); putv(norm); printf("%18.12g %18.12g\n", r1, r2); return(MG_OK); }
void Fail(struct ocx *ocx, int err, const char *fmt, ...) { va_list ap; if (err) err = errno; Put(ocx, OCX_DIAG, "Failure: "); va_start(ap, fmt); putv(ocx, OCX_DIAG, fmt, ap); va_end(ap); Put(ocx, OCX_DIAG, "\n"); if (err) Put(ocx, OCX_DIAG, "errno = %d (%s)\n", err, strerror(err)); exit(1); }
int sysbef (char *befbuf) //************************************************************************* // //************************************************************************* { static char shutdown_reason[23]; char xbuf[20]; static char *beftab[] = { "CONNECT", "LOGIN", "CALL", "OSHELL", #ifdef __DOS16__ #ifdef _TNC "TNC", #endif "W2", "UWIN", "TWIN", #ifdef _AUTOTRCWIN "TRWIN", #endif #endif "RTEXT", "CAT", "RPRG", "WTEXT", "WPRG", "RBIN", "WBIN", "SLR", "CLOG", "REORG", "LIFETIME", "MKBOARD", "RMBOARD", "MVBOARD", "SHUTDOWN", "NEW", "KILL", "TEST", "IMPORT", "DISABLE", "ENABLE", #ifdef DIEBOX_UIMPORT "UIMPORT", #endif #ifdef OLDMAILIMPORT "OLDMAILIMPORT", #endif "SETUSER", "BEACON", "GREP", "TGREP", "TAIL", "BEGIN", "BATCH", "EXPORT", "PWGEN", "POSTFWD", "MONITOR", "NOTE", "MACRO", "CFGFLEX", "ORM", "OMV", "OCP", "OMD", "APPEND", #ifdef DF3VI_EXTRACT "EXTRACT", #endif "HOLD", "SETPW", #ifdef FEATURE_YAPP "WYAPP", "RYAPP", #endif #ifdef FEATURE_DIDADIT "WDIDADIT", "RDIDADIT", #endif #if defined FEATURE_SERIAL || defined _TELEPHONE "TTYINIT", #endif #ifdef _TELEPHONE // JJ "TTYCMD", "TTYDIAL", "TTYHANGUP", "TTYSTATUS", "TTYWIN", "TTYCOUNTERRESET", #endif #ifdef _AUTOFWD "AFWDLIST", #endif #ifdef FEATURE_MDPW "MD2SUM", "MD5SUM", #endif #ifdef FEATURE_EDITOR "EDIT", "FEDIT", "REDIT", #else #ifdef DF3VI_FWD_EDIT "FEDIT", "FWDEDIT", #endif #ifdef DF3VI_REJ_EDIT "REDIT", "REJECTEDIT", #endif #ifdef DF3VI_CONV_EDIT "CEDIT", "CONVEDIT", #endif #endif #ifdef _FILEFWD "FWDIMPORT", "FWDEXPORT", #endif "YMBTEST", "SCMDLIST", // Dies ist immer das letzte Kommando! NULL }; enum befnum { unsinn, connect_, login, call_, oshell_, #ifdef __DOS16__ #ifdef _TNC tnc, #endif w2, uwin, twin, #ifdef _AUTOTRCWIN trwin, #endif #endif rtext, rtext_, rprg, wtext, wprg, rbin, wbin, slr, clog, reorg, life_, mkb, rmb, mvb, shutdown_, new_, kill_, test, import, disable_, enable_, #ifdef DIEBOX_UIMPORT uimport_, #endif #ifdef OLDMAILIMPORT oldmailimport_, #endif setuser, beacon, grep_, tgrep, tail, begin, batch, export_, pwgen, postfwd_, monitor_, note, macro, cfgflex_, orm, omv, ocp, omd, _append, #ifdef DF3VI_EXTRACT extract_, #endif hold, setpw, #ifdef FEATURE_YAPP wyapp, ryapp, #endif #ifdef FEATURE_DIDADIT wdidadit, rdidadit, #endif #if defined FEATURE_SERIAL || defined _TELEPHONE ttyinit, #endif #ifdef _TELEPHONE // JJ ttycmd, ttydial, ttyhangup, ttystatus, ttywin_, ttycounterreset, #endif #ifdef _AUTOFWD afwdlist_, #endif #ifdef FEATURE_MDPW md2sum, md5sum, #endif #ifdef FEATURE_EDITOR edit, fedit, redit, #else #ifdef DF3VI_FWD_EDIT fedit, fwdedit, #endif #ifdef DF3VI_REJ_EDIT redit, rejectedit, #endif #ifdef DF3VI_CONV_EDIT cedit, convedit_, #endif #endif #ifdef _FILEFWD fwdimport, fwdexport, #endif ymbtest, scmdlist // Dies ist immer das letzte Kommando! } cmd = unsinn; befbuf += blkill(befbuf); cmd = (befnum) readcmd(beftab, &befbuf, 0); switch (cmd) { #ifdef FEATURE_YAPP case ryapp: #endif #ifdef FEATURE_DIDADIT case rdidadit: #endif #if defined(FEATURE_YAPP) || defined(FEATURE_DIDADIT) break; #endif default: if (u->lf != 6) putv(LF); leerzeile(); // Sends the number of CRs stored in "ALTER LF" } switch (cmd) { case unsinn: if ( mbinitbef(befbuf, 0) #ifdef _TELEPHONE // JJ || ttyinitbef(befbuf, 0) #endif ) { strcpy(xbuf, "^"); mbparsave(); #ifdef _TELEPHONE // JJ ttyparsave(); #endif strncpy(xbuf + 1, befbuf, 18); xbuf[19] = 0; subst1(xbuf, ' ', 0); subst1(xbuf, '=', 0); grep(MBINITNAME, xbuf, o_i); #ifdef _TELEPHONE // JJ grep(INITTTYNAME, xbuf, o_i); #endif return OK; } else return NO; case note: trace(replog, "note", "%s", befbuf); break; #ifdef DF3VI_EXTRACT case extract_: mbchange(befbuf, w_extract, 1); break; #endif case hold: mbchange(befbuf, w_hold, 1); break; case omv: { char f1[50], f2[50]; befbuf = nexttoken(befbuf, f1, 49); befbuf = nexttoken(befbuf, f2, 49); if (! *f1 || ! *f2 || xrename(f1, f2)) putf(ms(m_error)); else { putf(ms(m_moving)); putf(ms(m_nach), f1, f2); } break; } case ocp: { char f1[50], f2[50]; befbuf = nexttoken(befbuf, f1, 49); befbuf = nexttoken(befbuf, f2, 49); if (! *f1 || ! *f2 || filecopy(f1, f2)) putf(ms(m_error)); else { putf(ms(m_copying)); putf(ms(m_nach), f1, f2); } break; } case orm: { char f1[50]; befbuf = nexttoken(befbuf, f1, 49); if (! *f1 || xunlink(f1)) putf(ms(m_filecantdeleted), f1); else putf(ms(m_filedeleted), f1); break; } case omd: { char f1[50]; befbuf = nexttoken(befbuf, f1, 49); killbackslash(f1); if (! *f1 || xmkdir(f1)) putf(ms(m_directorycantcreated), f1); else putf(ms(m_directorycreated), f1); break; } case _append: { char textline[LINELEN+1]; befbuf = nexttoken(befbuf, textline, LINELEN); if (! *befbuf) { putf("Syntax: APPEND <textline> <filename>\n"); break; } FILE *f = s_fopen(befbuf, "sat"); if (f) { fprintf(f, "%s\n", textline); s_fclose(f); } else putf(ms(m_filenotfound), befbuf); } break; case macro: { mk_start(befbuf); } break; case setuser: { char call[CALLEN+1]; befbuf = nexttoken(befbuf, call, CALLEN+1); strupr(call); if (mbcallok(call) && *befbuf) { trace(report, "setuser", "%s", befbuf); { if (! mbalter(NULL, befbuf, call)) putf(ms(m_isunknown), call); b->msg_loadnum = 0; //reload msg loaduser(b->logincall, u, 1); } } else putf("Syntax: SETUSER <call> <option> <value>\n"); } break; case setpw: //automatisierte Passwort-Vergabe { char call[CALLEN+1]; char passwd[40]; int i, pwline = 0; FILE *upwf; befbuf = nexttoken(befbuf, call, CALLEN+1); strupr(call); pwline = atoi(befbuf); if (! mbcallok(call) || ! pwline) { putf("Syntax: SETPW <call> <number>\n"); break; } if (! loaduser(call, u, 0)) { putf(ms(m_isunknown), call); break; } upwf = s_fopen("userpw.bcm", "sr"); if (! upwf) { putf(ms(m_filenotfound), "userpw.bcm"); break; } for (i = 0; i < pwline && ! feof(upwf); i++) fgets(passwd, sizeof(passwd) - 1, upwf); s_fclose(upwf); if (i < pwline) { putf(ms(m_userpwlines), i - 1); break; } strcpy(u->password, passwd); saveuser(u); pwline = strlen(u->password); putf(ms(m_loginpw), pwtypestr(u->loginpwtype), pwtypestr(u->sfpwtype)); putf(" "); putf(ms(m_pwdlength), pwline); sprintf(passwd, "pw set to %i char", pwline); pwlog(call, b->logincall, passwd); b->msg_loadnum = 0; //reload msg loaduser(b->logincall, u, 1); } break; #ifdef DIEBOX_UIMPORT case uimport_: { putf(ms(m_dieboximport)); uimport(); } break; #endif #ifdef OLDMAILIMPORT case oldmailimport_: { scanoptions(befbuf); formoptions(); befbuf += blkill(befbuf); if (isdir(befbuf)) { putf(ms(m_omi_started), befbuf); putflush(); oldmailimport(befbuf); } else putf(ms(m_dirunknown), befbuf); } break; #endif case disable_: { putf(ms(m_boxdisabled)); m.disable = 1; mbparsave(); } break; case enable_: { putf(ms(m_boxenabled)); m.disable = 0; mbparsave(); } break; case test: { if (*befbuf == 'W') { while (1); } // for testing watchdog else if (*befbuf == 'S') { trace(fatal, "test", "abort"); } else if (*befbuf == 'V') { *(char *)0 = 1; } else mk_start(befbuf); } break; case batch: { runbatch(befbuf); } break; case rtext: case rtext_: { fileio_text fio; fio.usefile(befbuf); fio.tx(); putf("\032\n"); // CTRL-Z } break; case wtext: { fileio_text fio; fio.usefile(befbuf); fio.rx(); } break; case rbin: case rprg: { fileio_abin fio; fio.usefile(befbuf); fio.tx(); } break; case wbin: case wprg: { fileio_abin fio; fio.usefile(befbuf); fio.rx(); } break; #ifdef FEATURE_YAPP case ryapp: { fileio_yapp fio; fio.usefile(befbuf); fio.tx(); } break; case wyapp: { fileio_yapp fio; fio.usefile(befbuf); fio.rx(); } break; #endif // FEATURE_YAPP #ifdef FEATURE_DIDADIT case rdidadit: { fileio_dida fio; fio.usefile(befbuf); fio.tx(); } break; case wdidadit: { fileio_dida fio; if (! *befbuf) fio.usefile("dummy"); else { if (befbuf[strlen(befbuf) - 1] != '/') strcat(befbuf, "/"); strcat(befbuf, "dummy"); fio.usefile(befbuf); } fio.rx(); } break; #endif // FEATURE_DIDADIT case slr: { scanoptions(befbuf); putlog(TRACEPATH "/" SYSLOGRNAME, befbuf); } break; case clog: { scanoptions(befbuf); putlog(TRACEPATH "/" CMDLOGNAME, befbuf); } break; case tail: { scanoptions(befbuf); befbuf += blkill(befbuf); if (b->optplus&o_f && *befbuf) { int a; FILE *f = s_fopen(befbuf, "lrt"); if (f) { fseek(f, 0, SEEK_END); do { while ((a = fgetc(f)) != EOF) putv(a); wdelay(349); } while (! testabbruch()); s_fclose(f); } } else { fileio_text fio; fio.usefile(befbuf); fio.settail(-2000); fio.tx(); } } break; case begin: { fileio_text fio; fio.usefile(befbuf); fio.settail(2000); fio.tx(); } break; case monitor_: { if (*befbuf) { scanoptions(befbuf); b->continous = 1; monitor(atoi(befbuf), b->optplus); } else putf("Syntax: MONITOR [-iords] <task-id>\n"); } break; case tgrep: { char string[61]; char name[40]; scanoptions(befbuf); if (b->optminus & o_i) b->optplus |= o_i; //wenn nicht explizit "-i-", ist "-i" default b->usermail = 0; if (! *befbuf) { putf("Syntax: TGREP [pattern] <fwd-bbs>\n"); break; } befbuf = nexttoken(befbuf, string, 60); if (*befbuf) { sprintf(name, TRACEPATH "/t_%s.bcm", befbuf); grep(name, string, b->optplus); } else { sprintf(name, TRACEPATH "/t_%s.bcm", string); putlog(name, ""); } } break; case grep_: { char string[61]; scanoptions(befbuf); if (b->optminus & o_i) b->optplus |= o_i; //wenn nicht explizit "-i-", ist "-i" default b->usermail = 0; befbuf = nexttoken(befbuf, string, 60); grep(befbuf, string, b->optplus); } break; #ifdef _AUTOFWD case afwdlist_: { afwdlist(befbuf); } break; #endif case life_: { if (*befbuf) { strupr(befbuf); char *life = skip(befbuf); int board = finddir(befbuf, b->sysop); if (board > 0) { board -= 1; if (life && *life) { tree[board].lifetime_max = atoi(life); tree[board].lifetime_min = 1; if (tree[board].lifetime_max > 999) tree[board].lifetime_max = 999; if (tree[board].lifetime_max < 1) tree[board].lifetime_max = 1; char *life_min = skip(life); if (life_min && *life_min) { tree[board].lifetime_min = atoi(life_min); if (tree[board].lifetime_min > 999) tree[board].lifetime_min = 999; if (tree[board].lifetime_min < 1) tree[board].lifetime_min = 1; } mbtreesave(); } putf(ms(m_lifetimestat), b->boardfullname, tree[board].lifetime_max, tree[board].lifetime_min); } else putf(ms(m_notfound), befbuf); } else putf("Syntax: LIFETIME <board> <days_maximum> [<days_minimum>]\n" " (with 1 <= days_maximum/days_minimum <= 999)\n\n"); } break; #ifdef _TNC case tnc: { control_tnc(befbuf); } break; #endif case connect_: { termqso(befbuf); } break; case login: { if (mbcallok(befbuf)) { mblogin(befbuf, login_standard, b->uplink); cmdlog("login changed"); putf(ms(m_loginchanged)); } else putf("Syntax: LOGIN <new logincall>\n"); } break; case call_: { if (mbcallok(befbuf)) { mblogin(befbuf, login_silent, b->uplink); b->msg_loadnum--; //Sonst wird falsche Sprache benutzt cmdlog("call changed"); } else putf("Syntax: CALL <new logincall>\n"); } break; case oshell_: { if (t->input == io_file || t->output == io_file) oshell(befbuf, sh_noinput); else oshell(befbuf, m.dosinput ? sh_forceinput : sh_ifmultitask); } break; case reorg: { if (sema_test("purgereorg") == 1) putf(ms(m_purgeallstarted)); else { putf(ms(m_reorginvoked)); fork(P_BACK | P_MAIL, 0, mbreorg, befbuf); } } break; case postfwd_: { putf(ms(m_postfwdinvoked)); fork(P_BACK | P_MAIL, 0, postfwd, "Postfwd"); } break; #ifdef FEATURE_EDITOR case edit: { fork(P_WIND | P_KEYB, 0, editfile, befbuf); } break; case fedit: { fork(P_WIND | P_KEYB, 0, editfile, FWDLISTNAME); } break; case redit: { fork(P_WIND | P_KEYB, 0, editfile, REJECTNAME); } break; #else #ifdef DF3VI_FWD_EDIT case fedit: //wenn kein editor vorhanden remote-editor aufrufen case fwdedit: { fwdlistedit(befbuf); } break; #endif #ifdef DF3VI_REJ_EDIT case redit: case rejectedit: { rejectlistedit(befbuf); } break; #endif #ifdef DF3VI_CONV_EDIT case cedit: case convedit_: { convedit(befbuf); } break; #endif #endif case new_: { scanoptions(befbuf); mbinit(); initfwdlist(); #ifdef _AUTOFWD initafwdlist(); #endif if (! (b->optplus & o_q)) // skip statistics on "new -q" { b->optplus = o_s | o_f | o_c; putf(ms(m_hadrstat)); browse_hadr(""); } mbcvtload(); #ifdef RUNUTILS read_runfile(); #endif msg_dealloc(1); mk_read_jobs(); } break; case kill_: { if (atoi(befbuf)) { while (atoi(befbuf)) { if (! killtask(nextdez(&befbuf), 1)) putf(ms(m_cantkilltask)); } } else putf("Syntax: KILL <task-id>\n"); } break; #ifdef __DOS16__ case w2: { fork(P_WIND | P_KEYB|P_MAIL, 0, mbwin2, m.sysopcall); } break; case uwin: { fork(P_WIND | P_KEYB|P_MAIL, 0, userwin, "Users"); } break; case twin: { fork(P_WIND | P_MAIL, 0, taskwin, befbuf); } break; #ifdef _AUTOTRCWIN case trwin: { if (*befbuf) fork(P_WIND | P_MAIL, 0, trcwin, befbuf); else putf("Syntax: TRWIN [-iords] <task-id>\n"); } break; #endif #endif //__DOS16__ case mkb: { char mainboard[30]; char newboard[20]; char *slash; befbuf = nexttoken(befbuf, mainboard, 29); befbuf = nexttoken(befbuf, newboard, 19); slash = strchr(mainboard + 1, '/'); if (slash && (! *newboard)) { *slash = 0; strcpy(newboard, slash + 1); } if (! *newboard && *mainboard == '/') { strcpy(newboard, mainboard + 1); mainboard[1] = 0; } if (*mainboard && *newboard) { switch (mkboard(mainboard, newboard, 0)) { case 0: putf(ms(m_boardcreated)); break; case 1: putf(ms(m_mainboardnotfound)); break; case 2: putf(ms(m_toomanyboards)); break; case 3: putf(ms(m_boardnameexist)); break; case 4: putf(ms(m_invalidboardname)); break; } } else putf("Syntax: MKBOARD <mainboard> <subboard>\n"); } break; case rmb: { if (*befbuf) { subst1(befbuf, ' ', '/'); if (*befbuf == '/' && befbuf[1] == '/') befbuf++; switch (rmboard(befbuf)) { case 0: putf(ms(m_boardremoved)); break; case 1: putf(ms(m_boardnotfound)); break; case 2: putf(ms(m_boardnotempty)); break; } } else putf("Syntax: RMBOARD <mainboard> <subboard>\n"); } break; case mvb: { char oldboard[20]; char subboard[20]; char neuboard[20]; befbuf = nexttoken(befbuf, oldboard, 19); befbuf = nexttoken(befbuf, subboard, 19); befbuf = nexttoken(befbuf, neuboard, 19); if (*oldboard && *subboard && *neuboard) { switch (mvboard(oldboard, subboard, neuboard)) { case 0: putf(ms(m_boardmoved)); break; case 1: putf(ms(m_newboardnotfound)); break; case 2: putf(ms(m_toomanyboards)); break; case 4: putf(ms(m_oldboardnotfound)); break; } } else putf("Syntax: MVBOARD <oldboard> <subboard> <newboard>\n"); } break; case shutdown_: { scanoptions(befbuf); #ifdef __DOS16__ if (b->optplus & o_r) atexit((void(*)()) MK_FP(0xffff, 0x0000)); #endif runterfahren = 1; sprintf(shutdown_reason, "shutdown by %s", b->logincall); stopreason = shutdown_reason; } break; case cfgflex_: { if (*befbuf && file_isreg("cfgflex.bcm")) { putf(ms(m_flexstarted)); fork(P_BACK | P_MAIL, 0, cfgflex, befbuf); } else putf("Syntax: CFGFLEX <flexcall> (cfgflex.bcm must exist)\n"); } break; case import: { sysimport(befbuf); } break; case export_: { if (*befbuf) { if ((t->input != io_file || t->output == io_dummy) && t->output != io_file) { char fname[51]; scanoptions(befbuf); befbuf = nexttoken(befbuf, fname, 50); if (b->optplus & o_a) // neue Option -b fuer binaer { if (b->optplus & o_b) b->outputfile = s_fopen(fname, "sab"); else b->outputfile = s_fopen(fname, "sat"); } else { if (b->optplus & o_b) b->outputfile = s_fopen(fname, "swb"); else b->outputfile = s_fopen(fname, "swt"); } if (b->outputfile) { s_fsetopt(b->outputfile, 1); b->oldinput = t->input; b->oldoutput = t->output; t->input = io_dummy; t->output = io_file; b->continous = 1; if (b->optplus & o_u) b->sysop = 0; if (*befbuf) mailbef(befbuf, 0); b->sysop = 1; } else putf(ms(m_filenotopen), fname); } } else putf("Syntax: EXPORT <filename> <box-command>\n"); } break; case beacon: { if (*befbuf) { FILE *f = s_fopen(BEACONNAME, "srt"); unsigned int i = 0; char s[LINELEN+1]; if (f) { while (fgets(s, LINELEN, f)) { if (*s) { s[strlen(s) - 1] = 0; putbeacon_tnc(s, befbuf); i++; } } s_fclose(f); } putf(ms(m_beaconframes), i); } else { fork(P_BACK | P_MAIL, 0, sendmailbake, "Beacon"); putf(ms(m_beaconstarted)); } } break; case pwgen: { FILE *f; if (*befbuf && (f = s_fopen(befbuf, "swt")) != 0) { unsigned int i; int upw; upw = ! stricmp(befbuf, "userpw.bcm"); // file fuer setpw for (i = 0; i < 1620; i++) { char c = 0; while (! isalnum(c)) c = random_max('z'); fputc(c, f); //pw-file fuer setpw erzeugen (81 Zeilen mit je 20 Zeichen) if (upw && (i % 20) == 19) fputc(LF, f); } trace(report, "pwgen", "%s created", befbuf); s_fclose(f); } else //ohne Parameter immer userpw.bcm erzeugen if (! *befbuf && (f = s_fopen("userpw.bcm", "swt")) != 0) { unsigned int i; for (i = 0; i < 1620; i++) { char c = 0; while (! isalnum(c)) c = random_max('z'); fputc(c, f); //pw-file fuer setpw erzeugen (81 Zeilen mit je 20 Zeichen) if ((i % 20) == 19) fputc(LF, f); } trace(report, "pwgen", "userpw.bcm created"); s_fclose(f); } } break; case scmdlist: // DH3MB { unsigned int i = 0; while (beftab[i]) putf("(%02d) %s\n", ++i, beftab[i]); } break; #ifdef FEATURE_MDPW case md2sum: { if (! *befbuf) { putf("Syntax: MD2SUM <filename>\n"); break; } if (! file_isreg(befbuf)) putf(ms(m_filenotfound), befbuf); else { MD2 md2; md2.readfile(befbuf, 0L); md2.gethexdigest(b->line); putf("%s %s\n", b->line, befbuf); } } break; case md5sum: { if (! *befbuf) { putf("Syntax: MD5SUM <filename>\n"); break; } if (! file_isreg(befbuf)) putf(ms(m_filenotfound), befbuf); else { MD5 md5; md5.readfile(befbuf, 0L); md5.gethexdigest(b->line); putf("%s %s\n", b->line, befbuf); } } break; #endif #if defined FEATURE_SERIAL || defined _TELEPHONE case ttyinit: { if (eingelogt("getty", 0, 0)) putf(ms(m_ttyactive)); else init_tty(); } break; #endif #ifdef _TELEPHONE // JJ case ttycmd: { if (*befbuf) { if (m.ttydevice > 1) putf_tty("%s\r", befbuf); else putf(ms(m_nomodem)); } else putf("Syntax: TTYCMD <command>\n"); } break; case ttydial: { strupr(befbuf); char *nummer; char call[8]; nummer = nexttoken(befbuf, call, 8); if (*befbuf && mbcallok(call)) { if (m.ttydevice && (get_ufwd(call)[0] || isforwardpartner(call) >= 0)) { putf(ms(m_startphonefwd), call, nummer); sprintf(befbuf, "%s TTY %s", call, nummer); fork(P_BACK | P_MAIL, 0, fwdsend, befbuf); } else putf(ms(m_nottyactive)); } else putf("Syntax: TTYDIAL <call> <number>\n"); } break; case ttyhangup: { tty_hangup(); putf(ms(m_hangupmodem)); } break; case ttystatus: { tty_statustext(); putv(LF); } break; case ttywin_: { fork(P_WIND | P_MAIL, 0, tty_win, befbuf); } break; case ttycounterreset: { tty_counterreset(); putv(LF); } break; #endif #ifdef _FILEFWD case fwdimport: { if (*befbuf) fwd_import(befbuf); } break; case fwdexport: { if (*befbuf) fwd_export(befbuf); } break; #endif case ymbtest: { #ifdef _USERCOMP if (u->comp == 1) { /* char output[256] = { 0 }; char output2[256] = { 0 }; int i, il = 0; */ putf("//COMP 1\n\n"); putflush(); /* il = comp_sp_stat_huff(befbuf, strlen(befbuf), output); // printf("il: %d strlen: %d\n",il,strlen(befbuf)); // printf("befbuf:\n-%s-\nOut:\n-%s-\n",befbuf,output); //putflush(); for (i = 1; i < il ; i++) bputv(output[i]); putv(LF); putflush(); output[0] = '\0'; strcpy(befbuf, "dies ist noch ein laengerer text 2"); il = comp_sp_stat_huff(befbuf, strlen(befbuf), output); for (i = 1; i < il ; i++) bputv(output[i]); putv(LF); putflush(); output[0] = '\0'; strcpy(befbuf, "dies ist ein noch laengerer text 3"); il = comp_sp_stat_huff(befbuf, strlen(befbuf), output); for (i = 1; i < il ; i++) bputv(output[i]); putv(LF); putflush(); putf("\n"); il = decomp_sp_stat_huff(output, strlen(output), output2); printf("il: %d strlen: %d\n",il,strlen(output)); printf("Out2:\n-%s-\n",output2); */ /* #include "ahuf.h" // TOP-Huffman class AHUF; AHUF *ahuf; ahuf = new AHUF(); il = ahuf->Komprimieren(true, befbuf, output, strlen(befbuf) ); printf("il: %d strlen: %d\n",il,strlen(befbuf)); printf("befbuf:\n-%s-\nOut:\n-%s-\n",befbuf,output); putflush(); putf("%s",output); putflush(); putf("\n"); */ } #endif } break; } return OK;
void mbhelp_t::dohelp (char *subject) //************************************************************************* // //************************************************************************* { unsigned int i = 0; long seekpos = 0; int helpall = ! stricmp(subject, "ALL"); int found = 0; char idx[20]; char *subsubject = strchr(subject, ' '); char *mlink = NULL; char *sublink = NULL; char linkstr[40]; char sublinkstr[40]; int linkcnt = 0; char oldsubject[60]; strcpy(linkstr, ""); strcpy(sublinkstr, ""); strcpy(oldsubject, ""); strcpy(idx, "INDEX"); helpf = NULL; idxf = NULL; if (! subsubject) subsubject = strchr(subject, '.'); if (subsubject) *subsubject++ = 0; if (! *subject) subject = "HELP"; if (! helpopen(ms(m_helpext))) { if (! helpopen("GB")) { if (! helpopen("DL")) { putf(ms(m_nohelp)); trace(serious, "dohelp", ms(m_nohelp)); return; } } } if (strstr(idx, subject) == idx) { putf(ms(m_helpkeywords)); while (fscanf(idxf, "%s %ld", inbuf, &seekpos) == 2) { subst1(inbuf, '=', 0); if (! subsubject || strstr(inbuf, subsubject) == inbuf) { #ifdef __FLAT__ if (! strcmp(b->uplink, "HTTP")) html_putf("<a href=\"/cmd?cmd=h+%s\">%-19s</a>", inbuf, inbuf); else #endif putf("%-19s", inbuf); i++; if (! (i % 4)) putv(LF); else putv(' '); } } putv(LF); } else { while (fscanf(idxf, "%s %ld\n", inbuf, &seekpos) == 2) { if (strstr(inbuf, subject) == inbuf || helpall) { if (subsubject && ! helpall) { char *dot = strchr(inbuf, '.'); if (dot) { dot++; if (strstr(dot, subsubject) != dot) continue; } else continue; } mlink = strchr(inbuf, '='); if (mlink) { if (helpall) continue; *mlink = 0; mlink++; strcpy(linkstr, mlink); sublink = strchr(linkstr, '.'); sprintf(oldsubject, "%s -> ", inbuf); if (sublink) { *sublink = 0; strcpy(sublinkstr, sublink + 1); subsubject = sublinkstr; } else subsubject = NULL; subject = linkstr; rewind(idxf); fgets(inbuf, LINELEN, idxf); // skip first line containing filetime if (++linkcnt > 10) { trace(serious, "help", "cyclic link %s.%s", subject, subsubject); break; } continue; } found++; subst1(inbuf, '.', ' '); subst1(oldsubject, '.', ' '); putv(LF); charstr(strlen(inbuf) + 6 + strlen(oldsubject), ':'); putf(":: %s%s ::", oldsubject, inbuf); putv(LF); charstr(strlen(inbuf) + 6 + strlen(oldsubject), ':'); fseek(helpf, seekpos, SEEK_SET); while (fgets(inbuf, LINELEN, helpf)) { if (*inbuf == '\\' && inbuf[1] == '\\') break; putf("%s", inbuf); if (b->abbruch) break; } if (! helpall) break; } if (b->abbruch) break; } //testabbruch(); if (! found) putf(ms(m_helpnotfound), subject, subsubject ? subsubject : "*"); } }
int autohadr (char *call, int ausgabe) //************************************************************************* // // Search for address in HADR database // //************************************************************************* { lastfunc("autohadr"); int pos; int i; bitfeld options = b->optplus; int which = -1; hadr_t *ha = (hadr_t*) t_malloc(sizeof(hadr_t), "hadr"); if (m.hadrstore) { strupr(call); hadr_tryopen(); pos = loadhadr(call, ha, 0); uclose(); if (pos) { which = which_partner(call, ha); if (ausgabe && (options & o_a)) { time_t mindelay = ad_time(); time_t mtime = ad_time(); putf("Forward data from HADR-entry:\n"); putf("H-Addr : %s\n", ha->adr); putf("R-Header : %s\n", ha->lastheader); putf("Last BID : %s\n", ha->lastbid); putf("Last Board : %s\n", ha->lastboard); putf("Last User : %s\n", ha->lastuser); putf("Header Date: %s\n", datestr(ha->lasthtime, 12)); if (*ha->sysopcall) putf("Sysop: %s %s\n", ha->sysopcall, get_name(ha->sysopcall, 1)); if (*ha->protocol && *ha->hwaddress) putf("HW-Address: %s: %s\n", ha->protocol, ha->hwaddress); if (ha->bversion && *ha->bstatus && ha->lastwprcvd) putf("BVersion: %ld %s (%s)\n", ha->bversion, ha->bstatus, datestr(ha->lastwprcvd, 12)); putf("Bulletins : %ld\n", ha->bulletins); putf("Usermails : %ld\n", ha->usermails); putf("Neighbour Count Update +Delay Hops\n"); for (i = 0; i < ADJNUM; i++) { if (ha->adjacent[i][0]) { if (ha->delay[i] < mindelay) mindelay = ha->delay[i]; } } for (i = 0; i < ADJNUM; i++) { // Ausgabe HADR-Eintrag if (ha->adjacent[i][0]) { putf("%-9s%6d%7s%7s%5d", ha->adjacent[i], ha->rel_mails[i], zeitspanne(mtime - ha->lastupdate[i], zs_seconds), zeitspanne(ha->delay[i] - mindelay, zs_seconds), ha->hops[i]); if (i == which) putf(" <"); if (isforwardpartner(ha->adjacent[i]) == NOTFOUND) putf(" fwd terminated"); putv(LF); } } putv(LF); } } } if (which != NOTFOUND) strcpy(b->destboxlist, ha->adjacent[which]); t_free(ha); if (which == NOTFOUND) return unbekannt; return auto_bekannt; }
void cfgflex (char * befbuf) //************************************************************************* // // cfgflex // //************************************************************************* { int a, i; int promptz = 0; // Zaehler der Nodeprompts char fn[20]; // Dateiname des Configfiles char fo[20]; // Dateiname des Antwortfiles char ziel[30]; // Nodecall char line[255]; // Noderueckgabe strcpy(fn, "cfgflex.bcm"); strcpy(fo, "cfgflex.out"); strncpy(ziel, befbuf, 29); ziel[29] = 0; trace(report, "cfgflex", "connect %s", ziel); timeout(1); lastcmd("Connect"); if (makeconnect(m.mycall[1], ziel)) { setsession(); *b->logincall = 0; if (filetime(fn)) { trace(report, "cfgflex", "sending %s", fn); FILE *f = s_fopen(fn, "lrt"); lastcmd("TX cfg_file"); while ((a = fgetc(f)) != EOF) { getclear_tnc(); timeout(1); waitfor(e_ticsfull); putv(a); if (a == LF) promptz++; // zaehlt prompts vorwaerts } putv(LF); putv(LF); s_fclose(f); trace(report, "cfgflex", "receive %s", fo); // speichert Rueckgaben FILE *g = s_fopen(fo, "lwt"); lastcmd("RX cfg_result"); if (g) // JJ { while (promptz > 0) { getline(line, BUFLEN - 1, 1); if (! strncmp(line, "=>", 2)) promptz--; // zaehlt prompts rueckwaerts if (! strncmp(line, "***", 3)) promptz = 0; // link failure fprintf(g, "%s", line); fputc(LF, g); } } s_fclose(g); } lastcmd("Delay"); for (i = 0; i < 100; i++) { wdelay(226); getclear_tnc(); } mblogout(0); mbdisconnect(1); // wait for data to be sent } }