void sbbs_t::fileinfo(file_t* f) { char ext[513]; char tmp[512]; char path[MAX_PATH+1]; char fpath[MAX_PATH+1]; uint i,j; for(i=0;i<usrlibs;i++) if(usrlib[i]==cfg.dir[f->dir]->lib) break; for(j=0;j<usrdirs[i];j++) if(usrdir[i][j]==f->dir) break; getfilepath(&cfg,f,path); bprintf(text[FiLib],i+1,cfg.lib[cfg.dir[f->dir]->lib]->lname); bprintf(text[FiDir],j+1,cfg.dir[f->dir]->lname); bprintf(text[FiFilename],getfname(path)); SAFECOPY(fpath,path); fexistcase(fpath); if(strcmp(path,fpath) && strcmp(f->desc,getfname(fpath))) /* Different "actual" filename */ bprintf(text[FiFilename],getfname(fpath)); if(f->size!=-1L) bprintf(text[FiFileSize],ultoac(f->size,tmp)); bprintf(text[FiCredits] ,(cfg.dir[f->dir]->misc&DIR_FREE || !f->cdt) ? "FREE" : ultoac(f->cdt,tmp)); bprintf(text[FiDescription],f->desc); bprintf(text[FiUploadedBy],f->misc&FM_ANON ? text[UNKNOWN_USER] : f->uler); if(f->date) bprintf(text[FiFileDate],timestr(&f->date)); bprintf(text[FiDateUled],timestr(&f->dateuled)); bprintf(text[FiDateDled],f->datedled ? timestr(&f->datedled) : "Never"); bprintf(text[FiTimesDled],f->timesdled); if(f->size!=-1L) bprintf(text[FiTransferTime],sectostr(f->timetodl,tmp)); if(f->altpath) { if(f->altpath<=cfg.altpaths) { if(SYSOP) bprintf(text[FiAlternatePath],cfg.altpath[f->altpath-1]); } else bprintf(text[InvalidAlternatePathN],f->altpath); } CRLF; if(f->misc&FM_EXTDESC) { getextdesc(&cfg,f->dir,f->datoffset,ext); CRLF; putmsg(ext,P_NOATCODES); CRLF; } if(f->size==-1L) bprintf(text[FileIsNotOnline],f->name); if(f->opencount) bprintf(text[FileIsOpen],f->opencount,f->opencount>1 ? "s" : nulstr); }
void printfiledata(FILE *fd, char *fn, int domd5, int dosha1, int dormd160) { struct stat st; struct passwd *pw; struct group *gr; int staterror; char linknam[PATH_MAX]; time_t now = getcurrenttime(NULL); *linknam = '\0'; staterror = lstat(fn, &st); if ((staterror == 0) && S_ISLNK(st.st_mode)) { int n = readlink(fn, linknam, sizeof(linknam)-1); if (n == -1) n = 0; linknam[n] = '\0'; staterror = stat(fn, &st); } if (staterror == -1) { fprintf(fd, "ERROR: %s\n", strerror(errno)); } else { char *stsizefmt; pw = getpwuid(st.st_uid); gr = getgrgid(st.st_gid); fprintf(fd, "type:%o (%s)\n", (unsigned int)(st.st_mode & S_IFMT), ftypestr(st.st_mode, (*linknam ? linknam : NULL))); fprintf(fd, "mode:%o (%s)\n", (unsigned int)(st.st_mode & (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)), fmodestr(st.st_mode)); fprintf(fd, "linkcount:%d\n", (int)st.st_nlink); fprintf(fd, "owner:%u (%s)\n", (unsigned int)st.st_uid, (pw ? pw->pw_name : "")); fprintf(fd, "group:%u (%s)\n", (unsigned int)st.st_gid, (gr ? gr->gr_name : "")); if (sizeof(st.st_size) == sizeof(long long int)) stsizefmt = "size:%lld\n"; else stsizefmt = "size:%ld\n"; fprintf(fd, stsizefmt, st.st_size); fprintf(fd, "clock:%u (%s)\n", (unsigned int)now, timestr(now)); fprintf(fd, "atime:%u (%s)\n", (unsigned int)st.st_atime, timestr(st.st_atime)); fprintf(fd, "ctime:%u (%s)\n", (unsigned int)st.st_ctime, timestr(st.st_ctime)); fprintf(fd, "mtime:%u (%s)\n", (unsigned int)st.st_mtime, timestr(st.st_mtime)); if (S_ISREG(st.st_mode)) { if (domd5) fprintf(fd, "%s\n", filesum(fn, "md5")); else if (dosha1) fprintf(fd, "%s\n", filesum(fn, "sha1")); else if (dormd160) fprintf(fd, "%s\n", filesum(fn, "rmd160")); } } fprintf(fd, "\n"); }
bool CompareTime( const Options &opts, time_t val ) { bool ok; char b1[64], b2[64], b3[64]; if ( opts.isValueRange() ) { ok = ( ( val >= opts.getValue().asRange.minVal.asTime ) && ( val <= opts.getValue().asRange.maxVal.asTime ) ); if ( !ok && opts.getVerbose() ) { if ( opts.getNumeric() ) { printf( " %s: %lu not in %lu - %lu\n", opts.getField()->m_name, (unsigned long)val, (unsigned long)opts.getValue().asRange.minVal.asTime, (unsigned long)opts.getValue().asRange.maxVal.asTime ); } else { printf( " %s: %s not in %s - %s\n", opts.getField()->m_name, timestr( val, b1, sizeof(b1) ), timestr( opts.getValue().asRange.minVal.asTime, b2, sizeof(b2) ), timestr( opts.getValue().asRange.maxVal.asTime, b3, sizeof(b3) ) ); } } } else { ok = ( val == opts.getValue().asInt.asTime ); if ( !ok && opts.getVerbose() ) { if ( opts.getNumeric() ) { printf( " %s: %lu != %lu\n", opts.getField()->m_name, (unsigned long) val, (unsigned long) opts.getValue().asInt.asTime ); } else { printf( " %s: %s != %s\n", opts.getField()->m_name, timestr( val, b1, sizeof(b1) ), timestr( opts.getValue().asRange.minVal.asTime, b2, sizeof(b2) ) ); } } } return ok; }
void sbbs_t::show_msghdr(smbmsg_t* msg) { char str[MAX_PATH+1]; char *sender=NULL; int i; attr(LIGHTGRAY); if(useron.misc&CLRSCRN) outchar(FF); else CRLF; sprintf(str,"%smenu/msghdr.*", cfg.text_dir); if(fexist(str)) { menu("msghdr"); return; } bprintf(text[MsgSubj],msg->subj); if(msg->hdr.attr) show_msgattr(msg->hdr.attr); bprintf(text[MsgTo],msg->to); if(msg->to_ext) bprintf(text[MsgToExt],msg->to_ext); if(msg->to_net.addr) bprintf(text[MsgToNet],smb_netaddrstr(&msg->to_net,str)); if(!(msg->hdr.attr&MSG_ANONYMOUS) || SYSOP) { bprintf(text[MsgFrom],msg->from); if(msg->from_ext) bprintf(text[MsgFromExt],msg->from_ext); if(msg->from_net.addr && !strchr(msg->from,'@')) bprintf(text[MsgFromNet],smb_netaddrstr(&msg->from_net,str)); } bprintf(text[MsgDate] ,timestr(msg->hdr.when_written.time) ,smb_zonestr(msg->hdr.when_written.zone,NULL)); CRLF; for(i=0;i<msg->total_hfields;i++) { if(msg->hfield[i].type==SENDER) sender=(char *)msg->hfield_dat[i]; if(msg->hfield[i].type==FORWARDED && sender) bprintf(text[ForwardedFrom],sender ,timestr(*(time32_t *)msg->hfield_dat[i])); } CRLF; }
void print_svrstat(const struct svrstat_st* ss, int indent) { time_t boottime = from_nettime(ss->nt_boottime); char s_boottime[TIME_STRLEN] = { 0 }; timestr(&boottime, s_boottime, sizeof s_boottime); char s_uuid[UUID_STRLEN] = { 0 }; uuid_unparse(ss->uuid, s_uuid); char tabs[indent + 1]; ljbx_str_repeat('\t', indent, tabs, sizeof tabs); fprintf(stderr, "%s .boottime = %ld (%s)\n" "%s .seqno = %u\n" "%s .uuid = %s\n" "%s .loadavg = %d\n" , tabs, boottime, s_boottime , tabs, ss->seqno , tabs, s_uuid , tabs, ss->loadavg ); }
static void report_stderr(const int fatal, const char *str) { char e[300]; e[0] = '\0'; #define REVERSE_VIDEO_ERRORS #ifdef REVERSE_VIDEO_ERRORS snprintf(e+strlen(e), sizeof(e)-strlen(e), "\x1b[7m"); /* reverse video */ #endif snprintf(e+strlen(e), sizeof(e)-strlen(e), "[%s] ", timestr()); snprintf(e+strlen(e), sizeof(e)-strlen(e), "%s", str); #ifdef REVERSE_VIDEO_ERRORS snprintf(e+strlen(e), sizeof(e)-strlen(e), "\x1b[0m"); /* reset */ #endif fflush(stdout); fflush(stderr); fprintf(stderr, "%s\n", e); fflush(stderr); if (fatal) { fprintf(stderr, "<terminating after fatal error>\n"); report_creat_quitfile(); #ifdef FATAL_ASSERT fflush(stderr); assert(0); #endif exit(1); } }
void report_start(int argc, char *argv[]) { char cline[1024], hostname[64]; int i; if (gettimeofday(&start_tv, NULL) < 0) { report_perror(FATAL, "gettimeofday"); return; } if (gethostname(hostname, sizeof(hostname)) < 0) { report_perror(FATAL, "gethostname"); return; } cline[0] = '\0'; for (i=0 ; i<argc ; i++) { strncat(cline, argv[i], sizeof(cline) - strlen(cline)); if (i < argc - 1) { strncat(cline, " ", sizeof(cline) - strlen(cline)); } } fprintf(stdout, "[%s] START host \"%s\" command line \"%s\"\n", timestr(), hostname, cline); fflush(stdout); }
bool GtkGraph::on_button_press_event(GdkEventButton *event) { if(event->button == 3) // if right-click { std::stringstream option(gt::Settings::settings["GraphIntervals"]); std::vector<unsigned> intervals; do { unsigned tmp; option >> tmp; intervals.push_back(tmp); }while(!option.eof()); Gtk::Menu *rcMenu = Gtk::manage(new Gtk::Menu()); std::vector<Gtk::MenuItem*> rcItems; rcItems.resize(intervals.size()); for(unsigned i = 0;i<intervals.size();++i) { rcItems[i] = Gtk::manage(new Gtk::MenuItem(timestr(intervals[i]))); rcItems[i]->signal_activate().connect([this,i,intervals](){m_displaySize = intervals[i];}); rcMenu->add(*(rcItems[i])); } rcMenu->show_all(); rcMenu->popup(event->button, event->time); }
extern "C" BOOL DLLCALL hacklog(scfg_t* cfg, char* prot, char* user, char* text, char* host, SOCKADDR_IN* addr) { char hdr[1024]; char tstr[64]; char fname[MAX_PATH+1]; int file; time32_t now=time32(NULL); sprintf(fname,"%shack.log",cfg->logs_dir); if((file=sopen(fname,O_CREAT|O_RDWR|O_BINARY|O_APPEND,SH_DENYWR,DEFFILEMODE))==-1) return(FALSE); sprintf(hdr,"SUSPECTED %s HACK ATTEMPT for user '%s' on %.24s\r\nUsing port %u at %s [%s]\r\nDetails: " ,prot ,user ,timestr(cfg,now,tstr) ,addr->sin_port ,host ,inet_ntoa(addr->sin_addr) ); write(file,hdr,strlen(hdr)); write(file,text,strlen(text)); write(file,crlf,2); write(file,crlf,2); close(file); return(TRUE); }
/** * Log a message to monits logfile or syslog. * @param s A formated (printf-style) string to log */ void log_log(const char *s, ...) { long len; va_list ap; char *msg= NULL; ASSERT(s); va_start(ap,s); msg= format(s, ap, &len); va_end(ap); if(! Run.dolog) goto nolog; if(Run.use_syslog) { LOCK(log_mutex) syslog(LOG_ERR, "%s", msg); END_LOCK; } else if(LOG) { LOCK(log_mutex) fprintf(LOG,"[%s] %s", timestr(), msg); END_LOCK; } nolog: LOCK(log_mutex) fprintf(stderr, "%s", msg); fflush(stderr); END_LOCK; FREE(msg); }
void sbbs_t::telluser(smbmsg_t* msg) { char str[256]; uint usernumber,n; node_t node; if(msg->from_net.type) return; if(msg->from_ext) usernumber=atoi(msg->from_ext); else { usernumber=matchuser(&cfg,msg->from,TRUE /*sysop_alias*/); if(!usernumber) return; } for(n=1;n<=cfg.sys_nodes;n++) { /* Tell user */ getnodedat(n,&node,0); if(node.useron==usernumber && (node.status==NODE_INUSE || node.status==NODE_QUIET)) { sprintf(str ,text[UserReadYourMailNodeMsg] ,cfg.node_num,useron.alias); putnmsg(&cfg,n,str); break; } } if(n>cfg.sys_nodes) { now=time(NULL); sprintf(str,text[UserReadYourMail] ,useron.alias,timestr(now)); putsmsg(&cfg,usernumber,str); } }
/***************************************************************** ** printserial() *****************************************************************/ static void printserial (const char *fname, unsigned long serial) { if ( fname && *fname ) printf ("%-30s\t", fname); printf ("%10lu", serial); /* try to guess the soa serial format */ if ( serial < 1136070000L ) /* plain integer (this is 2006-1-1 00:00 in unixtime format) */ ; else if ( serial > 2006010100L ) /* date format */ { int y, m, d, v; v = serial % 100; serial /= 100; d = serial % 100; serial /= 100; m = serial % 100; serial /= 100; y = serial; printf ("\t%d-%02d-%02d Version %02d", y, m, d, v); } else /* unixtime */ printf ("\t%s\n", timestr (serial) ); printf ("\n"); }
static void setwakeup(void) { register Seconds_t t; register Seconds_t now; int level; now = CURSECS; if (!trap.alarms) t = 0; else if (trap.alarms->time <= now) t = 1; else t = trap.alarms->time - now; alarm(t); sfsprintf(tmpname, MAXNAME, "%lu", t ? (now + t) : t); setvar(internal.alarm->name, fmtelapsed(t, 1), 0); if (error_info.trace <= (level = (state.test & 0x00010000) ? 2 : CMDTRACE)) { register Alarms_t* a; if (a = trap.alarms) { error(level, "ALARM TIME RULE"); do { error(level, "%6s %s %s", fmtelapsed((a->time >= now) ? (a->time - now) : 0, 1), timestr(tmxsns(a->time, 0)), a->rule->name); } while (a = a->next); } else error(level, "ALARM -- NONE"); } }
static void print_v(int nspec) { struct link *l; for (l = vcpus; l != NULL; l = l->l_next) { struct vcpu *v = l->l_ptr; if ((nspec != 0) && (!v->v_doit)) continue; (void) printf(_("Status of virtual processor %d as of: "), l->l_id); (void) printf("%s\n", timestr(time(NULL))); (void) printf(_(" %s since %s.\n"), _(v->v_state), timestr(v->v_state_begin)); if (v->v_clock_mhz) { (void) printf( _(" The %s processor operates at %llu MHz,\n"), v->v_cpu_type, (unsigned long long)v->v_clock_mhz); } else { (void) printf( _(" The %s processor operates at " \ "an unknown frequency,\n"), v->v_cpu_type); } switch (*v->v_fpu_type) { case '\0': (void) printf( _("\tand has no floating point processor.\n")); break; case 'a': case 'A': case 'e': case 'E': case 'i': case 'I': case 'o': case 'O': case 'u': case 'U': case 'y': case 'Y': (void) printf( _("\tand has an %s floating point processor.\n"), v->v_fpu_type); break; default: (void) printf( _("\tand has a %s floating point processor.\n"), v->v_fpu_type); break; } } }
str siglog_startup_msg () { strbuf msg; str tm = single_char_sub (timestr (), ':', "."); msg << "sfsauthd restarted: " << tm << "\n"; return msg; }
void sbbs_t::logentry(const char *code, const char *entry) { char str[512]; now=time(NULL); sprintf(str,"Node %2d %s\r\n %s",cfg.node_num,timestr(now),entry); logline(code,str); }
void BSSGWriteLowSide(NSMsg *ulmsg) { if (gBSSG.mbsTestQ) { // For testing, deliver messages to this queue instead: gBSSG.mbsTestQ->write(ulmsg); } else { GPRSLOG(1) << "BSSG ===> writelowside " <<ulmsg->str()<<timestr(); gBSSG.mbsTxQ.write(ulmsg); // normal mode; block is headed for the SGSN. } }
int main() { welcome(); printf("2011:%d, 2012:%d\n",isleap(2011),isleap(2012)); printf("soft01:%d\n", getid("soft01")); time_t now = time(NULL); printf("time:%s\n",timestr(localtime(&now))); char buf[100]; printf("1234543:%s\n", itoa(1234543,buf,sizeof(buf))); return 0; }
str authclnt::siglogline (const sfsauth2_sign_arg &arg, const str &uname) { str req = xdr2str (arg); if (!req) return NULL; req = armor64 (req); str tm = single_char_sub (timestr (), ':', "."); strbuf line; line << "SIGN:" << uname << ":" << client_name << ":" << tm << ":" << req << "\n"; return line; }
void *miniGgsnReadServiceLoop(void *arg) { Ggsn *ggsn = (Ggsn*)arg; sethighpri(); while (ggsn->active()) { struct pollfd fds[1]; fds[0].fd = tun_fd; fds[0].events = POLLIN; fds[0].revents = 0; // being cautious // We time out occassionally to check if the user wants to shut the sgsn down. MGINFO("ggsn: polling at %s",timestr().c_str()); if (-1 == poll(fds,1,ggsn->mStopTimeout)) { SGSNERROR("ggsn: poll failure"); return 0; } MGINFO("ggsn: polling %0x at %s",fds[0].revents,timestr().c_str()); if (fds[0].revents & POLLIN) { miniggsn_handle_read(); } } return 0; }
extern "C" int DLLCALL errorlog(scfg_t* cfg, const char* host, const char* text) { FILE* fp; char buf[128]; char path[MAX_PATH+1]; sprintf(path,"%serror.log",cfg->logs_dir); if((fp=fnopen(NULL,path,O_WRONLY|O_CREAT|O_APPEND))==NULL) return -1; fprintf(fp,"%s %s\r\n%s\r\n\r\n", timestr(cfg,time32(NULL),buf), host==NULL ? "":host, text); fclose(fp); return 0; }
const string MessageLog::format(const Message& msg, const char prefix) { ostringstream oss; oss << timestr() << " |" << fLogData.fSessionID << '|' << fLogData.fTxnID << '|' << fLogData.fThdID << "| " << prefix << ' ' << setw(2) << setfill('0') << fLogData.fSubsysID << ' ' << msg.msg() ; return escape_pct(oss.str()); }
void report_stop(int print_rusage) { float usertime, systemtime, totaltime; struct timeval end_tv; struct rusage rusage; if (gettimeofday(&end_tv, NULL) < 0) { report_perror(FATAL, "gettimeofday"); return; } if (getrusage(RUSAGE_SELF, &rusage) == -1) { report_perror(FATAL, "getrusage"); return; } fprintf(stdout, "[%s] STOP\n", timestr()); fflush(stdout); if (!print_rusage) { return; } totaltime = (float)(end_tv.tv_sec - start_tv.tv_sec) + (float)(end_tv.tv_usec - start_tv.tv_usec)/1000000.0; usertime = (float)rusage.ru_utime.tv_sec + ((float)rusage.ru_utime.tv_usec)/1000000.0; systemtime = (float)rusage.ru_stime.tv_sec + ((float)rusage.ru_stime.tv_usec)/1000000.0; printf(">>> real(s): %9.2f\n", totaltime); printf(">>> user(s): %9.2f (%0.2f%%)\n", usertime, 100.0*usertime/totaltime); printf(">>> sys(s): %9.2f (%0.2f%%)\n", systemtime, 100.0*systemtime/totaltime); printf(">>> \"idle\"(s): %9.2f (%0.2f%%)\n", totaltime-(usertime+systemtime), 100.0*(totaltime-(usertime+systemtime))/totaltime); printf(">>> maximal resident set size(KB): %7ld\n", rusage.ru_maxrss); printf(">>> integral resident set size: %7ld\n", rusage.ru_idrss); printf(">>> page faults not requiring I/O: %7ld\n", rusage.ru_minflt); printf(">>> page faults requiring I/O: %7ld\n", rusage.ru_majflt); printf(">>> swaps: %7ld\n", rusage.ru_nswap); printf(">>> input operations: %7ld\n", rusage.ru_inblock); printf(">>> output operations: %7ld\n", rusage.ru_oublock); printf(">>> msgsnd operations: %7ld\n", rusage.ru_msgsnd); printf(">>> msgrcv operations: %7ld\n", rusage.ru_msgrcv); printf(">>> signals handled: %7ld\n", rusage.ru_nsignals); printf(">>> voluntary context switches: %7ld\n", rusage.ru_nvcsw); printf(">>> involuntary context switches: %7ld\n", rusage.ru_nivcsw); }
static void print_normal(int nspec) { struct link *l; struct vcpu *v; for (l = vcpus; l != NULL; l = l->l_next) { v = l->l_ptr; if ((nspec == 0) || (v->v_doit)) { (void) printf(_("%d\t%-8s since %s\n"), l->l_id, _(v->v_state), timestr(v->v_state_begin)); } } }
unsigned char *miniggsn_rcv_npdu(int *plen, uint32_t *dstaddr) { static unsigned char *recvbuf = NULL; if (recvbuf == NULL) { recvbuf = (unsigned char*)malloc(ggConfig.mgMaxPduSize+2); if (!recvbuf) { /**error = -ENOMEM;*/ return NULL; } } // The O_NONBLOCK was set by default! Is not happening any more. { int flags = fcntl(tun_fd,F_GETFL,0); if (flags & O_NONBLOCK) { //MGDEBUG(4,"O_NONBLOCK = %d",O_NONBLOCK & flags); flags &= ~O_NONBLOCK; // Want Blocking! int fcntlstat = fcntl(tun_fd,F_SETFL,flags); MGWARN("ggsn: WARNING: Turning off tun_fd blocking flag, fcntl=%d",fcntlstat); } } // We can just read from the tunnel. int ret = read(tun_fd,recvbuf,ggConfig.mgMaxPduSize); if (ret < 0) { MGERROR("ggsn: error: reading from tunnel: %s", strerror(errno)); //*error = ret; return NULL; } else if (ret == 0) { MGERROR("ggsn: error: zero bytes reading from tunnel: %s", strerror(errno)); //*error = ret; // huh? return NULL; } else { struct iphdr *iph = (struct iphdr*)recvbuf; { char infobuf[200]; MGINFO("ggsn: received %s at %s",packettoa(infobuf,recvbuf,ret), timestr().c_str()); //MGLOGF("ggsn: received proto=%s %d byte npdu from %s for %s at %s", //ip_proto_name(iph->protocol), ret, //ip_ntoa(iph->saddr,nbuf), //ip_ntoa(iph->daddr,NULL), timestr()); } *dstaddr = iph->daddr; // TODO: Do we have to allocate a new buffer? *plen = ret; // Zero terminate for the convenience of the pinger. recvbuf[ret] = 0; return recvbuf; } }
void xChLogo(char n) { char logo[10]="XCHLOGO_"; int x=x_maxx()-150,y=0; if(fullscreen || customerscreen) return; #ifndef TEXTONLY if(arachne.GUIstyle==STYLE_SMALL1 || arachne.GUIstyle==STYLE_SMALL2) { if(n=='0') { int y=3; if(arachne.GUIstyle==STYLE_SMALL2) y=4; if(!user_interface.iconsoff) DrawIconNow( "ALTICON2",x_maxx()-146,y ); return; } sprintf(logo,"SMALOGO_"); x=x_maxx()-19; if(arachne.GUIstyle==STYLE_SMALL1) y=5; else y=6; if(n>'4' && n<'A')n-=4; } logo[7]=n; DrawIconNow( logo, x,y); if(ppplogtime && tcpip) { char cas[32]; timestr(cas); if (strcmp(lasttime,cas) == 0 ) return; strcpy(lasttime,cas); draw_time_online(); } #endif//textonly }//end sub
/* * Log to file and/or syslog as directed. We want different * behaviour before syslog has been called and set up; and * different behaviour before we fork for ssh: errors before * that point result in exit. */ void doerrlog(int level, char *fmt, va_list ap) { FILE *fl; #ifndef HAVE_VSYSLOG char logbuf[1024]; #endif fl = flog; /* only set per-call */ if (loglevel >= level) { if (logtype & L_SYSLOG) { #ifdef __ANDROID__ (void)vsnprintf(logbuf, sizeof(logbuf), fmt, ap); __android_log_print(ANDROID_LOG_DEBUG, "autossh", logbuf, 1); #else #ifndef HAVE_VSYSLOG (void)vsnprintf(logbuf, sizeof(logbuf), fmt, ap); syslog(level, logbuf); #else vsyslog(level, fmt, ap); #endif #endif } else if (!fl) { /* * if we're not using syslog, and we * don't have a log file, then use * stderr. */ fl = stderr; } if ((logtype & L_FILELOG) && fl) { fprintf(fl, "%s %s[%d]: ", timestr(), __progname, (int)getpid()); vfprintf(fl, fmt, ap); fprintf(fl, "\n"); fflush(fl); } } return; }
extern "C" BOOL DLLCALL spamlog(scfg_t* cfg, char* prot, char* action ,char* reason, char* host, char* ip_addr ,char* to, char* from) { char hdr[1024]; char to_user[256]; char tstr[64]; char fname[MAX_PATH+1]; int file; time32_t now=time32(NULL); sprintf(fname,"%sspam.log",cfg->logs_dir); if((file=sopen(fname,O_CREAT|O_RDWR|O_BINARY|O_APPEND,SH_DENYWR,DEFFILEMODE))==-1) return(FALSE); if(to==NULL) to_user[0]=0; else sprintf(to_user,"to: %.128s",to); if(from==NULL) from=host; sprintf(hdr,"SUSPECTED %s SPAM %s on %.24s\r\nHost: %s [%s]\r\nFrom: %.128s %s\r\nReason: " ,prot ,action ,timestr(cfg,now,tstr) ,host ,ip_addr ,from ,to_user ); write(file,hdr,strlen(hdr)); if(reason!=NULL) write(file,reason,strlen(reason)); write(file,crlf,2); write(file,crlf,2); close(file); return(TRUE); }
void post_dream (DESCRIPTOR_DATA *d) { char *p = NULL; char *date = NULL; DREAM_DATA *dream; CHAR_DATA *ch; p = d->character->delay_who; ch = d->character->delay_ch; if ( !p || !*p ) { send_to_char ("Dream aborted.\n\r", d->character); unload_pc (d->character->delay_ch); return; } CREATE (dream, DREAM_DATA, 1); dream->dream = d->character->delay_who; dream->next = ch->pc->dreams; d->character->delay_who = NULL; ch->pc->dreams = dream; send_to_char ("Dream added.\n\r", d->character); date = timestr(date); add_message (GET_NAME (ch), /* PC board */ 3, /* message # */ GET_NAME (d->character), /* Imm name */ date, "Entry via GIVEDREAM command.", "", dream->dream, MF_DREAM); unload_pc (ch); mem_free (date); }
static void print_report(const char *op, struct timeval *t, int64_t offset, int count, int total, int cnt, int Cflag) { char s1[64], s2[64], ts[64]; timestr(t, ts, sizeof(ts), Cflag ? VERBOSE_FIXED_TIME : 0); if (!Cflag) { cvtstr((double)total, s1, sizeof(s1)); cvtstr(tdiv((double)total, *t), s2, sizeof(s2)); printf("%s %d/%d bytes at offset %" PRId64 "\n", op, total, count, offset); printf("%s, %d ops; %s (%s/sec and %.4f ops/sec)\n", s1, cnt, ts, s2, tdiv((double)cnt, *t)); } else {/* bytes,ops,time,bytes/sec,ops/sec */ printf("%d,%d,%s,%.3f,%.3f\n", total, cnt, ts, tdiv((double)total, *t), tdiv((double)cnt, *t)); } }