/* -------------------------------------------------------------------- */ dumpf(char *filename) { FILE *fbuf; char line[MAXWORD]; int returnval = TRUE; /* last itteration might have been N>exted */ outFlag = OUTOK; setio(whichIO, echo, outFlag); doCR(); if ( (fbuf = fopen(filename, "r")) == NULL) { mPrintf(" No helpfile %s", filename); return(ERROR); } /* looks like a kludge, but we need speed!! */ while ( fgets(line, MAXWORD, fbuf) && (outFlag != OUTNEXT) && (outFlag != OUTSKIP) && !mAbort(FALSE) ) { mFormat(line); } if ( outFlag == OUTSKIP) returnval = ERROR; fclose(fbuf); return returnval; }
/* -------------------------------------------------------------------- */ void echocharacter(char c) { setio(whichIO, echo, outFlag); if (echo == NEITHER) { if (echoChar != '\0') { echo = BOTH; if (c == '\b') doBS(); else if (c == '\t') doTAB(); else if (c == '\n') { echo = CALLER; doCR(); } else oChar(echoChar); echo = NEITHER; } } else if (c == '\b') doBS(); else if (c == '\n') doCR(); else oChar(c); }
/* -------------------------------------------------------------------- */ void doCR(void) { static numLines = 0; do_idle(0); /* clear idle display */ crtColumn = 1; setio(whichIO, echo, outFlag); domcr(); doccr(); if (printing) fprintf(printfile, "\n"); prevChar = ' '; /* pause on full screen */ if (logBuf.linesScreen) { if (outFlag == OUTOK) { numLines++; if (numLines == logBuf.linesScreen) { outFlag = OUTPAUSE; mAbort(); numLines = 0; } } else { numLines = 0; } } else { numLines = 0; } }
/* -------------------------------------------------------------------- */ int dump(char *filename) { FILE *fbuf; int c, returnval = TRUE; /* last itteration might have been N>exted */ outFlag = OUTOK; setio(whichIO, echo, outFlag); doCR(); if ( (fbuf = fopen(filename, "r")) == NULL) { mPrintf(" No file %s", filename); return(ERROR); } /* looks like a kludge, but we need speed!! */ while ( (c = getc(fbuf) ) != ERROR && (c != 26 /* CPMEOF */ ) && (outFlag != OUTNEXT) && (outFlag != OUTSKIP) && !mAbort(FALSE) ) { if (c == '\n') doCR(); else oChar((char)c); } if ( outFlag == OUTSKIP) returnval = ERROR; fclose(fbuf); return returnval; }
logfunctions::logfunctions(iofunc_t *iofunc) { prefix = NULL; put(" "); settype(GENLOG); setio(iofunc); // BUG: unfortunately this can be called before the bochsrc is read, // which means that the bochsrc has no effect on the actions. for (int i=0; i<N_LOGLEV; i++) onoff[i] = get_default_action(i); }
/* -------------------------------------------------------------------- */ void tutorial(char *filename) { int i; char temp[14]; char oldverbose; outFlag = OUTOK; setio(whichIO, echo, outFlag); if (!expert) mPrintf("\n <3J0>ump <3N0>ext <3P0>ause <3S0>top\n"); /* doCR(); */ if (changedir(cfg.helppath) == -1 ) return; /* no bad files */ if (checkfilename(filename, 0) == ERROR) { mPrintf(" No helpfile %s", filename); changedir(cfg.homepath); return; } if (ambig(filename)) { /* fill our directory array according to filename */ oldverbose = verbose; verbose = FALSE; filldirectory(filename); verbose = oldverbose; /* print out all the files */ for (i = 0; filedir[i].entry[0] && ( dumpf(filedir[i].entry) != ERROR) ; i++); if ( !i) mPrintf(" No helpfile %s", filename); /* free file directory structure */ if(filedir != NULL) _ffree((void *)filedir); } else { strcpy(temp, filename); temp[strlen(temp)-1] = '@'; if (filexists(temp) && *term.bold) dump(temp); else dumpf(filename); } /* go to our home-path */ changedir(cfg.homepath); }
logfunctions::logfunctions(void) { prefix = NULL; put(" "); settype(GENLOG); if (io == NULL && Allocio == 0) { Allocio = 1; io = new iofunc_t(stderr); } setio(io); // BUG: unfortunately this can be called before the bochsrc is read, // which means that the bochsrc has no effect on the actions. for (int i=0; i<N_LOGLEV; i++) onoff[i] = get_default_action(i); }
/* -------------------------------------------------------------------- */ void putWord(char *st) { char *s; int newColumn; setio(whichIO, echo, outFlag); /* calculate word end */ for (newColumn = crtColumn, s = st; *s; s++) { if (*s == '\t') while ((++newColumn % 8) != 1); else if (*s == 1) --newColumn; /* don't count ANSI codes */ else if (*s > ' ') /* don't count what we don't print */ ++newColumn; } if (newColumn >= gl_term.termWidth) /* Wrap words that don't fit */ doCR(); for (; *st; ++st) { /* check for Ctrl-A codes */ if (*st == 1) { if (*++st) { /* must have something after ^A */ termCap(*st); continue; } else { break; } } /* worry about words longer than a line: */ if (crtColumn > gl_term.termWidth) doCR(); if ((prevChar != '\n') || (*st > ' ')) { oChar(*st); } else { /* end of paragraph: */ if (outFlag == OUTPARAGRAPH) { outFlag = OUTOK; } doCR(); oChar(*st); } } }
/* -------------------------------------------------------------------- */ void dospCR(void) { char oldecho; oldecho = echo; echo = BOTH; setio(whichIO, echo, outFlag); if (cfg.nopwecho == 1) doCR(); else { if (onConsole) { if (gotCarrier()) domcr(); } else doccr(); } echo = oldecho; }
static void parseWeatherData(char **fields, int count) { char setioVarName[50]; if (DEBUG_LEVEL > 0 ) printf("weatherservice [INFO]: Getting forecast for +%s hour ,received %d elements\n", fieldStart[0], count); int i = 0; if (count == 15) { int offset = atoi(fields[0]); if ( offset == 0 ) { int timestamp = getcurrenttime(); int timestamp_real = atoi(fields[1]); setweatherdata(22, timestamp, timestamp); setweatherdata(23, timestamp, timestamp_real); } else { int timestamp = atoi(fields[1]); } // FIELD | NAME | WeatherID | // ------+---------------------+-----------+ // 0 | offset | | // 1 | epoch | | // 2 | temp_c | 1 | // 3 | relative_humidity | 3 | // 4 | wind_dir | | // 5 | wind_degrees | 5 | // 6 | wind_kph | 4 | // 7 | wind_gust_kph | 6 | // 8 | pressure_mb | 11 | // 9 | dewpoint_c | 2 | // 10 | windchill_c | | // 11 | feelslike_c | 26 | // 12 | solarradiation | 27 , 7 | // 13 | precip_today_metric | 9 | // 14 | weathercode | 10 | // ------+---------------------+-----------+ if (*fields[2] != '\0') { setweatherdata(1, timestamp, atof(fields[2]) ); sprintf(setioVarName, "outsideTemp_offset_hour_%d", offset); setio(setioVarName, atof(fields[2])); } if (*fields[3] != '\0') { setweatherdata(3, timestamp, atof(fields[3]) ); } if (*fields[5] != '\0') { setweatherdata(5, timestamp, atof(fields[5]) ); } if (*fields[6] != '\0') { setweatherdata(4, timestamp, atof(fields[6]) ); } if (*fields[7] != '\0') { setweatherdata(6, timestamp, atof(fields[7]) ); } if (*fields[8] != '\0') { setweatherdata(11, timestamp, atof(fields[8]) ); } if (*fields[9] != '\0') { setweatherdata(2, timestamp, atof(fields[9]) ); } if (*fields[11] != '\0') { setweatherdata(26, timestamp, atof(fields[11]) ); } if (*fields[12] != '\0') { setweatherdata(7, timestamp, atof(fields[12]) ); setweatherdata(27, timestamp, atof(fields[12]) ); sprintf(setioVarName, "solar_radiation_offset_hour_%d", offset); setio(setioVarName, atof(fields[12])); } if (*fields[13] != '\0') { setweatherdata(9, timestamp, atof(fields[13]) ); } if (*fields[14] != '\0') { setweatherdata(10, timestamp, atof(fields[14]) ); } } else { printf("Only received %d items", count); } }
/* -------------------------------------------------------------------- */ void Readlog(BOOL revOrder) { int i, grpslot; char dtstr[80]; char flags[11]; char wild=FALSE; char buser=FALSE; char step; grpslot = ERROR; if (mf.mfUser[0]) { getNormStr("user", mf.mfUser, NAMESIZE, ECHO); stripansi(mf.mfUser); if (personexists(mf.mfUser) == ERROR) { if( strpos('?',mf.mfUser) || strpos('*',mf.mfUser) || strpos('[',mf.mfUser)) { wild = TRUE; } else { mPrintf(" \nNo such user!\n "); return; } } else { buser = TRUE; } } outFlag = OUTOK; setio(whichIO, echo, outFlag); if (mf.mfLim && (cfg.readluser || sysop || aide)) { doCR(); getgroup(); if (!mf.mfLim) return; grpslot = groupexists(mf.mfGroup); } else { mf.mfLim = FALSE; } outFlag = OUTOK; setio(whichIO, echo, outFlag); if (!expert) mPrintf(" \n \n <3J0>ump <3N0>ext <3P0>ause <3S0>top"); if (!revOrder) { step = 1; i = 0; } else { step = -1; i = cfg.MAXLOGTAB - 1; } for ( ; ( (i < cfg.MAXLOGTAB) && (outFlag != OUTSKIP) && (i >= 0) ); i += step) { if(mAbort(FALSE)) return; if (logTab[i].ltpwhash != 0 && logTab[i].ltnmhash != 0) { if (buser && (int)hash(mf.mfUser) != logTab[i].ltnmhash) continue; getLog(&lBuf,logTab[i].ltlogSlot); if (buser && strcmpi(mf.mfUser, lBuf.lbname) != SAMESTRING) continue; if(wild && !u_match(deansi(lBuf.lbname), mf.mfUser)) continue; if (mf.mfLim && (lBuf.groups[grpslot] != grpBuf.group[grpslot].groupgen) && (strcmpi(lBuf.lbname, cfg.sysop) != SAMESTRING ) ) continue; /* Show yourself even if unlisted */ if ( (!i && loggedIn) || (lBuf.lbflags.L_INUSE && (aide || !lBuf.lbflags.UNLISTED) ) ) { if (verbose) { strftime(dtstr, 79, (loggedIn) ? logBuf.vdstamp : cfg.vdatestamp, lBuf.calltime); if ((cfg.surnames || cfg.titles) && /* verbose >= 2 */ logBuf.DISPLAYTS) { doCR(); doCR(); if (*lBuf.title) mPrintf(" [%s]", lBuf.title); mPrintf(" 3%s0", lBuf.lbname); if (*lBuf.surname) mPrintf(" [%s]", lBuf.surname); doCR(); mPrintf(" #%lu %s", lBuf.callno, dtstr); } else { doCR(); mPrintf(" 3%-20s0 #%lu %s", lBuf.lbname, lBuf.callno, dtstr); } } else { doCR(); #if 1 if (aide || lBuf.lbflags.NODE) #endif mPrintf(" %-20s",lBuf.lbname); #if 1 else mPrintf(" %s", lBuf.lbname); #endif } if (aide ) /* A>ide T>wit P>erm U>nlist N>etuser S>ysop */ { if (cfg.accounting && verbose) { if (lBuf.lbflags.NOACCOUNT) mPrintf( " %10s", "N/A"); else mPrintf( " %10.2f", lBuf.credits); } strcpy(flags, " "); if ( lBuf.lbflags.AIDE) flags[0] = 'A'; if ( lBuf.lbflags.PROBLEM) flags[1] = 'T'; if ( lBuf.lbflags.PERMANENT) flags[2] = 'P'; if ( lBuf.lbflags.NETUSER) flags[3] = 'N'; if ( lBuf.lbflags.UNLISTED) flags[4] = 'U'; if ( lBuf.lbflags.SYSOP) flags[5] = 'S'; if ( lBuf.lbflags.NOMAIL) flags[6] = 'M'; if ( lBuf.VERIFIED) flags[7] = 'V'; if ( lBuf.DUNGEONED) flags[8] = 'D'; if ( lBuf.MSGAIDE) flags[9] = 'm'; mPrintf(" %s",flags); } if (lBuf.lbflags.NODE) { mPrintf(" (Node) "); } } #ifdef GOODBYE if (verbose) { strftime(dtstr, 79, (loggedIn) ? logBuf.dstamp : cfg.datestamp, lBuf.calltime); if ((cfg.surnames || cfg.titles) && logBuf.DISPLAYTS) { doCR(); mPrintf(" [%s] 3%s0 [%s]", lBuf.title, lBuf.lbname, lBuf.surname); doCR(); mPrintf(" #%lu %s", lBuf.callno, dtstr); } else { doCR(); mPrintf(" 3%-20s0 #%lu %s", lBuf.lbname, lBuf.callno, dtstr); } } else { doCR(); mPrintf(" %-20s",lBuf.lbname); } if (aide ) /* A>ide T>wit P>erm U>nlist N>etuser S>ysop */ { if (cfg.accounting && verbose) { if (lBuf.lbflags.NOACCOUNT) mPrintf( " %10s", "N/A"); else mPrintf( " %10.2f", lBuf.credits); } strcpy(flags, " "); if ( lBuf.lbflags.AIDE) flags[0] = 'A'; if ( lBuf.lbflags.PROBLEM) flags[1] = 'T'; if ( lBuf.lbflags.PERMANENT) flags[2] = 'P'; if ( lBuf.lbflags.NETUSER) flags[3] = 'N'; if ( lBuf.lbflags.UNLISTED) flags[4] = 'U'; if ( lBuf.lbflags.SYSOP) flags[5] = 'S'; if ( lBuf.lbflags.NOMAIL) flags[6] = 'M'; if ( lBuf.VERIFIED) flags[7] = 'V'; if ( lBuf.DUNGEONED) flags[8] = 'D'; if ( lBuf.MSGAIDE) flags[9] = 'm'; mPrintf(" %s",flags); } if (lBuf.lbflags.NODE) { mPrintf(" (Node) "); } if (verbose) doCR(); } #endif } }
/* -------------------------------------------------------------------- */ void minibin(void) { int calls, messages; char dtstr[80]; char minutes[5]; /* messages = (int)(cfg.newest - logBuf.lbvisit[1]); */ messages = (int)(cfg.newest - logBuf.lastpointer); calls = (int)(cfg.callno - logBuf.callno); /* special hack to kill mangled surnames beacuse of the 3.10.05 to 3.11.00 conversion program... */ if (!tfilter[logBuf.surname[0]]) { logBuf.surname[0] = '\0' /*NULL*/; } if (!expert) mPrintf(" \n \n <3J0>ump <3N0>ext <3P0>ause <3S0>top"); doCR(); mPrintf("0Welcome back "); if (cfg.titles && logBuf.title[0] && logBuf.DISPLAYTS) { mPrintf("[%s] ", logBuf.title); } mPrintf("3%s0",logBuf.lbname); if (cfg.surnames && logBuf.surname[0] && logBuf.DISPLAYTS) { mPrintf(" [%s]", logBuf.surname); } mPrintf("!"); doCR(); if (calls == 0) { mPrintf("You were just here."); doCR(); } else if (calls == -1) { ; } else { strftime(dtstr, 79, (loggedIn) ? logBuf.vdstamp : cfg.vdatestamp, logBuf.calltime); mPrintf("You last called on: %s", dtstr); doCR(); mPrintf("You are caller %s", ltoac(cfg.callno + 1l)); doCR(); mPrintf("%d %s made", people, (people == 1)?"person has":"people have"); doCR(); mPrintf("%d %s and left",calls, (calls == 1)?"call":"calls"); doCR(); mPrintf("%s new %s since you were last here.",ltoac((long)messages), (messages==1)? cfg.msg_nym: cfg.msgs_nym); doCR(); } if (cfg.accounting && !logBuf.lbflags.NOACCOUNT) { if (!specialTime) { sprintf(minutes, "%.0f", logBuf.credits); mPrintf("You have %s minute%s left today.", minutes, (strcmp(minutes, "1") == SAMESTRING) ? "" : "s"); } else { mPrintf("You have unlimited time."); } doCR(); } outFlag = OUTOK; setio(whichIO, echo, outFlag); }
/* -------------------------------------------------------------------- */ void doLogin(char moreYet) { int foundIt; char InitPw[NAMESIZE+NAMESIZE+2]; char password[NAMESIZE+NAMESIZE+2]; char initials[NAMESIZE+NAMESIZE+2]; char *semicolon; Mflush(); if (!CARRIER) return; if (login_user || login_pw) /* handle command line log-ins */ { if (!modStat) if (cfg.offhook) offhook(); /* login using initials and pw */ if (login_pw) { normalizepw(cmd_login, initials, password); login_pw = FALSE; } else if (login_user) { normalizeString(cmd_login); if (findPerson(cmd_login, &logBuf) != ERROR) { strcpy(initials, logBuf.lbin); strcpy(password, logBuf.lbpw); } login_user = FALSE; } } else /* ask user for initials and password */ { if (moreYet == 2) moreYet = FALSE; else { /* dont print Login when hitting 'L' from console mode */ if (!(!moreYet && !loggedIn && !modStat)) { mPrintf("Login "); } } if (loggedIn) { mPrintf("\n Already logged in!\n "); return; } if (!modStat) if (cfg.offhook) offhook(); getNormStr((moreYet) ? "" : "your initials", InitPw, NAMESIZE+NAMESIZE+1, NO_ECHO); if (!CARRIER) return; dospCR(); semicolon = strchr(InitPw, ';'); if (!semicolon) { strcpy(initials, InitPw); getNormStr( "password", password, NAMESIZE, NO_ECHO); dospCR(); } else { normalizepw(InitPw, initials, password); } /* dont allow anything over 19 characters */ initials[NAMESIZE] = '\0'; } /* reset transmitted & received */ transmitted = 0l; received = 0l; /* reset read & entered */ mread = 0; entered = 0; foundIt = ((pwslot(initials, password)) != ERROR); if (foundIt && *password) { loggedIn = TRUE; update25(); /* trap it */ if (!logBuf.lbflags.NODE) { sprintf( msgBuf->mbtext, "Login %s", logBuf.lbname); if (onConsole) strcat(msgBuf->mbtext, " (Console)"); trap(msgBuf->mbtext, T_LOGIN); } else { sprintf( msgBuf->mbtext, "NetLogin %s", logBuf.lbname); trap(msgBuf->mbtext, T_NETWORK); } } else { loginNew(initials, password); } if (!loggedIn) return; heldMessage = FALSE; setsysconfig(); setgroupgen(); setroomgen(); setlbvisit(); slideLTab(thisSlot); /* cant log in now. */ if (cfg.accounting && !logBuf.lbflags.NOACCOUNT) { negotiate(); logincrement(); if (!logincheck()) { Hangup(); return; } } /* can't log in now. */ if (logBuf.VERIFIED && !onConsole) { tutorial("verified.blb"); Hangup(); return; } if (logBuf.lbflags.NODE) { #ifdef TRASH if (debug) { readnode(); cPrintf("Node: \"%s\" \"%s\"", node.ndname, node.ndregion); doccr(); cPrintf("Phone: \"%s\" %d", node.ndphone, node.nddialto); doccr(); cPrintf("Login: \"%s\" %d", node.ndlogin, node.ndwaitto); doccr(); cPrintf("Baud: %d Protocol: \"%s\"\n ", node.ndbaud, node.ndprotocol); cPrintf("Expire:%d Waitout: %d", node.ndexpire, node.ndwaitto); doccr(); cPrintf("Network: %d ZIP: %s UNZIP: %s", node.network, node.zip, node.unzip); doccr(); } #endif time(&logtimestamp); return; } if (logBuf.PSYCHO) { backout = TRUE; } /* reverse engineering Minibin?!?! */ if (logBuf.MINIBIN) { minibin(); } changedir(cfg.helppath); if ( filexists("bulletin.blb") ) { tutorial("bulletin.blb"); } gotodefaulthall(); roomtalley(); mf.mfLim = 0; /* just to make sure. */ mf.mfMai = 0; mf.mfPub = 0; mf.mfUser[0]=0; nochat(TRUE); /* reset chats */ /* verbose = FALSE; */ verbose = logBuf.VERBOSE; /* hmmm... where to put this */ if (roomBuf.rbflags.APLIC && roomBuf.rbflags.AUTOAPP ) ExeAplic(); showMessages(NEWoNLY, FALSE); verbose = FALSE; if (expert) listRooms(NEWRMS, FALSE); else listRooms(OLDNEW, FALSE); outFlag = OUTOK; setio(whichIO, echo, outFlag); /* record login time, date */ time(&logtimestamp); cfg.callno++; storeLog(); }