#include //#include #include //#include #include //#include //#include //#include //#include #define MAX_LEN 100 int allValidChars(const char * str); int main (void) { while (1) { char *result; char line[MAX_LEN+1] = ""; //read line of input result = fgets(line, MAX_LEN+1, stdin); //check for valid input if(!result) { break; } if(allValidChars(line) == 0) { printf("illegal character in line\n"); return -1; } printf("line looks good, parsing...\n"); //parse the line char token[MAX_LEN+1] = ""; token = strtok(line, " "); printf("first tolken: %s\n",token); char path[MAX_LEN+1] = ""; int len = 0; getcwd(path, len); printf("%s\n",path); if(token[0]!='/') { printf("appending path:\n %s, %i\n",path,len); // path = getcwd(path,len); printf("found CWD, appending\n"); strcat(path, "/"); strcat(path,token); printf("path appended\n"); } else { printf("path already present\n"); path = token; } printf("path: %s\n",path); // printf("line = %s\n",line); } return 0; } int allValidChars(const char * str) { int len = 0; int i = 0; len = strlen(str); for(i=0;i