test/test_physfs.c
changeset 72 ad828df14344
parent 42 c9cab2b09437
child 74 a4a5066fb640
equal deleted inserted replaced
71:105bdb041c03 72:ad828df14344
     7  */
     7  */
     8 
     8 
     9 #include <stdio.h>
     9 #include <stdio.h>
    10 #include <stdlib.h>
    10 #include <stdlib.h>
    11 #include <errno.h>
    11 #include <errno.h>
       
    12 #include <string.h>
       
    13 
       
    14 #if (!defined WIN32)
       
    15 #define HAVE_READLINE
       
    16 #endif
       
    17 
       
    18 #if (defined HAVE_READLINE)
    12 #include <unistd.h>
    19 #include <unistd.h>
    13 #include <readline.h>
    20 #include <readline.h>
    14 #include <history.h>
    21 #include <history.h>
       
    22 #endif
       
    23 
    15 #include "physfs.h"
    24 #include "physfs.h"
    16 
    25 
    17 #define TEST_VERSION_MAJOR  0
    26 #define TEST_VERSION_MAJOR  0
    18 #define TEST_VERSION_MINOR  1
    27 #define TEST_VERSION_MINOR  1
    19 #define TEST_VERSION_PATCH  0
    28 #define TEST_VERSION_PATCH  0
   471         } /* for */
   480         } /* for */
   472 
   481 
   473         if (i->cmd == NULL)
   482         if (i->cmd == NULL)
   474             printf("Unknown command. Enter \"help\" for instructions.\n");
   483             printf("Unknown command. Enter \"help\" for instructions.\n");
   475 
   484 
       
   485 #if (defined HAVE_READLINE)
   476         add_history(complete_cmd);
   486         add_history(complete_cmd);
   477         if (history_file)
   487         if (history_file)
   478         {
   488         {
   479             fprintf(history_file, "%s\n", complete_cmd);
   489             fprintf(history_file, "%s\n", complete_cmd);
   480             fflush(history_file);
   490             fflush(history_file);
   481         } /* if */
   491         } /* if */
       
   492 #endif
       
   493 
   482     } /* if */
   494     } /* if */
   483 
   495 
   484     free(cmd_copy);
   496     free(cmd_copy);
   485     return(rc);
   497     return(rc);
   486 } /* process_command */
   498 } /* process_command */
   487 
   499 
   488 
   500 
   489 static void open_history_file(void)
   501 static void open_history_file(void)
   490 {
   502 {
       
   503 #if (defined HAVE_READLINE)
   491 #if 0
   504 #if 0
   492     const char *envr = getenv("TESTPHYSFS_HISTORY");
   505     const char *envr = getenv("TESTPHYSFS_HISTORY");
   493     if (!envr)
   506     if (!envr)
   494         return;
   507         return;
   495 #else
   508 #else
   528         printf("\n\n"
   541         printf("\n\n"
   529                "Could not open history file [%s] for appending!\n"
   542                "Could not open history file [%s] for appending!\n"
   530                "  Will not be able to record this session's history.\n\n",
   543                "  Will not be able to record this session's history.\n\n",
   531                 envr);
   544                 envr);
   532     } /* if */
   545     } /* if */
       
   546 #endif
   533 } /* open_history_file */
   547 } /* open_history_file */
   534 
   548 
   535 
   549 
   536 int main(int argc, char **argv)
   550 int main(int argc, char **argv)
   537 {
   551 {
   553 
   567 
   554     printf("Enter commands. Enter \"help\" for instructions.\n");
   568     printf("Enter commands. Enter \"help\" for instructions.\n");
   555 
   569 
   556     do
   570     do
   557     {
   571     {
       
   572 #if (defined HAVE_READLINE)
   558         buf = readline("> ");
   573         buf = readline("> ");
       
   574 #else
       
   575         buf = malloc(512);
       
   576         memset(buf, '\0', 512);
       
   577         scanf("%s", buf);
       
   578 #endif
   559         rc = process_command(buf);
   579         rc = process_command(buf);
   560         free(buf);
   580         free(buf);
   561     } while (rc);
   581     } while (rc);
   562 
   582 
   563     if (!PHYSFS_deinit())
   583     if (!PHYSFS_deinit())