File: gmtset.c

package info (click to toggle)
gmt 3.3.3-3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 3,288 kB
  • ctags: 2,962
  • sloc: ansic: 50,470; sh: 1,760; makefile: 284; asm: 38
file content (78 lines) | stat: -rw-r--r-- 2,486 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*--------------------------------------------------------------------
 *    The GMT-system:	@(#)gmtset.c	2.28  09/21/99
 *
 *	Copyright (c) 1991-1999 by P. Wessel and W. H. F. Smith
 *	See COPYING file for copying and redistribution conditions.
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation; version 2 of the License.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	Contact info: www.soest.hawaii.edu/gmt
 *--------------------------------------------------------------------*/
/*
 * gmtset will set the specified options to the argument that follows them.
 *
 * Author:	Paul Wessel
 * Date:	1-JUN-1993
 * Version:	2.0
 * Revised:	07-SEP-1999, for GMT 3.3.2
 */
 
#include "gmt.h"

main (int argc, char **argv)
{
	int i, j;
	char *file = CNULL;
	
        GMT_stdout = stdout;    GMT_stdin = stdin;
	if (argc == 2 && argv[1][0] == '-' && argv[1][1] == 0) GMT_quick = TRUE;
	
	if (argc == 1 || GMT_quick) {
		fprintf (stderr, "gmtset %s - To set individual default parameters\n\n", GMT_VERSION);
		fprintf (stderr, "usage: gmtset [-G<defaultsfile> PARAMETER1 value1 PARAMETER2 value2 PARAMETER3 value3 ...\n");
		fprintf (stderr, "	For available PARAMETERS, see gmtdefaults man page\n");
		
		if (GMT_quick) exit (EXIT_FAILURE);

		fprintf (stderr, "\n\tOPTIONS:\n");
		fprintf (stderr, "	-G sets name of specific .gmtdefaults file to modify\n");
		fprintf (stderr, "	   [Default looks for file in current directory,  If not fould,\n");
		fprintf (stderr, "	   it looks in the home directory, if not found it uses GMT defaults.\n");
		fprintf (stderr, "	   The modified defaults are written to the current directory]\n");
		
		exit (EXIT_FAILURE);
	}
	
	for (i = strlen(argv[0]); i >= 0 && argv[0][i] != '/'; i--);
	GMT_program = &argv[0][i+1];

	for (i = 1, j = 0; i < argc && j == 0; i++) {
		if (!strncmp (argv[i], "-G", 2)) {
			file = &argv[i][2];
			j = i;
		}
	}
	
	if (j) {
		for (i = j + 1; i < argc; i++, j++) argv[j] = argv[i];	/* Remove the -G string */
		argc--;
	}
		
	GMT_getdefaults (file);
	
	GMT_setdefaults (argc, argv);

	if (file)
		GMT_savedefaults (file);
	else
		GMT_savedefaults (".gmtdefaults");

	exit (EXIT_SUCCESS);
}