Commit e1dcb880 authored by Matthew Burket's avatar Matthew Burket
Browse files

Got many commands working

parent 62faf159
Loading
Loading
Loading
Loading
Loading
+137 −117
Original line number Diff line number Diff line
@@ -44,15 +44,34 @@ int main() {
            readBuff = strtok(readBuff, "|");
        }
        char commands[10][BUFFSIZE];
        int numCmds = 0;
        char *doMany = strchr(readBuff, ';');
        if (doMany != NULL) {
            if (numCmds >= 10) {
                break;
            }
            char *strtok_save;
            char *del = ";";
            char * cmdTok = strtok_r(readBuff, del, &strtok_save);
            strcpy(commands[0], cmdTok);
            numCmds = 1;
            while (cmdTok != NULL) {
                cmdTok = strtok_r(NULL, del, &strtok_save);
                if (cmdTok == NULL) {
                    break;
                }
                strcpy(commands[numCmds], cmdTok);
                numCmds++;
            }

        } else {

            strcpy(commands[0], readBuff);
            numCmds = 1;
        }

        for (int i = 0; i < numCmds; i++) {
            char **tokens = malloc(sizeof(char) * 5000);
        int numTokens = tokenize(readBuff, tokens);
            int numTokens = tokenize(commands[i], tokens);
            char *lastToken = tokens[numTokens - 2];

            if (strcmp(tokens[0], "cd") == TRUE) {
@@ -193,6 +212,7 @@ int main() {
            free(tokens);
        }
    }
}

void storeHist(char **readBuff, int *historyPos, char historyBuff[50][5000], int numTokens) {
    // History store stuff