예제 #1
0
파일: main.c 프로젝트: jwongv/cmps012b
int main (int argc, char **argv) {
   execname = basename (argv[0]);
   queue_ref queue = new_queue();

   if (argc < 2) {
      putinqueue (queue, stdin, "-");
   }else {
      for (int argi = 1; argi < argc; ++argi) {
         if (strcmp (argv[argi], "-") == 0) {
            putinqueue (queue, stdin, "-");
         }else {
            putfileinqueue (queue, argv[argi]);
         }
      }
   }

   while (! isempty_queue (queue)) { 
      char *oldstring = remove_queue(queue);
      printf ("%s\n", oldstring);
      free (oldstring);
   }

   free_queue(queue);

   return exit_status;
}
예제 #2
0
파일: main.c 프로젝트: ddsun95/projects
int main (int argc, char **argv) {
   execname = basename(argv[0]);
   queue *the_queue = queue_new();

   if (argc < 2) {
      putinqueue(the_queue, stdin, "-");
   } else {
      for (int argi = 1; argi < argc; ++argi) {
         if (strcmp(argv[argi], "-") == 0) {
            putinqueue(the_queue, stdin, "-");
         } else {
            putfileinqueue(the_queue, argv[argi]);
         }
      }
   }

   while (!queue_isempty(the_queue)) {
	   char* tmp = queue_remove(the_queue);  //assign a temp char pointer to point at the item
      printf("%s\n", tmp);                  //print the item
	   free(tmp);                            //free the pointer
   }

   queue_free(the_queue);                   //free the queue
   return exit_status;
}
예제 #3
0
파일: main.c 프로젝트: rcoley93/coursework
int main (int argc, char **argv) {
   execname = basename(argv[0]);
   queue *the_queue = queue_new();

   if (argc < 2) {
      putinqueue(the_queue, stdin, "-");
   } else {
      for (int argi = 1; argi < argc; ++argi) {
         if (strcmp(argv[argi], "-") == 0) {
            putinqueue(the_queue, stdin, "-");
         } else {
            putfileinqueue(the_queue, argv[argi]);
         }
      }
   }

   while (!queue_isempty(the_queue)) {
      queue_item_t temp = queue_remove(the_queue);
      printf("%s\n", temp);
      free(temp);
   }
   queue_free(the_queue);

   return exit_status;
}
예제 #4
0
파일: main.c 프로젝트: jwongv/cmps012b
void putfileinqueue (queue_ref queue, char *filename) {
   FILE *input = fopen (filename, "r");
   if (input == NULL) {
      fflush (NULL);
      fprintf (stderr, "%s: %s: %s\n",
               execname, filename, strerror (errno));
      fflush (NULL);
      exit_status = EXIT_FAILURE;
   }else {
      putinqueue (queue, input, filename);
      fclose (input);
   }
}
예제 #5
0
int main (int argc, char **argv) {
    execname = basename(argv[0]);
    Queue *the_queue = queue_new();
    
    if (argc < 2) {
        putinqueue(the_queue, stdin, "-");
    } else {
        for (int argi = 1; argi < argc; ++argi) {
            if (strcmp(argv[argi], "-") == 0) {
                putinqueue(the_queue, stdin, "-");
            } else {
                putfileinqueue(the_queue, argv[argi]);
            }
        }
    }
    
    while (!queue_isempty(the_queue)) {
        printf("%s\n", queue_remove(the_queue));
    }
    
    return 0;
}
예제 #6
0
int main (int argc, char **argv) {
   execname = basename (argv[0]);
   queue *the_queue = new_queue();

   if (argc < 2) {
      putinqueue (the_queue, stdin, "-");
   }else {
      for (int argi = 1; argi < argc; ++argi) {
         if (strcmp (argv[argi], "-") == 0) {
            putinqueue (the_queue, stdin, "-");
         }else {
            putfileinqueue (the_queue, argv[argi]);
         }
      }
   }

   while (! isempty_queue (the_queue)) {
      printf ("%s\n", remove_queue (the_queue));
   }

   return exit_status;
}