Program to generate an xml file based on a provided text file
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

54 lines
1.1 KiB

  1. /* Christopher Cromer
  2. * Ingeniería Civil en Informática
  3. * */
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include "main.h"
  8. #include "readconfig.h"
  9. int main(int argc, char *argv[]) {
  10. char *config_file = "";
  11. if (argc == 1) {
  12. /* No arguments were passed */
  13. printusage(0);
  14. return 1;
  15. }
  16. /* Read the command line arguments */
  17. int i;
  18. for (i = 1; i < argc; i++) {
  19. if ((strcmp(argv[i], "-c") == 0 || strcmp(argv[i], "--config") == 0) && i != argc - 1 && strlen(config_file) == 0) {
  20. config_file = (char *) malloc(strlen(argv[i + 1]) * sizeof(char));
  21. config_file = argv[i + 1];
  22. /* Use config file */
  23. break;
  24. }
  25. else {
  26. /* Incorrect usage or used the same option more than once */
  27. printusage(1);
  28. return 1;
  29. }
  30. }
  31. int status = readconfig(config_file);
  32. if (status != 0) {
  33. return 1;
  34. }
  35. return 0;
  36. }
  37. /* Print how to use the program
  38. * */
  39. void printusage(int error) {
  40. if (error == 1) {
  41. printf("Opcion desconocido!\n\n");
  42. }
  43. printf("usage: generarxml [opciones] \n");
  44. printf(" -s, --config <archivo> archivo de configuración\n");
  45. }