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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/********************************************************************
* Description: emcargs.cc
* Globals initialized to values in emccfg.h
*
* Derived from a work by Fred Proctor & Will Shackleford
*
* Author:
* License: GPL Version 2
* System: Linux
*
* Copyright (c) 2004 All rights reserved.
*
* Last change:
********************************************************************/
#include <string.h> /* strcpy() */
#include <stdio.h> /* fgets() */
#include "nml.hh" /* nmlSetHostAlias */
#include "emcglb.h" /* these decls */
#include "emccfg.h" /* their initial values */
#include "rcs_print.hh"
int emcGetArgs(int argc, char *argv[])
{
int t;
/* process command line args, indexing argv[] from [1] */
for (t = 1; t < argc; t++) {
if (!strcmp(argv[t], "-ini")) {
if (t == argc - 1) {
return -1;
} else {
if (strlen(argv[t+1]) >= LINELEN) {
fprintf(stderr, "ini file name too long (max %d):\n", LINELEN);
fprintf(stderr, " %s\n", argv[t+1]);
return -1;
}
strcpy(emc_inifile, argv[t + 1]);
t++;
}
continue;
}
if (!strcmp(argv[t], "-rcsdebug")) {
set_rcs_print_flag(PRINT_EVERYTHING);
max_rcs_errors_to_print = -1;
continue;
}
if (!strcmp(argv[t], "-queryhost")) {
char qhost[80];
printf("EMC Host?");
if(!fgets(qhost, 80, stdin)) return -1;
for (int i = 0; i < 80; i++) {
if (qhost[i] == '\r' || qhost[i] == '\n'
|| qhost[i] == ' ') {
qhost[i] = 0;
break;
}
}
nmlSetHostAlias(qhost, "localhost"); /* If localhost
appears in .nml
file it will
overriden by this
argument. */
nmlForceRemoteConnection();
/* The only good reason for aliasing the host that I know of is
to connect to a remote server so we will ignore the
LOCAL/REMOTE field in the .nml file and always connect
remotely. */
continue;
}
if (!strcmp(argv[t], "-host")) {
if (t == argc - 1) {
return -1;
} else {
nmlSetHostAlias(argv[t + 1], "localhost"); /* If
localhost
appears in
.nml file
it will
overriden
by this
argument. */
nmlForceRemoteConnection();
/* The only good reason for aliasing the host that I know of
is to connect to a remote server so we will ignore the
LOCAL/REMOTE field in the .nml file and always connect
remotely. */
t++;
}
continue;
}
}
/* else not recognized-- ignore */
return 0;
}
|