void ifIFDIFI(string &line, void(*push)(bool)) { string een,twee; een=tolower(trim(getargument(line))); needcomma(line); twee=tolower(trim(getargument(line))); (*push)(een!=twee); }
void ifIFIDN(string &line, void(*push)(bool)) { string een,twee; een=trim(getargument(line)); needcomma(line); twee=trim(getargument(line)); (*push)(een==twee); }
void ifIFINI(string &line, void(*push)(bool)) { bool c=false; string een; een=tolower(trim(getargument(line))); while (1) { if (!comma(line)) break; if (een==tolower(trim(getargument(line)))) c=true; } (*push)(c); }
void decode() { extopcode *eop; eop = (extopcode *) (M + ic); /* pointer to extended opcode in M */ lastic = ic; /* save ic for possible redecoding */ ic += APOPCODE; opcode = ((int) eop->opcode) & 0xFF; getargument (a1, 0); getargument (a2, 1); getargument (a3, 2); }
/*allow the user to create a text file*/ void docreate(char* line) { char file[12800]; int index=0; char* name=getargument(line); char c=0; printstring("Enter your text. End the file by typing CTRL-C.\r\n\n\0"); /*terminates when user presses CTRL-C - 3) */ while(c!=0x3) { /*get a character and store it*/ c=getchar(); file[index++]=c; /*echo it back if it isn't CTRL-C*/ if (c!=0x3) putchar(c); /*if the user presses ENTER, follow the CR with a LF*/ if (c==0xd) { file[index++]=0xa; putchar(0xa); } } /*terminate the file with a 0*/ file[index-1]=0x0; /*write it to the disk. Round up the sector*/ writefile(name,file,div(index,512)+1); printstring("\r\n\0"); }
void doCreateFile(char* line) { char file[12800]; int index=0; char* name=getargument(line); char c=0; printstring("Ingrese el texto del archivo, para finalizar escriba Ctrl + C.\r\n\n\0"); while(c!=0x3) { c=getchar(); file[index++]=c; if (c!=0x3) putchar(c); //putchar(c); if (c==0xd) { file[index++]=0xa; putchar(0xa); } } file[index-1]=0x0; guardarArchivo(name,file, index); }
/*load the file and print out the contents. assume that's it's ASCII*/ void dotype(char* line) { char file[12800]; char* name=getargument(line); file[0]=0x1; readfile(name,file); if (file[0]==0x1) { printstring("File not found\r\n\0"); } else { printstring(file); } }
/*execute a program. fore is 1 if the shell is meant to be paused while the program runs*/ void doexecute(char* line, int fore) { char program[12800]; /*extract the name from the command line*/ char* name=getargument(line); /*check that a program is loaded by putting 0 in the first byte. if it stays, wasn't loaded*/ /*I guess it's bad luck if the program starts with 0*/ program[0]=0x0; readfile(name,program); if (program[0]==0x0) { printstring("Program not found\r\n\0"); } else { /*use fore to pick one of the library functions*/ if (fore==1) executeprogram(program,12800); else executeprogrambackground(program,12800); } }
void doCount(char* line) { char* nombre = getargument(line); strTok(nombre); }
void doEcho(char* line) { char* nombre = getargument(line); leerArchivo(nombre); }
void doRemove(char* line) { char* nombre=getargument(line); //printstring(nombre); Remove(nombre); }
void domkdir(char* line) { char* directorio=getargument(line); mkdir(directorio); }
/*delete a file*/ void dodelete(char* line) { char* name=getargument(line); /*make the system call*/ deletefile(name); }
int pregetmacro(string &line, bool icase, RawSource *rs, bool list, bool recursive) { Macro mac; mac._list=list; mac._recursive=recursive; string d,name=getid(line); if (name.empty()) { error1("Illegal macroname"); return 0; } while('>') { skipblanks(line); if (!line[0]) break; if (isalpha(line[0])) { d=getid(line); mac._namParam.push_back(d); if (sbcneed(line,'+')) mac._greedy=true; if (sbcneed(line,':')) { d=getargument(line,mac._greedy); } else d="\01"; mac._namDefaults.push_back(d); if (mac._greedy) break; if (comma(line)) continue; break; } if (isdigit(line[0])) { if (!getConstant(line,mac._minnum)) { error1("constant expected"); return 0; } if (need(line,"..")) { skipblanks(line); if (sbcneed(line,'*')) mac._maxnum=BIGVALUE; else { if (!getConstant(line,mac._maxnum)) { error1("constant expected"); return 0; } } } else mac._maxnum=mac._minnum; if (mac._minnum<0 || mac._maxnum<mac._minnum) { error1("Illegal parameter"); return 0; } if (sbcneed(line,'+')) if (mac._maxnum<BIGVALUE) mac._greedy=true; else error1("No greedy stars allowed!"); break; } if (sbcneed(line,'*')) { mac._minnum=0; mac._maxnum=BIGVALUE; if (sbcneed(line,'+')) error1("No greedy stars allowed!"); break; } error1("Syntax error"); break; } if (mac._maxnum>mac._minnum && line[0]) { int i=mac._maxnum-mac._minnum; bool gr=false; while (i--) { if (!line[0]) break; if (!i) gr=mac._greedy; d=getargument(line,gr); mac._numDefaults.push_back(d); } } if (mac._minnum) mac._minparam=(int)mac._namParam.size()+mac._minnum; else { int i=(int)mac._namParam.size(); mac._minparam=0; while (i--) if (mac._namDefaults[i]=="\01") { mac._minparam=i+1; break; } } if (mac._greedy || mac._maxnum==BIGVALUE) mac._maxparam=BIGVALUE; else mac._maxparam=(int)mac._namParam.size()+mac._maxnum; if (listopt._macroname.empty()) mac._line=curlin; else mac._line=listopt._macrocurlin; mac._filename=listopt._filename; mac._body=rs->ReadUntil(macronl,macroel,"macro"); if (!listopt._macroname.empty()) listopt._macrocurlin+=(int)mac._body.size()+1; mactab.add(name,icase,mac); return 1; }
/*kill a process*/ void dokill(char* line) { /*make the system call*/ char* arg=getargument(line); int21(9,arg[0]-0x30); }
void TxtTabular::parsefrom(StrPtr icols, StrPtr icontent) { QString cols=icols; colaligns.reset(); while (qstrlen(cols)>0) { bool processed=false; if ((!processed)&&(cols[0]=='|')) { vertlineleftfrom.add(colaligns.G_count()); cols.substring(1,cols.G_length()); processed=true; } if ((!processed)&&(cols[0]=='l')) { colaligns.add(-1); fixedcolsizes.add(-1); cols.substring(1,cols.G_length()); processed=true; } if ((!processed)&&(cols[0]=='c')) { colaligns.add(0); fixedcolsizes.add(-1); cols.substring(1,cols.G_length()); processed=true; } if ((!processed)&&(cols[0]=='r')) { colaligns.add(+1); fixedcolsizes.add(-1); cols.substring(1,cols.G_length()); processed=true; } if ((!processed)&&(cols[0]=='p')) { cols.substring(1,cols.G_length()); QString substr; colaligns.add(-1); getargument(cols,substr,true); fixedcolsizes.add(ConvertSize(substr,fnt)); processed=true; } } colcount=colaligns.G_count(); QString content;content=icontent; while (content.G_length()>0) { QString linetxt; content.splitstring(_qstr("\\\\"),linetxt); eatstartspaces(linetxt); if (trykeyword(linetxt,_qstr("\\hline"))) { horlinetopof.add(lines.G_count()); eatstartspaces(linetxt); } if (linetxt.G_length()>0) { TabularLine *line=new TabularLine;lines.add(line); int curcolnr=0; while (linetxt.G_length()>0) { QString celltxt; linetxt.splitstring(_qstr("&"),celltxt); eatstartspaces(celltxt);eatendspaces(celltxt); TabularCell *cell=new TabularCell(env,fnt); cell->colnr_start=curcolnr;cell->colnr_end=curcolnr; if (trykeyword(celltxt,_qstr("\\multicolumn"))) { QString arg_num,arg_align,arg_content; getargument(celltxt,arg_num,true); getargument(celltxt,arg_align,true); getargument(celltxt,arg_content,true); if (arg_align[0]=='l') cell->align=-1; if (arg_align[0]=='c') cell->align= 0; if (arg_align[0]=='r') cell->align=+1; cell->colnr_end=cell->colnr_start+qstr2int(arg_num)-1; celltxt=arg_content; } cell->parsefrom(celltxt); line->cells.add(cell); curcolnr++; if (curcolnr>colcount) colcount=curcolnr; } } } }
void dols(char * path) { char * pathToList; pathToList = getargument(path); ls(pathToList); }