home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pcmagazi / 1992 / 12 / ini.c < prev    next >
Text File  |  1992-06-07  |  2KB  |  66 lines

  1.  
  2. // INI 1.0
  3. // Copyright (c) 1986-87 Fran Finnegan Associates
  4. // Copyright (c) 1988-92 Finnegan O'Malley & Company Inc.
  5. // All Rights Reserved.
  6. // First Published in PC Magazine, June 30, 1992.
  7.  
  8. // originally developed under Microsoft C 4.0
  9. // updated for Microsoft C 5.1
  10.  
  11. #include <stdio.h>
  12. #include <string.h>
  13.  
  14. #include "config.i"
  15. #include "const.i"
  16. #include "string.i"
  17.  
  18. #include "charasci.c"
  19. #include "config.c"
  20. #include "filespec.c"
  21. #include "strtrunc.c"
  22.  
  23. extern    int        main(int argc, char **argv);
  24.  
  25. static    char        Copyright[] =
  26.         "%s 1.0\n"
  27.         "Copyright (c) 1988-92 Finnegan O'Malley & Company Inc.  "
  28.         "All Rights Reserved.\n"
  29.         "First Published in PC Magazine, June 30, 1992.\n";
  30.  
  31. /////////////////////////////////////////////////////////////////
  32.  
  33. extern    int        main
  34. (
  35.     int        argc,
  36.     char        **argv
  37. )
  38. {
  39. static    char        szNUL[] = "NUL";
  40.  
  41. if (argc != 5 || *argv[1] == '-' || *argv[1] == '/' || *argv[1] == '?')
  42.     {
  43.     fprintf(stderr, Copyright, argv[0]);
  44.     fprintf(stderr, "\nUsage:\t%s filespec \"section\" \"key\" \"string\"\n"
  45.         "where:\t\"section\", \"key\" and/or \"string\" may be \"nul\"\n"
  46.         "\tand must be enclosed in double-quotes if they contain blanks\a\n",
  47.         argv[0]);
  48.     return 1;
  49.     }
  50.  
  51. gbConfigCloseFileOnExit = YES;
  52. gbConfigDeleteBakOnExit = NO;
  53.  
  54. if (!WriteConfigString(argv[1],                 // File
  55.       (!IsStrEquiv(argv[2], szNUL)?  argv[2]:  NULL),    // Section
  56.       (!IsStrEquiv(argv[3], szNUL)?  argv[3]:  NULL),    // Key
  57.       (!IsStrEquiv(argv[4], szNUL)?  argv[4]:  NULL)))    // String
  58.     {
  59.     fprintf(stderr, Copyright, argv[0]);
  60.     fprintf(stderr, "\nError updating %s\a\n", argv[1]);
  61.     return 2;
  62.     }
  63. return 0;
  64. }
  65.  
  66.