void DOS_Shell::CMD_TYPE(char * args) { HELP("TYPE"); StripSpaces(args); if (!*args) { WriteOut(MSG_Get("SHELL_SYNTAXERROR")); return; } Bit16u handle; char * word; nextfile: word=StripArg(args); if (!DOS_OpenFile(word,0,&handle)) { WriteOut(MSG_Get("SHELL_CMD_FILE_NOT_FOUND"),word); return; } Bit16u n;Bit8u c; do { n=1; DOS_ReadFile(handle,&c,&n); if (c==0x1a) break; // stop at EOF DOS_WriteFile(STDOUT,&c,&n); } while (n); DOS_CloseFile(handle); if (*args) goto nextfile; }
static int freq_sysctl_hw_model (int help) { #if HAVE_SYSCTL && defined (CTL_HW) && defined (HW_MODEL) int mib[2]; char str[128]; unsigned val; size_t size; char *p; int end; HELP ("sysctl() hw.model"); mib[0] = CTL_HW; mib[1] = HW_MODEL; size = sizeof(str); if (sysctl (mib, 2, str, &size, NULL, 0) == 0) { for (p = str; *p != '\0'; p++) { end = 0; if (sscanf (p, "%u MHz%n", &val, &end) == 1 && end != 0) { speed_cycletime = 1e-6 / (double) val; if (speed_option_verbose) printf ("Using sysctl() hw.model %u for cycle time %.3g\n", val, speed_cycletime); return 1; } } } #endif return 0; }
/* "/etc/hw -r cpu" for SCO OpenUnix 8, printing a line like The speed of the CPU is approximately 450Mhz */ static int freq_sco_etchw (int help) { int ret = 0; #if HAVE_POPEN FILE *fp; char buf[128]; double val; int end; HELP ("SCO /etc/hw program output"); /* Error messages are sent to /dev/null in case /etc/hw doesn't exist. The brackets are necessary for some shells. */ if ((fp = popen ("(/etc/hw -r cpu) 2>/dev/null", "r")) != NULL) { while (fgets (buf, sizeof (buf), fp) != NULL) { end = 0; if (sscanf (buf, " The speed of the CPU is approximately %lfMhz%n", &val, &end) == 1 && end != 0) { speed_cycletime = 1e-6 / val; if (speed_option_verbose) printf ("Using /etc/hw %.2f MHz, for cycle time %.3g\n", val, speed_cycletime); ret = 1; break; } } pclose (fp); } #endif return ret; }
static int freq_attr_get_invent (int help) { int ret = 0; #if HAVE_ATTR_GET && HAVE_INVENT_H && defined (INFO_LBL_DETAIL_INVENT) invent_cpuinfo_t inv; int len, val; HELP ("attr_get(\"/hw/cpunum/0\") ic_cpu_info.cpufq"); len = sizeof (inv); if (attr_get ("/hw/cpunum/0", INFO_LBL_DETAIL_INVENT, (char *) &inv, &len, 0) == 0 && len == sizeof (inv) && inv.ic_gen.ig_invclass == INV_PROCESSOR) { val = inv.ic_cpu_info.cpufq; speed_cycletime = 1e-6 / val; if (speed_option_verbose) printf ("Using attr_get(\"/hw/cpunum/0\") ic_cpu_info.cpufq %d MHz for cycle time %.3g\n", val, speed_cycletime); ret = 1; } #endif return ret; }
void DOS_Shell::CMD_ECHO(char * args){ if (!*args) { if (echo) { WriteOut(MSG_Get("SHELL_CMD_ECHO_ON"));} else { WriteOut(MSG_Get("SHELL_CMD_ECHO_OFF"));} return; } char buffer[512]; char* pbuffer = buffer; safe_strncpy(buffer,args,512); StripSpaces(pbuffer); if (strcasecmp(pbuffer,"OFF")==0) { echo=false; return; } if (strcasecmp(pbuffer,"ON")==0) { echo=true; return; } if(strcasecmp(pbuffer,"/?")==0) { HELP("ECHO"); } args++;//skip first character. either a slash or dot or space size_t len = strlen(args); //TODO check input of else ook nodig is. if(len && args[len - 1] == '\r') { LOG(LOG_MISC,LOG_WARN)("Hu ? carriage return already present. Is this possible?"); WriteOut("%s\n",args); } else WriteOut("%s\r\n",args); }
static int freq_bsd_dmesg (int help) { FILE *fp; char buf[256], *p; double val; int ret = 0; int end; HELP ("BSD /var/run/dmesg.boot file"); if ((fp = fopen ("/var/run/dmesg.boot", "r")) != NULL) { while (fgets (buf, sizeof (buf), fp) != NULL) { if (memcmp (buf, "CPU:", 4) == 0) { for (p = buf; *p != '\0'; p++) { end = 0; if (sscanf (p, "(%lf-MHz%n", &val, &end) == 1 && end != 0) { speed_cycletime = 1e-6 / val; if (speed_option_verbose) printf ("Using /var/run/dmesg.boot CPU: %.2f MHz for cycle time %.3g\n", val, speed_cycletime); ret = 1; break; } } } } fclose (fp); } return ret; }
/* /bin/sysinfo for SunOS 4. Prints a line like: cpu0 is a "75 MHz TI,TMS390Z55" CPU */ static int freq_sunos_sysinfo (int help) { int ret = 0; #if HAVE_POPEN FILE *fp; char buf[128]; double val; int end; HELP ("SunOS /bin/sysinfo program output, cpu0"); /* Error messages are sent to /dev/null in case /bin/sysinfo doesn't exist. The brackets are necessary for some shells. */ if ((fp = popen ("(/bin/sysinfo) 2>/dev/null", "r")) != NULL) { while (fgets (buf, sizeof (buf), fp) != NULL) { end = 0; if (sscanf (buf, " cpu0 is a \"%lf MHz%n", &val, &end) == 1 && end != 0) { speed_cycletime = 1e-6 / val; if (speed_option_verbose) printf ("Using /bin/sysinfo \"cpu0 MHz\" %.2f for cycle time %.3g\n", val, speed_cycletime); ret = 1; break; } } pclose (fp); } #endif return ret; }
void DOS_Shell::CMD_DATE(char * args) { HELP("DATE"); if(ScanCMDBool(args,"H")) { // synchronize date with host parameter time_t curtime; struct tm *loctime; curtime = time (NULL); loctime = localtime (&curtime); reg_cx = loctime->tm_year+1900; reg_dh = loctime->tm_mon+1; reg_dl = loctime->tm_mday; reg_ah=0x2b; // set system date CALLBACK_RunRealInt(0x21); return; } // check if a date was passed in command line Bit32u newday,newmonth,newyear; if(sscanf(args,"%u-%u-%u",&newmonth,&newday,&newyear)==3) { reg_cx = static_cast<Bit16u>(newyear); reg_dh = static_cast<Bit8u>(newmonth); reg_dl = static_cast<Bit8u>(newday); reg_ah=0x2b; // set system date CALLBACK_RunRealInt(0x21); if(reg_al==0xff) WriteOut(MSG_Get("SHELL_CMD_DATE_ERROR")); return; } // display the current date reg_ah=0x2a; // get system date CALLBACK_RunRealInt(0x21); const char* datestring = MSG_Get("SHELL_CMD_DATE_DAYS"); Bit32u length; char day[6] = {0}; if(sscanf(datestring,"%u",&length) && (length<5) && (strlen(datestring)==(length*7+1))) { // date string appears valid for(Bit32u i = 0; i < length; i++) day[i] = datestring[reg_al*length+1+i]; } bool dateonly = ScanCMDBool(args,"T"); if(!dateonly) WriteOut(MSG_Get("SHELL_CMD_DATE_NOW")); const char* formatstring = MSG_Get("SHELL_CMD_DATE_FORMAT"); if(strlen(formatstring)!=5) return; char buffer[15] = {0}; Bitu bufferptr=0; for(Bitu i = 0; i < 5; i++) { if(i==1 || i==3) { buffer[bufferptr] = formatstring[i]; bufferptr++; } else { if(formatstring[i]=='M') bufferptr += sprintf(buffer+bufferptr,"%02u",(Bit8u) reg_dh); if(formatstring[i]=='D') bufferptr += sprintf(buffer+bufferptr,"%02u",(Bit8u) reg_dl); if(formatstring[i]=='Y') bufferptr += sprintf(buffer+bufferptr,"%04u",(Bit16u) reg_cx); } } WriteOut("%s %s\n",day, buffer); if(!dateonly) WriteOut(MSG_Get("SHELL_CMD_DATE_SETHLP")); };
void DOS_Shell::CMD_PAUSE(char * args){ HELP("PAUSE"); WriteOut(MSG_Get("SHELL_CMD_PAUSE")); Bit8u c;Bit16u n=1; DOS_ReadFile(STDIN,&c,&n); if (c==0) DOS_ReadFile(STDIN,&c,&n); // read extended key }
static void _malelf_help() { HELP("\n"); HELP("Tool to infect and/or analyse ELF binary.\n"); HELP("Usage: malelf <command> [-h] <options> \n"); HELP("Commands:\n"); HELP(" dissect \tShow ELF binary info. \n"); HELP(" disas \tDisassembly binary ELF in NASM compatible format.\n"); HELP(" infect \tInfect the binary with a malware.\n"); HELP(" shellcode \tcreate the virus shellcode in the proper format\n\ \tto use with the infect command.\n"); HELP(" dynanalyse \tDinamically analyse the ELF binary for malwares.\n"); HELP(" database \tStores ELF binary info in a database.\n"); HELP(" analyse \tAnalyse ELF binary info in a database.\n"); HELP("\n"); exit(MALELF_SUCCESS); }
int main(int argc, char *argv[]) { argv0 = *argv; HELP("Initialise the branch and repository for issue tracking"); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { argv0 = *argv; HELP("Add, remove or list known unaffected versions of the program for an issue"); return EXIT_SUCCESS; }
void DOS_Shell::CMD_CHDIR(char * args) { HELP("CHDIR"); StripSpaces(args); char sargs[CROSS_LEN]; if (*args && !DOS_GetSFNPath(args,sargs,false)) { WriteOut(MSG_Get("SHELL_ILLEGAL_PATH")); return; } Bit8u drive = DOS_GetDefaultDrive()+'A'; char dir[DOS_PATHLENGTH]; if (!*args) { DOS_GetCurrentDir(0,dir,true); WriteOut("%c:\\%s\n",drive,dir); } else if(strlen(args) == 2 && args[1]==':') { Bit8u targetdrive = (args[0] | 0x20)-'a' + 1; unsigned char targetdisplay = *reinterpret_cast<unsigned char*>(&args[0]); if(!DOS_GetCurrentDir(targetdrive,dir,true)) { if(drive == 'Z') { WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_NOT_FOUND"),toupper(targetdisplay)); } else { WriteOut(MSG_Get("SHELL_ILLEGAL_PATH")); } return; } WriteOut("%c:\\%s\n",toupper(targetdisplay),dir); if(drive == 'Z') WriteOut(MSG_Get("SHELL_CMD_CHDIR_HINT"),toupper(targetdisplay)); } else if (!DOS_ChangeDir(sargs)) { /* Changedir failed. Check if the filename is longer then 8 and/or contains spaces */ std::string temps(args),slashpart; std::string::size_type separator = temps.find_first_of("\\/"); if(!separator) { slashpart = temps.substr(0,1); temps.erase(0,1); } separator = temps.find_first_of("\\/"); if(separator != std::string::npos) temps.erase(separator); separator = temps.find_first_of("\""); if(separator != std::string::npos) temps.erase(separator); separator = temps.rfind('.'); if(separator != std::string::npos) temps.erase(separator); separator = temps.find(' '); if(separator != std::string::npos) {/* Contains spaces */ temps.erase(separator); if(temps.size() >6) temps.erase(6); temps += "~1"; WriteOut(MSG_Get("SHELL_CMD_CHDIR_HINT_2"),temps.insert(0,slashpart).c_str()); } else { if (drive == 'Z') { WriteOut(MSG_Get("SHELL_CMD_CHDIR_HINT_3")); } else { WriteOut(MSG_Get("SHELL_CMD_CHDIR_ERROR"),args); } } } }
int main(int argc, char *argv[]) { argv0 = *argv; HELP("Declare your interest seeing an issue resolved"); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { argv0 = *argv; HELP("Set or get the title of an issue"); return EXIT_SUCCESS; }
static int freq_proc_cpuinfo (int help) { FILE *fp; char buf[128]; double val; int ret = 0; int end; HELP ("linux kernel /proc/cpuinfo file, cpu MHz or bogomips"); if ((fp = fopen ("/proc/cpuinfo", "r")) != NULL) { while (fgets (buf, sizeof (buf), fp) != NULL) { if (sscanf (buf, "cycle frequency [Hz] : %lf", &val) == 1 && val != 0.0) { speed_cycletime = 1.0 / val; if (speed_option_verbose) printf ("Using /proc/cpuinfo \"cycle frequency\" %.2f for cycle time %.3g\n", val, speed_cycletime); ret = 1; break; } if (sscanf (buf, "cpu MHz : %lf\n", &val) == 1) { speed_cycletime = 1e-6 / val; if (speed_option_verbose) printf ("Using /proc/cpuinfo \"cpu MHz\" %.2f for cycle time %.3g\n", val, speed_cycletime); ret = 1; break; } end = 0; if (sscanf (buf, "clock : %lfMHz\n%n", &val, &end) == 1 && end != 0) { speed_cycletime = 1e-6 / val; if (speed_option_verbose) printf ("Using /proc/cpuinfo \"clock\" %.2f for cycle time %.3g\n", val, speed_cycletime); ret = 1; break; } if (sscanf (buf, "bogomips : %lf\n", &val) == 1 || sscanf (buf, "BogoMIPS : %lf\n", &val) == 1) { speed_cycletime = 1e-6 / val; if (speed_option_verbose) printf ("Using /proc/cpuinfo \"bogomips\" %.2f for cycle time %.3g\n", val, speed_cycletime); ret = 1; break; } } fclose (fp); } return ret; }
void DOS_Shell::CMD_RMDIR(char * args) { HELP("RMDIR"); StripSpaces(args); char * rem=ScanCMDRemain(args); if (rem) { WriteOut(MSG_Get("SHELL_ILLEGAL_SWITCH"),rem); return; } if (!DOS_RemoveDir(args)) { WriteOut(MSG_Get("SHELL_CMD_RMDIR_ERROR"),args); } }
void DOS_Shell::CMD_CHOICE(char * args){ HELP("CHOICE"); static char defchoice[3] = {'y','n',0}; char *rem = NULL, *ptr; bool optN = ScanCMDBool(args,"N"); bool optS = ScanCMDBool(args,"S"); //Case-sensitive matching ScanCMDBool(args,"T"); //Default Choice after timeout if (args) { char *last = strchr(args,0); StripSpaces(args); rem = ScanCMDRemain(args); if (rem && *rem && (tolower(rem[1]) != 'c')) { WriteOut(MSG_Get("SHELL_ILLEGAL_SWITCH"),rem); return; } if (args == rem) args = strchr(rem,0)+1; if (rem) rem += 2; if(rem && rem[0]==':') rem++; /* optional : after /c */ if (args > last) args = NULL; } if (!rem || !*rem) rem = defchoice; /* No choices specified use YN */ ptr = rem; Bit8u c; if(!optS) while ((c = *ptr)) *ptr++ = (char)toupper(c); /* When in no case-sensitive mode. make everything upcase */ if(args && *args ) { StripSpaces(args); size_t argslen = strlen(args); if(argslen>1 && args[0] == '"' && args[argslen-1] =='"') { args[argslen-1] = 0; //Remove quotes args++; } WriteOut(args); } /* Show question prompt of the form [a,b]? where a b are the choice values */ if (!optN) { if(args && *args) WriteOut(" "); WriteOut("["); size_t len = strlen(rem); for(size_t t = 1; t < len; t++) { WriteOut("%c,",rem[t-1]); } WriteOut("%c]?",rem[len-1]); } Bit16u n=1; do { DOS_ReadFile (STDIN,&c,&n); } while (!c || !(ptr = strchr(rem,(optS?c:toupper(c))))); c = optS?c:(Bit8u)toupper(c); DOS_WriteFile (STDOUT,&c, &n); dos.return_code = (Bit8u)(ptr-rem+1); }
void DOS_Shell::CMD_SET(char * args) { HELP("SET"); StripSpaces(args); std::string line; if (!*args) { /* No command line show all environment lines */ Bitu count=GetEnvCount(); for (Bitu a=0;a<count;a++) { if (GetEnvNum(a,line)) WriteOut("%s\n",line.c_str()); } return; } //There are args: char * pcheck = args; while ( *pcheck && (*pcheck == ' ' || *pcheck == '\t')) pcheck++; if (*pcheck && strlen(pcheck) >3 && (strncasecmp(pcheck,"/p ",3) == 0)) E_Exit("Set /P is not supported. Use Choice!"); char * p=strpbrk(args, "="); if (!p) { if (!GetEnvStr(args,line)) WriteOut(MSG_Get("SHELL_CMD_SET_NOT_SET"),args); WriteOut("%s\n",line.c_str()); } else { *p++=0; /* parse p for envirionment variables */ char parsed[CMD_MAXLINE]; char* p_parsed = parsed; while(*p) { if(*p != '%') *p_parsed++ = *p++; //Just add it (most likely path) else if( *(p+1) == '%') { *p_parsed++ = '%'; p += 2; //%% => % } else { char * second = strchr(++p,'%'); if(!second) continue; *second++ = 0; std::string temp; if (GetEnvStr(p,temp)) { std::string::size_type equals = temp.find('='); if (equals == std::string::npos) continue; strcpy(p_parsed,temp.substr(equals+1).c_str()); p_parsed += strlen(p_parsed); } p = second; } } *p_parsed = 0; /* Try setting the variable */ if (!SetEnv(args,parsed)) { WriteOut(MSG_Get("SHELL_CMD_SET_OUT_OF_SPACE")); } } }
void DOS_Shell::CMD_LOADHIGH(char *args){ HELP("LOADHIGH"); Bit16u umb_start=dos_infoblock.GetStartOfUMBChain(); Bit8u umb_flag=dos_infoblock.GetUMBChainState(); Bit8u old_memstrat=(Bit8u)(DOS_GetMemAllocStrategy()&0xff); if (umb_start==0x9fff) { if ((umb_flag&1)==0) DOS_LinkUMBsToMemChain(1); DOS_SetMemAllocStrategy(0x80); // search in UMBs first this->ParseLine(args); Bit8u current_umb_flag=dos_infoblock.GetUMBChainState(); if ((current_umb_flag&1)!=(umb_flag&1)) DOS_LinkUMBsToMemChain(umb_flag); DOS_SetMemAllocStrategy(old_memstrat); // restore strategy } else this->ParseLine(args); }
void DOS_Shell::CMD_HELP(char * args){ HELP("HELP"); bool optall=ScanCMDBool(args,"ALL"); /* Print the help */ if(!optall) WriteOut(MSG_Get("SHELL_CMD_HELP")); Bit32u cmd_index=0,write_count=0; while (cmd_list[cmd_index].name) { if (optall || !cmd_list[cmd_index].flags) { WriteOut("<\033[34;1m%-8s\033[0m> %s",cmd_list[cmd_index].name,MSG_Get(cmd_list[cmd_index].help)); if(!(++write_count%22)) CMD_PAUSE(empty_string); } cmd_index++; } }
void DOS_Shell::CMD_DELETE(char * args) { HELP("DELETE"); /* Command uses dta so set it to our internal dta */ RealPt save_dta=dos.dta(); dos.dta(dos.tables.tempdta); char * rem=ScanCMDRemain(args); if (rem) { WriteOut(MSG_Get("SHELL_ILLEGAL_SWITCH"),rem); return; } /* If delete accept switches mind the space infront of them. See the dir /p code */ char full[DOS_PATHLENGTH],sfull[DOS_PATHLENGTH+2]; char buffer[CROSS_LEN]; args = ExpandDot(args,buffer); StripSpaces(args); if (!DOS_Canonicalize(args,full)) { WriteOut(MSG_Get("SHELL_ILLEGAL_PATH"));return; } //TODO Maybe support confirmation for *.* like dos does. char spath[DOS_PATHLENGTH],sargs[DOS_PATHLENGTH]; if (!DOS_GetSFNPath(args,spath,false)) { WriteOut(MSG_Get("SHELL_CMD_DEL_ERROR"),args); return; } sprintf(sargs,"\"%s\"",spath); bool res=DOS_FindFirst(sargs,0xffff & ~DOS_ATTR_VOLUME); if (!res) { WriteOut(MSG_Get("SHELL_CMD_DEL_ERROR"),args); dos.dta(save_dta); return; } //end can't be 0, but if it is we'll get a nice crash, who cares :) char * end=strrchr(full,'\\')+1;*end=0; char name[DOS_NAMELENGTH_ASCII],lname[LFN_NAMELENGTH+1]; Bit32u size;Bit16u time,date;Bit8u attr; DOS_DTA dta(dos.dta()); while (res) { dta.GetResult(name,lname,size,date,time,attr); if (!(attr & (DOS_ATTR_DIRECTORY|DOS_ATTR_READ_ONLY))) { strcpy(end,name); strcpy(sfull,full); if (uselfn) sprintf(sfull,"\"%s\"",full); if (!DOS_UnlinkFile(sfull)) WriteOut(MSG_Get("SHELL_CMD_DEL_ERROR"),full); } res=DOS_FindNext(); } dos.dta(save_dta); }
static std::string statsHelp() { return HELP( TLDR( "Shows local system metrics."), DESCRIPTION( "> cpus_total Total number of available CPUs", "> load_1min Average system load for last" " minute in uptime(1) style", "> load_5min Average system load for last" " 5 minutes in uptime(1) style", "> load_15min Average system load for last" " 15 minutes in uptime(1) style", "> memory_total_bytes Total system memory in bytes", "> memory_free_bytes Free system memory in bytes")); }
int Organize::test(){ //Functions to test are: assert(ADD_TRACK() == 0x01); assert(HELP()== 0x02); assert(GET_TRACK_SEQUENCE() == 0x04); assert(LIST_TRACKS() == 0x08); assert(RECENT_SEGMENT() == 0x10); assert(MARK_FINISHED() == 0x20); assert(COMPLETED_MOST_RECENT() == 0x40); // int check_arguments(const vector<string> arguments,string& location ); // int execute_arguments(const int arguments, string& location); // vector<string> extract_arguments(const char* array[], const int count); // int Organize::process_arguments(const int argc, const char *argv[]){ // int main(int argc, char* argv[]); //const_expr int ADD_TRACK() }
void DOS_Shell::CMD_PATH(char *args){ HELP("PATH"); if(args && *args && strlen(args)){ char pathstring[DOS_PATHLENGTH+CROSS_LEN+20]={ 0 }; strcpy(pathstring,"set PATH="); while(args && *args && (*args=='='|| *args==' ')) args++; strcat(pathstring,args); this->ParseLine(pathstring); return; } else { std::string line; if(GetEnvStr("PATH",line)) { WriteOut("%s",line.c_str()); } else { WriteOut("PATH=(null)"); } } }
/* GMP_CPU_FREQUENCY environment variable. Should be in Hertz and can be floating point, for example "450e6". */ static int freq_environment (int help) { char *e; HELP ("environment variable GMP_CPU_FREQUENCY (in Hertz)"); e = getenv ("GMP_CPU_FREQUENCY"); if (e == NULL) return 0; speed_cycletime = 1.0 / atof (e); if (speed_option_verbose) printf ("Using GMP_CPU_FREQUENCY %.2f for cycle time %.3g\n", atof (e), speed_cycletime); return 1; }
void DOS_Shell::CMD_VER(char *args) { HELP("VER"); if(args && *args) { char* word = StripWord(args); if(strcasecmp(word,"set")) return; word = StripWord(args); if (!*args && !*word) { //Reset dos.version.major = 7; dos.version.minor = 10; } else if (*args == 0 && *word && (strchr(word,'.') != 0)) { //Allow: ver set 7.10 const char * p = strchr(word,'.'); dos.version.major = (Bit8u)(atoi(word)); dos.version.minor = (Bit8u)(atoi(p+1)); } else { //Official syntax: ver set 7 10 dos.version.major = (Bit8u)(atoi(word)); dos.version.minor = (Bit8u)(atoi(args)); } if (autolfn) uselfn=dos.version.major>=7; } else WriteOut(MSG_Get("SHELL_CMD_VER_VER"),VERSION,dos.version.major,dos.version.minor,uselfn?"enabled":"disabled"); }
void DOS_Shell::CMD_GOTO(char * args) { HELP("GOTO"); StripSpaces(args); if (!bf) return; if (*args &&(*args==':')) args++; //label ends at the first space char* non_space = args; while (*non_space) { if((*non_space == ' ') || (*non_space == '\t')) *non_space = 0; else non_space++; } if (!*args) { WriteOut(MSG_Get("SHELL_CMD_GOTO_MISSING_LABEL")); return; } if (!bf->Goto(args)) { WriteOut(MSG_Get("SHELL_CMD_GOTO_LABEL_NOT_FOUND"),args); return; } }
static int freq_pstat_getprocessor (int help) { #if HAVE_PSTAT_GETPROCESSOR && HAVE_PSP_ITICKSPERCLKTICK struct pst_processor p; HELP ("pstat_getprocessor() psp_iticksperclktick"); if (pstat_getprocessor (&p, sizeof(p), 1, 0) != -1) { long c = clk_tck(); speed_cycletime = 1.0 / (c * p.psp_iticksperclktick); if (speed_option_verbose) printf ("Using pstat_getprocessor() psp_iticksperclktick %lu and clk_tck %ld for cycle time %.3g\n", (unsigned long) p.psp_iticksperclktick, c, speed_cycletime); return 1; } #endif return 0; }
static int freq_irix_hinv (int help) { int ret = 0; #if HAVE_POPEN FILE *fp; char buf[128]; double val; int nproc, end; HELP ("IRIX \"hinv -c processor\" output"); /* Error messages are sent to /dev/null in case hinv doesn't exist. The brackets are necessary for some shells. */ if ((fp = popen ("(hinv -c processor) 2>/dev/null", "r")) != NULL) { while (fgets (buf, sizeof (buf), fp) != NULL) { end = 0; if (sscanf (buf, "Processor 0: %lf MHZ%n", &val, &end) == 1 && end != 0) { found: speed_cycletime = 1e-6 / val; if (speed_option_verbose) printf ("Using hinv -c processor \"%.2f MHZ\" for cycle time %.3g\n", val, speed_cycletime); ret = 1; break; } end = 0; if (sscanf (buf, "%d %lf MHZ%n", &nproc, &val, &end) == 2 && end != 0) goto found; } pclose (fp); } #endif return ret; }