/* test local file -----------------------------------------------------------*/ static int test_local(gtime_t ts, gtime_t te, double ti, const char *path, const char *sta, const char *dir, int *nc, int *nt, FILE *fp) { gtime_t time; char remot[1024],remot_p[1024],dir_t[1024],local[1024],str[1024]; int stat,abort=0; for (time=ts;timediff(time,te)<=1E-3;time=timeadd(time,ti)) { sprintf(str,"%s->%s",path,local); if (showmsg(str)) { abort=1; break; } genpath(path,sta,time,0,remot); genpath(dir ,sta,time,0,dir_t); remot2local(remot,dir_t,local); stat=test_file(local); fprintf(fp," %s",stat==0?"-":(stat==1?"o":"z")); showmsg("STAT=%s",stat==0?"x":(stat==1?"o":"z")); (*nt)++; if (stat) (*nc)++; } fprintf(fp,"\n"); return abort; }
/** lookup all needed special keys not defined by ncurses */ void lookup_keys() { int not_ok = 0; key_kNXT3 = lookup_key("kNXT3"); key_kPRV3 = lookup_key("kPRV3"); key_kNXT5 = lookup_key("kNXT5"); key_kPRV5 = lookup_key("kPRV5"); if ((key_kNXT3 || key_kPRV3) == 0) { showmsg("Terminal does not support Alt-PgUp/PgDn keys"); not_ok = 1; } if ((key_kNXT5 || key_kPRV5) == 0) { showmsg("Terminal does not support Ctrl-PgUp/PgDn keys"); not_ok = 1; } if (not_ok == 1) { showmsg("See ':CQD' in man page for setting Auto_CQ delay"); showmsg(""); beep(); sleep(2); } }
void hamlib_init() { int status; if (no_trx_control == 1) { trx_control = 0; } if (trx_control != 0) { shownr("Rignumber is", (int) myrig_model); shownr("Rig speed is", serial_rate); showmsg("Trying to start rig ctrl"); status = init_tlf_rig(); if (status != 0) { showmsg("Continue without rig control Y/(N)?"); if (toupper(key_get()) != 'Y') { endwin(); exit(1); } trx_control = 0; showmsg("Disabling rig control!"); sleep(1); } } }
int read_logcfg(void) { extern int nodes; extern int node; extern char *config_file; char defltconf[80]; int status = PARSE_OK; contest = 0; partials = 0; use_part = 0; keyerport = 0; portnum = 0; packetinterface = 0; tncport = 0; nodes = 0; node = 0; shortqsonr = 0; if (cabrillo != NULL) { free(cabrillo); cabrillo = NULL; } strcpy(defltconf, PACKAGE_DATA_DIR); strcat(defltconf, "/logcfg.dat"); if (config_file == NULL) config_file = g_strdup("logcfg.dat"); if ((fp = fopen(config_file, "r")) == NULL) { if ((fp = fopen(defltconf, "r")) == NULL) { showmsg("Error opening logcfg.dat file."); showmsg("Exiting..."); sleep(5); endwin(); exit(1); } else { showstring("Using (Read Only) file", defltconf); } } else showstring("Opening config file", config_file); while ( fgets(inputbuffer, 120, fp) != NULL ) { if ((inputbuffer[0] != '#') && (strlen(inputbuffer) > 1)) { /* skip comments and * empty lines */ status |= parse_logcfg(inputbuffer); } } fclose(fp); return( status ); }
/* execute download ------------------------------------------------------------ * execute download * args : gtime_t ts,te I time start and end * double tint I time interval (s) * int seqnos I sequence number start * int seqnoe I sequence number end * url_t *urls I url address list * int nurl I number of urls * char **stas I station list * int nsta I number of stations * char *dir I local directory * char *remote_p I previous remote file path * char *usr I login user for ftp * char *pwd I login password for ftp * char *proxy I proxy server address * int opts I download options (or of the followings) * DLOPT_FORCE = force download existing file * DLOPT_KEEPCMP=keep compressed file * DLOPT_HOLDERR=hold on error file * DLOPT_HOLDLST=hold on listing file * char *msg O output messages * FILE *fp IO log file pointer (NULL: no output log) * return : status (1:ok,0:error,-1:aborted) * notes : urls should be read by using dl_readurl() *-----------------------------------------------------------------------------*/ extern int dl_exec(gtime_t ts, gtime_t te, double ti, int seqnos, int seqnoe, const url_t *urls, int nurl, char **stas, int nsta, const char *dir, const char *usr, const char *pwd, const char *proxy, int opts, char *msg, FILE *fp) { paths_t paths={0}; gtime_t ts_p={0}; char str[2048],remot_p[1024]=""; int i,n[4]={0}; unsigned int tick=tickget(); showmsg("STAT=_"); /* generate download paths */ while (timediff(ts,te)<1E-3) { for (i=0;i<nurl;i++) { if (!gen_paths(ts,ts_p,seqnos,seqnoe,urls+i,stas,nsta,dir,&paths)) { free_path(&paths); return 0; } } ts_p=ts; ts=timeadd(ts,ti); } /* compact download paths */ compact_paths(&paths); if (paths.n<=0) { sprintf(msg,"no download data"); return 0; } for (i=0;i<paths.n;i++) { sprintf(str,"%s->%s (%d/%d)",paths.path[i].remot,paths.path[i].local,i+1, paths.n); if (showmsg(str)) break; /* execute download */ if (exec_down(paths.path+i,remot_p,usr,pwd,proxy,opts,n,fp)) { break; } } if (!(opts&DLOPT_HOLDLST)) { remove(FTP_LISTING); } sprintf(msg,"OK=%d No_File=%d Skip=%d Error=%d (Time=%.1f s)",n[0],n[1],n[2], n[3],(tickget()-tick)*0.001); free_path(&paths); return 1; }
/* show message and check break ----------------------------------------------*/ static int checkbrk(const char *format, ...) { va_list arg; char buff[1024],*p=buff; if (!*format) return showmsg(""); va_start(arg,format); p+=vsprintf(p,format,arg); va_end(arg); if (*proc_rov&&*proc_base) sprintf(p," (%s-%s)",proc_rov,proc_base); else if (*proc_rov ) sprintf(p," (%s)",proc_rov ); else if (*proc_base) sprintf(p," (%s)",proc_base); return showmsg(buff); }
void lan_init() { if (lan_active == 1) { if (lanrecv_init() < 0) /* set up the network */ showmsg("LAN receive init failed"); else showmsg("LAN receive initialized"); if (lan_send_init() < 0) showmsg("LAN send init failed"); else showmsg("LAN send initialized"); } }
/* open procssing session ----------------------------------------------------*/ static int openses(const prcopt_t *popt, const solopt_t *sopt, const filopt_t *fopt, nav_t *nav, pcvs_t *pcvs, pcvs_t *pcvr) { char *ext; trace(3,"openses :\n"); /* read satellite antenna parameters */ if (*fopt->satantp&&!(readpcv(fopt->satantp,pcvs))) { showmsg("error : no sat ant pcv in %s",fopt->satantp); trace(1,"sat antenna pcv read error: %s\n",fopt->satantp); return 0; } /* read receiver antenna parameters */ if (*fopt->rcvantp&&!(readpcv(fopt->rcvantp,pcvr))) { showmsg("error : no rec ant pcv in %s",fopt->rcvantp); trace(1,"rec antenna pcv read error: %s\n",fopt->rcvantp); return 0; } /* read dcb parameters */ if (*fopt->dcb) { readdcb(fopt->dcb,nav); } /* read ionosphere data file */ if (*fopt->iono&&(ext=strrchr(fopt->iono,'.'))) { if (strlen(ext)==4&&(ext[3]=='i'||ext[3]=='I')) { readtec(fopt->iono,nav,0); } #ifdef EXTSTEC else if (!strcmp(ext,".stec")||!strcmp(ext,".STEC")) { stec_read(fopt->iono,nav); } #endif } /* open geoid data */ if (sopt->geoid>0&&*fopt->geoid) { if (!opengeoid(sopt->geoid,fopt->geoid)) { showmsg("error : no geoid data %s",fopt->geoid); trace(2,"no geoid data %s\n",fopt->geoid); } } /* read erp data */ if (*fopt->eop) { if (!readerp(fopt->eop,&nav->erp)) { showmsg("error : no erp data %s",fopt->eop); trace(2,"no erp data %s\n",fopt->eop); } } return 1; }
/* show status message -------------------------------------------------------*/ static int showstat(int sess, gtime_t ts, gtime_t te, int *n) { const char type[]="ONGHQLSE"; char msg[1024]="",*p=msg,s[64]; int i; if (sess>0) { p+=sprintf(p,"(%d) ",sess); } if (ts.time!=0) { time2str(ts,s,0); p+=sprintf(p,"%s",s); } if (te.time!=0&&timediff(te,ts)>0.9) { time2str(te,s,0); p+=sprintf(p,"-%s",s+5); } p+=sprintf(p,": "); for (i=0;i<NOUTFILE+1;i++) { if (n[i]==0) continue; p+=sprintf(p,"%c=%d%s",type[i],n[i],i<NOUTFILE?" ":""); } return showmsg(msg); }
int describekeybriefly(UNUSED(char **args)) { char *seq, *str, *msg, *is; Thingy func; if (statusline) return 1; clearlist = 1; statusline = "Describe key briefly: _"; zrefresh(); seq = getkeymapcmd(curkeymap, &func, &str); statusline = NULL; if(!*seq) return 1; msg = bindztrdup(seq); msg = appstr(msg, " is "); if (!func) is = bindztrdup(str); else is = nicedup(func->nam, 0); msg = appstr(msg, is); zsfree(is); showmsg(msg); zsfree(msg); return 0; }
/** Complain about problems in configuration * * Complains in standout mode about some problem. Beep and wait for * 2 seconds * * \param msg The reason for the problem to be shown */ void Complain(char *msg) { attron(A_STANDOUT); showmsg(msg); attroff(A_STANDOUT); confirmation_needed = PARSE_CONFIRM; beep(); }
int ParseReturnErrorComponent(struct Aoc *chanp, u_char *p, u_char *end, int dummy) { int invokeId; int errorValue; char error[80]; INIT; XSEQUENCE_1(ParseInvokeId, ASN1_TAG_INTEGER, ASN1_NOT_TAGGED, &invokeId); XSEQUENCE_1(ParseErrorValue, ASN1_TAG_INTEGER, ASN1_NOT_TAGGED, &errorValue); switch (errorValue) { case 0: sprintf(error, "not subscribed"); break; case 3: sprintf(error, "not available"); break; case 4: sprintf(error, "not implemented"); break; case 6: sprintf(error, "invalid served user nr"); break; case 7: sprintf(error, "invalid call state"); break; case 8: sprintf(error, "basic service not provided"); break; case 9: sprintf(error, "not incoming call"); break; case 10: sprintf(error, "supplementary service interaction not allowed"); break; case 11: sprintf(error, "resource unavailable"); break; case 12: sprintf(error, "invalid diverted-to nr"); break; case 14: sprintf(error, "special service nr"); break; case 15: sprintf(error, "diversion to served user nr"); break; case 23: sprintf(error, "incoming call accepted"); break; case 24: sprintf(error, "number of diversions exceeded"); break; case 46: sprintf(error, "not activated"); break; case 48: sprintf(error, "request already accepted"); break; default: sprintf(error, "(%d)", errorValue); break; } showmsg("ReturnError: %s\n", error); return p - beg; }
/* rinex converter ------------------------------------------------------------- * convert receiver log file to rinex obs/nav, sbas log files * args : int format I receiver raw format (STRFMT_???) * rnxopt_t *opt IO rinex options (see below) * char *file I rtcm, receiver raw or rinex file * (wild-cards (*) are expanded) * char **ofile IO output files * ofile[0] rinex obs file ("": no output) * ofile[1] rinex nav file ("": no output) * ofile[2] rinex gnav file ("": no output) * ofile[3] rinex hnav file ("": no output) * ofile[4] rinex qnav file ("": no output) * ofile[5] rinex lnav file ("": no output) * ofile[6] sbas/lex log file("": no output) * return : status (1:ok,0:error,-1:abort) * notes : the following members of opt are replaced by information in last * converted rinex: opt->tstart, opt->tend, opt->obstype, opt->nobs * keywords in ofile[] are replaced by first obs date/time and station * id (%r) * the order of wild-card expanded files must be in-order by time *-----------------------------------------------------------------------------*/ extern int convrnx(int format, rnxopt_t *opt, const char *file, char **ofile) { gtime_t t0={0}; rnxopt_t opt_=*opt; double tu,ts; int i,week,stat=1; trace(3,"convrnx: format=%d file=%s ofile=%s %s %s %s %s %s %s\n", format,file,ofile[0],ofile[1],ofile[2],ofile[3],ofile[4],ofile[5], ofile[6]); showmsg(""); if (opt->ts.time==0||opt->te.time==0||opt->tunit<=0.0) { /* single-session */ opt_.tstart=opt_.tend=t0; stat=convrnx_s(0,format,&opt_,file,ofile); } else if (timediff(opt->ts,opt->te)<=0.0) { /* multiple-session */ tu=opt->tunit<86400.0?opt->tunit:86400.0; ts=tu*(int)floor(time2gpst(opt->ts,&week)/tu); for (i=0;;i++) { /* for each session */ opt_.ts=gpst2time(week,ts+i*tu); opt_.te=timeadd(opt_.ts,tu-DTTOL-0.001); opt_.trtcm=timeadd(opt->trtcm,timediff(opt_.ts,opt->ts)); if (timediff(opt_.ts,opt->te)>0.0) break; if (timediff(opt_.ts,opt->ts)<0.0) opt_.ts=opt->ts; if (timediff(opt_.te,opt->te)>0.0) opt_.te=opt->te; opt_.tstart=opt_.tend=t0; if ((stat=convrnx_s(i+1,format,&opt_,file,ofile))<0) break; } } else { showmsg("no period"); return 0; } /* output start/end time */ opt->tstart=opt_.tstart; opt->tend=opt_.tend; return stat; }
/** Repair log file * * Try to repair log file if some limes are too short. * Same is used to convert old logfile format v1 to new v2 * * \return 0 on success */ int repair_log(char *filename) { gchar *backupfile; gchar *cmd; char buffer[200]; gchar *fill; int rc; FILE *infp; FILE *outfp; /* make a backup of the original file */ backupfile = g_strconcat(filename, ".bak", NULL); showstring ( "Backing up original file as: ", backupfile); cmd = g_strconcat("cp ", filename, " ", backupfile, NULL); rc = system(cmd); g_free(cmd); showmsg( "Converting file to new format"); infp = fopen(backupfile, "r"); outfp = fopen(filename, "w"); while (fgets(buffer, sizeof(buffer), infp)) { /* strip trailing whitespace (and newline) */ g_strchomp(buffer); /* append spaces */ fill = g_strnfill( (LOGLINELEN-1) - strlen(buffer), ' ' ); strcat(buffer, fill); g_free(fill); fputs(buffer, outfp); fputs("\n", outfp); } fclose(outfp); fclose(infp); g_free(backupfile); showmsg( "Done" ); sleep(2); return 0; }
void keyer_init() { char keyerbuff[3]; if (cwkeyer == NET_KEYER) { showmsg("CW-Keyer is cwdaemon"); if (netkeyer_init() < 0) { showmsg("Cannot open NET keyer daemon "); refreshp(); sleep(1); } else { netkeyer(K_RESET, "0"); sprintf(weightbuf, "%d", weight); write_tone(); snprintf(keyerbuff, 3, "%2d", GetCWSpeed()); netkeyer(K_SPEED, keyerbuff); // set speed netkeyer(K_WEIGHT, weightbuf); // set weight if (*keyer_device != '\0') netkeyer(K_DEVICE, keyer_device); // set device sprintf(keyerbuff, "%d", txdelay); netkeyer(K_TOD, keyerbuff); // set TOD if (sc_sidetone != 0) // set soundcard output netkeyer(K_SIDETONE, ""); if (*sc_volume != '\0') // set soundcard volume netkeyer(K_STVOLUME, sc_volume); } } if (cwkeyer == MFJ1278_KEYER || digikeyer == MFJ1278_KEYER || digikeyer == GMFSK) { init_controller(); } }
/* generate stream file ------------------------------------------------------*/ static strfile_t *gen_strfile(int format, const char *opt, gtime_t time) { strfile_t *str; trace(3,"init_strfile:\n"); if (!(str=(strfile_t *)malloc(sizeof(strfile_t)))) return NULL; if (format==STRFMT_RTCM2||format==STRFMT_RTCM3) { if (!init_rtcm(&str->rtcm)) { showmsg("init rtcm error"); return 0; } str->rtcm.time=time; str->obs=&str->rtcm.obs; str->nav=&str->rtcm.nav; strcpy(str->rtcm.opt,opt); } else if (format<=MAXRCVFMT) { if (!init_raw(&str->raw)) { showmsg("init raw error"); return 0; } str->raw.time=time; str->obs=&str->raw.obs; str->nav=&str->raw.nav; str->pvt=&str->raw.pvt; strcpy(str->raw.opt,opt); } else if (format==STRFMT_RINEX) { if (!init_rnxctr(&str->rnx)) { showmsg("init rnx error"); return 0; } str->obs=&str->rnx.obs; str->nav=&str->rnx.nav; strcpy(str->rnx.opt,opt); } str->format=format; str->sat=0; str->fp=NULL; str->time=time; return str; }
/* * Uncompress a file and return the new file name, if the file doesn't * appear to be compressed or the uncompression fails, the original * file name will be returned. In all cases, the return value is * allocated with XtNewString(). * * We use "system()" in here to avoid the hassle of converting the * decompression commands from strings to argv's but this means that * some kludging is needed to grab the error output. This would be * "cleaner" (in some sense) if pipe/dup2/fork/exec/XtAppAddInput * were used instead but sometimes laziness is good. */ char * mgv_unmangle(MGV *m, char *file) { # define CMD_FMT "%s <%s >%s 2>%s" char *cmd, *out, *tmp, *s; int t, cmd_size; MGV_APP *r = mgv_appres(m->main); if((t = filetype(file)) == FT_NORM || (tempdir == NULL && !mk_tmp(r->temp_dir))) return XtNewString(file); if((s = strrchr(file, '/')) == NULL) s = file; else ++s; out = XtCalloc(strlen(tempdir) + 1 + strlen(s) + 1 + 64 + 1, 1); tmp = XtCalloc(strlen(tempdir) + 1 + 64 + 1 + 1, 1); sprintf(out, "%s/%s.%ld.%d", tempdir, s, (long)XtWindow(m->main), m->inst_num); sprintf(tmp, "%s/%ld.%d", tempdir, (long)getpid(), m->inst_num); cmd_size = strlen(file) + strlen(out) + strlen(tmp) + sizeof(CMD_FMT); switch(t) { case FT_GZIP: cmd = XtCalloc(cmd_size + strlen(r->gunzip), 1); sprintf(cmd, "%s <%s >%s 2>%s", r->gunzip, file, out, tmp); break; case FT_BZIP: cmd = XtCalloc(cmd_size + strlen(r->bunzip), 1); sprintf(cmd, "%s <%s >%s 2>%s", r->bunzip, file, out, tmp); break; default: assert("mgv_unmangle(): confused by file type!" != NULL); XtFree(out); XtFree(tmp); return XtNewString(file); break; } errno = 0; if(system(cmd) != 0 && errno != 0) { XtFree(out); out = XtNewString(file); } showmsg(m, file, &tmp[0]); XtFree(tmp); XtFree(cmd); return out; # undef CMD_FMT }
/* read prec ephemeris, sbas data, lex data, tec grid and open rtcm ----------*/ static void readpreceph(char **infile, int n, const prcopt_t *prcopt, nav_t *nav, sbs_t *sbs, lex_t *lex) { seph_t seph0={0}; int i; char *ext; trace(3,"readpreceph: n=%d\n",n); nav->ne=nav->nemax=0; nav->nc=nav->ncmax=0; sbs->n =sbs->nmax =0; lex->n =lex->nmax =0; /* read precise ephemeris files */ for (i=0;i<n;i++) { if (strstr(infile[i],"%r")||strstr(infile[i],"%b")) continue; readsp3(infile[i],nav,0); } /* read precise clock files */ for (i=0;i<n;i++) { if (strstr(infile[i],"%r")||strstr(infile[i],"%b")) continue; readrnxc(infile[i],nav); } /* read sbas message files */ for (i=0;i<n;i++) { if (strstr(infile[i],"%r")||strstr(infile[i],"%b")) continue; sbsreadmsg(infile[i],prcopt->sbassatsel,sbs); } /* read lex message files */ for (i=0;i<n;i++) { if (strstr(infile[i],"%r")||strstr(infile[i],"%b")) continue; lexreadmsg(infile[i],0,lex); } /* allocate sbas ephemeris */ nav->ns=nav->nsmax=NSATSBS*2; if (!(nav->seph=(seph_t *)malloc(sizeof(seph_t)*nav->ns))) { showmsg("error : sbas ephem memory allocation"); trace(1,"error : sbas ephem memory allocation"); return; } for (i=0;i<nav->ns;i++) nav->seph[i]=seph0; /* set rtcm file and initialize rtcm struct */ rtcm_file[0]=rtcm_path[0]='\0'; fp_rtcm=NULL; for (i=0;i<n;i++) { if ((ext=strrchr(infile[i],'.'))&& (!strcmp(ext,".rtcm3")||!strcmp(ext,".RTCM3"))) { strcpy(rtcm_file,infile[i]); init_rtcm(&rtcm); break; } } }
int synclog(char *synclogfile) { extern char logfile[]; extern struct tm *time_ptr; int rc; char wgetcmd[120] = "wget ftp://"; //user:password@hst/dir/file char date_buf[60]; get_time(); strftime(date_buf, 9, "%d%H%M", time_ptr); if (strlen(synclogfile) < 80) strcat(wgetcmd, synclogfile); else { showmsg("Warning: Name of syncfile too long\n"); sleep(5); exit(1); } strcat(wgetcmd, " -O log1 -o wgetlogfile"); if (system(wgetcmd) == 0) showmsg("Syncfile o.k.\n"); else { showmsg("Warning: Did not get syncfile !!\nExiting...\n"); sleep(5); exit(1); } wgetcmd[0] = '\0'; sprintf(wgetcmd, "cp %s log2", logfile); if (system(wgetcmd) != 0) showstring("\nCopying logfile %s failed\n", logfile); showmsg("Backing up logfile.\n"); sleep(1); sprintf(wgetcmd, "cp %s %s%s", logfile, date_buf, logfile); if (system(wgetcmd) != 0) showstring("\nCopying logfile %s to backup failed\n", logfile); showmsg("Merging logfiles...\n"); sleep(1); sprintf(wgetcmd, "cat log1 log2 | sort -g -k4,4 | uniq -w79 > %s", logfile); if (system(wgetcmd) == 0) showmsg("Merging logs successfull\n"); else { showmsg("Problem merging logs.\nExiting...\n"); sleep(5); exit(1); } sleep(1); rc = system("rm log1"); rc = system("rm log2"); return (0); }
/* antenna phase center position ---------------------------------------------*/ static int antpos(prcopt_t *opt, int rcvno, const obs_t *obs, const nav_t *nav, const sta_t *sta, const char *posfile) { double *rr=rcvno==1?opt->ru:opt->rb,del[3],pos[3],dr[3]={0}; int i,postype=rcvno==1?opt->rovpos:opt->refpos; char *name; trace(3,"antpos : rcvno=%d\n",rcvno); if (postype==1) { /* average of single position */ if (!avepos(rr,rcvno,obs,nav,opt)) { showmsg("error : station pos computation"); return 0; } } else if (postype==2) { /* read from position file */ name=stas[rcvno==1?0:1].name; if (!getstapos(posfile,name,rr)) { showmsg("error : no position of %s in %s",name,posfile); return 0; } } else if (postype==3) { /* get from rinex header */ if (norm(stas[rcvno==1?0:1].pos,3)<=0.0) { showmsg("error : no position in rinex header"); trace(1,"no position position in rinex header\n"); return 0; } /* antenna delta */ if (stas[rcvno==1?0:1].deltype==0) { /* enu */ for (i=0;i<3;i++) del[i]=stas[rcvno==1?0:1].del[i]; del[2]+=stas[rcvno==1?0:1].hgt; ecef2pos(stas[rcvno==1?0:1].pos,pos); enu2ecef(pos,del,dr); } else { /* xyz */ for (i=0;i<3;i++) dr[i]=stas[rcvno==1?0:1].del[i]; } for (i=0;i<3;i++) rr[i]=stas[rcvno==1?0:1].pos[i]+dr[i]; } return 1; }
void showmsg(int m, int rflag) { long addr, len; int n, f, c, nl; uchar *ip; char *sp, *cp; if(m <= 0 || m > ncnotes){ Bad: fprint(2, "no footnote %d\n", m); return; } ip = &findex[8*(m-1)]; addr = LONG(ip); len = SHORT(ip+4); if(len == 0) goto Bad; Read(msg, addr, len); if(m > nfnotes && rflag){ cp = sp = malloc(len); memcpy(cp, msg, len); n = strtol(cp, &cp, 10); while(--n >= 0){ f = strtol(cp, &cp, 10); if(f > 0) showmsg(f, 0); } free(sp); return; } Bprint(out, "%d\t", m); ip = msg; nl = 0; while(ip<&msg[len]){ switch(c = *ip++){ case 0: case '\r': break; case '\n': BPUTC(out, c); ++nl; break; default: if(nl){ BPUTC(out, '\t'); nl = 0; } BPUTC(out, c); break; } } for(; nl<2; nl++) BPUTC(out, '\n'); }
/* open stream file ----------------------------------------------------------*/ static int open_strfile(strfile_t *str, const char *file) { trace(3,"open_strfile: file=%s\n",file); if (str->format==STRFMT_RTCM2||str->format==STRFMT_RTCM3) { if (!(str->fp=fopen(file,"rb"))) { showmsg("rtcm open error: %s",file); return 0; } } else if (str->format<=MAXRCVFMT) { if (!(str->fp=fopen(file,"rb"))) { showmsg("log open error: %s",file); return 0; } /* read head to resolve time ambiguity */ if (str->time.time==0) { str->raw.flag=1; while (input_strfile(str)>=-1&&str->time.time==0) ; str->raw.flag=1; rewind(str->fp); } } else if (str->format==STRFMT_RINEX) { if (!(str->fp=fopen(file,"r"))) { showmsg("rinex open error: %s",file); return 0; } /* open rinex control */ if (!open_rnxctr(&str->rnx,str->fp)) { showmsg("no rinex file: %s",file); fclose(str->fp); set_default_leaps(); return 0; } } return 1; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { int pid = 0; pid = GetCurrentProcessId(); while (showmsg(buf)) { sprintf(buf, "base=0x%08x\n pid=%d\n %s", (unsigned int) hInstance, &i, s); i++; // printf("i 的地址%p",&i); } return 0; }
int whereis(UNUSED(char **args)) { struct findfunc ff; if (!(ff.func = executenamedcommand("Where is: "))) return 1; ff.found = 0; ff.msg = nicedup(ff.func->nam, 0); scankeymap(curkeymap, 1, scanfindfunc, &ff); if (!ff.found) ff.msg = appstr(ff.msg, " is not bound to any key"); else if(ff.found > MAXFOUND) ff.msg = appstr(ff.msg, " et al"); showmsg(ff.msg); zsfree(ff.msg); return 0; }
int main() { signal(SIGCHLD,handle); signal(SIGINT,handle); iniui(); int r = initsock(); if(r == -1) { exit(-1); } if(fork()) { sendwmsg(); } else { showmsg(); } destroy(); return 0; }
void *threadRcv(void *param ) { printf("Receive Thread[%ld] running...\n", gettid()); int flag = IPC_NOWAIT | MSG_NOERROR; while (1) { struct mymsg_s mymsg; int rc = msgrcv(ipc_msg_id, &mymsg, sizeof(mymsg), ipc_msg_type, flag); if (rc < 0) { if (errno == EINTR || errno == ENOMSG) { usleep(1000); continue; } perror("msgrcv"); break; } showmsg(); printf("Receive %3d Bytes: %s\n", rc, mymsg.ptr); } return NULL; }
void main() { cout.precision(2); //设置精度 cout.setf(ios::fixed|ios::left); while(1) { switch(showMainmenu()) { case 1 :cash(); break; case 2 :stackmgr(); break; case 3 :reports(); break; case 4 :showmsg(); exit(0); break; } } }
int whatcursorposition(UNUSED(char **args)) { char msg[100]; char *s = msg, *mbstr; int bol = findbol(), len; ZLE_CHAR_T c = zleline[zlecs]; if (zlecs == zlell) strucpy(&s, "EOF"); else { strucpy(&s, "Char: "); switch (c) { case ZWC(' '): strucpy(&s, "SPC"); break; case ZWC('\t'): strucpy(&s, "TAB"); break; case ZWC('\n'): strucpy(&s, "LFD"); break; default: /* * convert a single character, remembering it may * turn into a multibyte string or be metafied. */ mbstr = zlelineasstring(zleline+zlecs, 1, 0, &len, NULL, 1); strcpy(s, mbstr); s += len; } sprintf(s, " (0%o, %u, 0x%x)", (unsigned int)c, (unsigned int)c, (unsigned int)c); s += strlen(s); } sprintf(s, " point %d of %d(%d%%) column %d", zlecs+1, zlell+1, zlell ? 100 * zlecs / zlell : 0, zlecs - bol); showmsg(msg); return 0; }
/* write header to output file -----------------------------------------------*/ static int outhead(const char *outfile, char **infile, int n, const prcopt_t *popt, const solopt_t *sopt) { FILE *fp=stdout; trace(3,"outhead: outfile=%s n=%d\n",outfile,n); if (*outfile) { createdir(outfile); if (!(fp=fopen(outfile,"w"))) { showmsg("error : open output file %s",outfile); return 0; } } /* output header */ outheader(fp,infile,n,popt,sopt); if (*outfile) fclose(fp); return 1; }
/* open output files ---------------------------------------------------------*/ static int openfile(FILE **ofp, char *files[], const char *file, const rnxopt_t *opt, nav_t *nav) { char path[1024]; int i; trace(3,"openfile:\n"); for (i=0;i<NOUTFILE;i++) { if (!*files[i]) continue; strcpy(path,files[i]); /* check overwrite input file and modify output file */ if (!strcmp(path,file)) strcat(path,"_"); /* create directory if not exist */ createdir(path); if (!(ofp[i]=fopen(path,"w"))) { showmsg("file open error: %s",path); for (i--;i>=0;i--) if (ofp[i]) fclose(ofp[i]); return 0; } /* write header to file */ switch (i) { case 0: outrnxobsh (ofp[0],opt,nav); break; case 1: outrnxnavh (ofp[1],opt,nav); break; case 2: outrnxgnavh(ofp[2],opt,nav); break; case 3: outrnxhnavh(ofp[3],opt,nav); break; case 4: outrnxqnavh(ofp[4],opt,nav); break; case 5: outrnxlnavh(ofp[5],opt,nav); break; case 6: outrnxcnavh(ofp[6],opt,nav); break; } } return 1; }