home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Science / Science.zip / gmt_os2.zip / src / gmtset.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-09  |  1.8 KB  |  66 lines

  1. /*--------------------------------------------------------------------
  2.  *    The GMT-system:    @(#)gmtset.c    2.10  2/9/95
  3.  *
  4.  *    Copyright (c) 1991-1995 by P. Wessel and W. H. F. Smith
  5.  *    See README file for copying and redistribution conditions.
  6.  *--------------------------------------------------------------------*/
  7. /*
  8.  * gmtset will set the specified options to the argument that follows them.
  9.  *
  10.  * Author:    Paul Wessel
  11.  * Date:    1-JUN-1993
  12.  * Version:    2.0
  13.  */
  14.  
  15. #include "gmt.h"
  16.  
  17. main (argc, argv)
  18. int argc;
  19. char **argv; {
  20.     int i, j;
  21.     char *file = 0;
  22.     
  23.     if (argc == 2 && argv[1][0] == '-' && argv[1][1] == 0) gmt_quick = TRUE;
  24.     
  25.     if (argc == 1 || gmt_quick) {
  26.         fprintf (stderr, "gmtset %s - To set individual default parameters\n\n", GMT_VERSION);
  27.         fprintf (stderr, "usage: gmtset [-G<defaultsfile> PARAMETER1 value1 PARAMETER2 value2 PARAMETER3 value3 ...\n");
  28.         fprintf (stderr, "    For available PARAMETERS, see gmtdefaults man page\n");
  29.         
  30.         if (gmt_quick) exit(-1);
  31.  
  32.         fprintf (stderr, "\n\tOPTIONS:\n");
  33.         fprintf (stderr, "    -G sets name of specific .gmtdefaults file to modify\n");
  34.         fprintf (stderr, "       [Default looks for file in current directory,  If not fould,\n");
  35.         fprintf (stderr, "       it looks in the home directory, if not found it uses GMT defaults.\n");
  36.         fprintf (stderr, "       The modified defaults are written to the current directory]\n");
  37.         
  38.         exit (-1);
  39.     }
  40.     
  41.     gmt_program = argv[0];
  42.     
  43.     for (i = 1, j = 0; i < argc && j == 0; i++) {
  44.         if (!strncmp (argv[i], "-G", 2)) {
  45.             file = &argv[i][2];
  46.             j = i;
  47.         }
  48.     }
  49.     
  50.     if (j) {
  51.         for (i = j + 1; i < argc; i++, j++) argv[j] = argv[i];    /* Remove the -G string */
  52.         argc--;
  53.     }
  54.         
  55.     get_gmtdefaults (file);
  56.     
  57.     gmt_setdefaults (argc, argv);
  58.  
  59.     if (file)
  60.         gmt_savedefaults (file);
  61.     else
  62.         gmt_savedefaults (".gmtdefaults");
  63.  
  64.     exit (0);
  65. }
  66.