int main(int argc, char *argv[]) { char *filename; FILE *input; initFunctions(); verifyCommands(); currentFontIdx = 2; currentFont = getFont(currentFontIdx); // printf("Functions initialized.\n"); if (argc == 2) { if (!strcmp(argv[1], "-h")) { usage(); } if (!strcmp(argv[1], "-l")) { listCommands(); } filename = argv[1]; input = fopen(filename, "r"); gdMainLoop(input); fclose(input); } else { gdMainLoop(stdin); } }
void cmdHelp(unsigned int argc,char * argv [ ],int * result) { Trace("Hi, what can I do for you?"); TraceLine(); listCommands(argc, argv, result); TraceLine(); *result = true; }
uint8_t ConsoleMenu::handleInputChar(char c) { if(c == '?') { inputBuffer[inputBufferIndex] = '\0'; Serial.println(); listCommands(inputBuffer); Serial.print(title); Serial.print("> "); Serial.print(inputBuffer); return INPUT_ACT_NONE; } else { return ConsoleMenuItem::handleInputChar(c); } }
boost::optional<int> HelpCmd::run(Dit &, const std::vector<std::string> &args) { if (args.size() > 1U) { err() << "Expected at most one argument.\n"; return EXIT_FAILURE; } if (args.empty()) { return listCommands(); } const std::string &cmdName = args[0]; return commandHelp(cmdName); }
int runCommand(){ int i = 0; int argc = splitString(textBuffer, ' '); for(i =0;i<argc;i++){argv[i]=stringArray[i];} if(k_strcmp(argv[0], "")==0){} else if(k_strcmp(argv[0], "clear")==0){ clearScreen(); typeOffset = 0;} else if(k_strcmp(argv[0], "history")==0){ printHistory();} else if(k_strcmp(argv[0], "pong")==0){ pong();} else if(k_strcmp(argv[0], "help")==0){ listCommands();} else if(k_strcmp(argv[0], "welcome")==0){ welcome();} else if(k_strcmp(argv[0], "splash")==0){ splash();} else if(k_strcmp(argv[0], "ls")==0){ ls(argc, argv); } else if(k_strcmp(argv[0], "cat")==0){ cat(argc, argv); } else if(k_strcmp(argv[0], "rm")==0){ rm(argc, argv); } else if(k_strcmp(argv[0], "chmod")==0){ chmod(argc, argv); } else if(k_strcmp(argv[0], "te")==0){ te(argc, argv); } else if(k_strcmp(argv[0], "cp")==0){ cp(argc, argv); } else if(k_strcmp(argv[0], "diff")==0){ diff(argc, argv); } else if(k_strcmp(argv[0], "wc")==0){ wc(argc, argv); } else if(k_strcmp(argv[0], "su")==0){ su(argc, argv); } else if(k_strcmp(argv[0], "chown")==0){ chown(argc, argv); } else if(k_strcmp(argv[0], "echo")==0){ echo(argc, argv); } else if(k_strcmp(argv[0], "adduser")==0){ adduser(argc, argv); } else if(k_strcmp(argv[0], "deluser")==0){ deluser(argc, argv); } else if(k_strcmp(argv[0], "listus")==0){ listus(); } else if(k_strcmp(argv[0], "passwd")==0){ passwd(argc, argv); } else if(k_strcmp(argv[0], "mkdir")==0){ mkdir(argc, argv); } else if(k_strcmp(argv[0], "rmdir")==0){ rmdir(argc, argv); } else if(k_strcmp(argv[0], "cd")==0){ cd(argc, argv); } else if(k_strcmp(argv[0], "pwd")==0){ pwd(argc, argv); } else if(k_strcmp(argv[0], "mv")==0){ mv(argc, argv); } // else check files else { printToConsole("Error: Unknown command '"); printToConsole(argv[0]); printToConsole("'\n"); } return 0; }
EditorRace::EditorRace(UBSocket* sock) : OLCEditor(sock), m_race() { listCommands(Global::Get()->EmptyString); }
static void makemoves(void) { int i, hitme; char ch; while (TRUE) { /* command loop */ hitme = FALSE; justin = 0; Time = 0.0; i = -1; while (TRUE) { /* get a command */ chew(); skip(1); proutn("COMMAND> "); if (scan() == IHEOL) continue; for (i=0; i < 29; i++) // Abbreviations allowed for the first 29 commands, only. if (isit(commands[i])) break; if (i < 29) break; for (; i < NUMCOMMANDS; i++) if (strcmp(commands[i], citem) == 0) break; if (i < NUMCOMMANDS #ifndef CLOAKING && i != 26 // ignore the CLOAK command #endif #ifndef CAPTURE && i != 27 // ignore the CAPTURE command #endif #ifndef SCORE && i != 28 // ignore the SCORE command #endif #ifndef DEBUG && i != 33 // ignore the DEBUG command #endif ) break; if (skill <= SFAIR) { prout("UNRECOGNIZED COMMAND. LEGAL COMMANDS ARE:"); listCommands(TRUE); } else prout("UNRECOGNIZED COMMAND."); } switch (i) { /* command switch */ case 0: // srscan srscan(1); break; case 1: // lrscan lrscan(); break; case 2: // phasers phasers(); if (ididit) { #ifdef CLOAKING if (irhere && d.date >= ALGERON && !isviolreported && iscloaked) { prout("The Romulan ship discovers you are breaking the Treaty of Algeron!"); ncviol++; isviolreported = TRUE; } #endif hitme = TRUE; } break; case 3: // photons photon(); if (ididit) { #ifdef CLOAKING if (irhere && d.date >= ALGERON && !isviolreported && iscloaked) { prout("The Romulan ship discovers you are breaking the Treaty of Algeron!"); ncviol++; isviolreported = TRUE; } #endif hitme = TRUE; } break; case 4: // move warp(1); break; case 5: // shields sheild(1); if (ididit) { attack(2); shldchg = 0; } break; case 6: // dock dock(); break; case 7: // damages dreprt(); break; case 8: // chart chart(0); break; case 9: // impulse impuls(); break; case 10: // rest waiting(); if (ididit) hitme = TRUE; break; case 11: // warp setwrp(); break; case 12: // status srscan(3); break; case 13: // sensors sensor(); break; case 14: // orbit orbit(); if (ididit) hitme = TRUE; break; case 15: // transport "beam" beam(); break; case 16: // mine mine(); if (ididit) hitme = TRUE; break; case 17: // crystals usecrystals(); break; case 18: // shuttle shuttle(); if (ididit) hitme = TRUE; break; case 19: // Planet list preport(); break; case 20: // Status information srscan(2); break; case 21: // Game Report report(0); break; case 22: // use COMPUTER! eta(); break; case 23: listCommands(TRUE); break; case 24: // Emergency exit clearscreen(); // Hide screen freeze(TRUE); // forced save exit(1); // And quick exit break; case 25: probe(); // Launch probe break; #ifdef CLOAKING case 26: cloak(); // turn on/off cloaking if (iscloaking) { attack(2); // We will be seen while we cloak iscloaking = FALSE; iscloaked = TRUE; } break; #endif #ifdef CAPTURE case 27: capture(); // Attempt to get Klingon ship to surrender if (ididit) hitme = TRUE; break; #endif #ifdef SCORE case 28: score(1); // get the score break; #endif case 29: // Abandon Ship abandn(); break; case 30: // Self Destruct dstrct(); break; case 31: // Save Game freeze(FALSE); if (skill > SGOOD) prout("WARNING--Frozen games produce no plaques!"); break; case 32: // Try a desparation measure deathray(); if (ididit) hitme = TRUE; break; #ifdef DEBUG case 33: // What do we want for debug??? debugme(); break; #endif case 34: // Call for help help(); break; case 35: alldone = 1; // quit the game #ifdef DEBUG if (idebug) score(0); #endif break; case 36: helpme(); // get help break; } for (;;) { if (alldone) break; // Game has ended #ifdef DEBUG if (idebug) prout("2500"); #endif if (Time != 0.0) { events(); if (alldone) break; // Events did us in } if (d.galaxy[quadx][quady] == 1000) { // Galaxy went Nova! atover(0); continue; } if (nenhere == 0) movetho(); if (hitme && justin==0) { attack(2); if (alldone) break; if (d.galaxy[quadx][quady] == 1000) { // went NOVA! atover(0); hitme = TRUE; continue; } } break; } if (alldone) break; } }
static void helpme(void) { int i, j; char cmdbuf[32]; char linebuf[132]; FILE *fp; /* Give help on commands */ int key; key = scan(); while (TRUE) { if (key == IHEOL) { proutn("Help on what command?"); key = scan(); } if (key == IHEOL) return; for (i = 0; i < NUMCOMMANDS; i++) { if (strcmp(commands[i], citem)==0) break; } if (i != NUMCOMMANDS) break; skip(1); prout("Valid commands:"); listCommands(FALSE); key = IHEOL; chew(); skip(1); } if (i == 23) { strcpy(cmdbuf, " ABBREV"); } else { strcpy(cmdbuf, " Mnemonic: "); j = 0; while ((cmdbuf[j+13] = toupper(commands[i][j])) != 0) j++; } fp = fopen("sst.doc", "r"); if (fp == NULL) { prout("Spock- \"Captain, that information is missing from the"); prout(" computer. You need to find SST.DOC and put it in the"); prout(" current directory.\""); return; } i = strlen(cmdbuf); do { if (fgets(linebuf, 132, fp) == NULL) { prout("Spock- \"Captain, there is no information on that command.\""); fclose(fp); return; } } while (strncmp(linebuf, cmdbuf, i) != 0); skip(1); prout("Spock- \"Captain, I've found the following information:\""); skip(1); do { if (linebuf[0]!=12) { // ignore page break lines linebuf[strlen(linebuf)-1] = '\0'; // No \n at end prout(linebuf); } fgets(linebuf,132,fp); } while (strstr(linebuf, "******")==NULL); fclose(fp); }
EditorArea::EditorArea(UBSocket* sock) : OLCEditor(sock), m_area() { listCommands(Global::Get()->EmptyString); }
static void makemoves(void) { int i, hitme; char ch; while (TRUE) { /* command loop */ hitme = FALSE; justin = 0; Time = 0.0; i = -1; while (TRUE) { /* get a command */ chew(); skip(1); proutn("COMMAND> "); // Use of scan() here (after chew) will get a new line of input // and will return IHEOL iff new line of input contains nothing // or a numeric input is detected but conversion fails. if (scan() == IHEOL) continue; for (i=0; i < 26; i++) if (isit(commands[i])) break; if (i < 26) break; for (; i < NUMCOMMANDS; i++) if (strcmp(commands[i], citem) == 0) break; if (i < NUMCOMMANDS) break; // we get here iff the first parsed input from the line does not // match one of the commands. In this case, the rest of the line // is discarded, the below message is printed, and we go back to // get a new command. if (skill <= 2) { prout("UNRECOGNIZED COMMAND. LEGAL COMMANDS ARE:"); listCommands(TRUE); } else prout("UNRECOGNIZED COMMAND."); } // end get command loop // we get here iff the first parsed input from the line matches one // of the commands (i.e., command i). We use i to dispatch the // handling of the command. The line may still contain additional // inputs (i.e., parameters of the command) that is to be parsed by // the dispatched command handler. If the line does not contain // all the necessary parameters, the dispatched command handler is // responsible to get additional input(s) interactively using scan(). // The dispatched command handler is also responsible to handle any // input errors. switch (i) { /* command switch */ case 0: // srscan srscan(1); break; case 1: // lrscan lrscan(); break; case 2: // phasers phasers(); if (ididit) hitme = TRUE; break; case 3: // photons photon(); if (ididit) hitme = TRUE; break; case 4: // move warp(1); break; case 5: // shields sheild(1); if (ididit) { attack(2); shldchg = 0; } break; case 6: // dock dock(); break; case 7: // damages dreprt(); break; case 8: // chart chart(0); break; case 9: // impulse impuls(); break; case 10: // rest waiting(); if (ididit) hitme = TRUE; break; case 11: // warp setwrp(); break; case 12: // status srscan(3); break; case 13: // sensors sensor(); break; case 14: // orbit orbit(); if (ididit) hitme = TRUE; break; case 15: // transport "beam" beam(); break; case 16: // mine mine(); if (ididit) hitme = TRUE; break; case 17: // crystals usecrystals(); break; case 18: // shuttle shuttle(); if (ididit) hitme = TRUE; break; case 19: // Planet list preport(); break; case 20: // Status information srscan(2); break; case 21: // Game Report report(0); break; case 22: // use COMPUTER! eta(); break; case 23: listCommands(TRUE); break; case 24: // Emergency exit clearscreen(); // Hide screen freeze(TRUE); // forced save exit(1); // And quick exit break; case 25: probe(); // Launch probe break; case 26: // Abandon Ship abandn(); break; case 27: // Self Destruct dstrct(); break; case 28: // Save Game freeze(FALSE); if (skill > 3) prout("WARNING--Frozen games produce no plaques!"); break; case 29: // Try a desparation measure deathray(); if (ididit) hitme = TRUE; break; case 30: // What do we want for debug??? #ifdef DEBUG debugme(); #endif break; case 31: // Call for help help(); break; case 32: alldone = 1; // quit the game #ifdef DEBUG if (idebug) score(); #endif break; case 33: helpme(); // get help break; } // end command switch for (;;) { if (alldone) break; // Game has ended #ifdef DEBUG if (idebug) prout("2500"); #endif if (Time != 0.0) { events(); if (alldone) break; // Events did us in } if (d.galaxy[quadx][quady] == 1000) { // Galaxy went Nova! atover(0); continue; } if (nenhere == 0) movetho(); if (hitme && justin==0) { attack(2); if (alldone) break; if (d.galaxy[quadx][quady] == 1000) { // went NOVA! atover(0); hitme = TRUE; continue; } } break; } // end event loop if (alldone) break; } // end command loop }