File: comline.c

package info (click to toggle)
xppaut 5.85-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 11,552 kB
  • ctags: 7,725
  • sloc: ansic: 80,633; cpp: 965; makefile: 265
file content (146 lines) | stat: -rw-r--r-- 2,297 bytes parent folder | download | duplicates (3)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include <stdlib.h> 
/* command-line stuff for xpp */
#include <stdio.h>
#define NCMD 10  /* add new commands as needed  */

#define MAKEC 0
#define XORFX 1
#define SILENT 2 
#define CONVERT 3
#define NOICON 4
#define NEWSEED 5
#define ALLWIN 6
#define SETFILE 7
#define MSSTYLE 8
#define PWHITE 9

extern int PaperWhite;
extern int MSStyle;
extern int got_file;
char setfilename[100];
int loadsetfile=0;
extern char this_file[100];
extern int XPPBatch;
extern int xorfix;
extern int newseeed;
extern int silent;
extern int allwinvis;
extern int ConvertStyle;
int noicon=1;
int newseed=0;
typedef struct {
  char name[10];
  int len;

} VOCAB;

VOCAB my_cmd[NCMD]=
{
  "-m",2,
  "-xorfix",7,
  "-silent",7,
  "-convert",8,
  "-iconify",7,
  "-newseed",7,
  "-allwin",6,
  "-setfile",7,
  "-ee",8,
  "-white", 6,
 };

do_comline(argc,argv)
char **argv;
int argc;
{
 int i,k;

 silent = 0;
 got_file=0;
 xorfix=1;
 PaperWhite=0;

 setfilename[0]=0;
 for(i=1;i<argc;i++){
   k=parse_it(argv[i]);
   if(k==1){
     strcpy(setfilename,argv[i+1]);
     i++;
     loadsetfile=1;
     
   }
 }
}

if_needed_load_set()
{
  FILE *fp;
  if(!loadsetfile)
    return 1;
  fp=fopen(setfilename,"r");
  if(fp==NULL){
    printf("Couldn't load %s\n",setfilename);
    return 0;
  }
  read_lunch(fp);
  fclose(fp);
}

parse_it(com)
     char *com;
{
  int j;
  for(j=0;j<NCMD;j++)
    if(strncmp(com,my_cmd[j].name,my_cmd[j].len)==0)break;
  if(j<NCMD){
    switch(j){
    case MAKEC:
      printf(" C files are no longer part of this version. \n Sorry \n");
      break;
    case SILENT:
      XPPBatch=1;
      break;
    case XORFX:
      xorfix=0;
      break;
    case CONVERT:
      ConvertStyle=1;
      break;
    case NOICON:
      noicon=0;
      break;
    case NEWSEED:
      printf("Random number seed changed\n");
      newseed=1;
      break;  
    case ALLWIN:
      allwinvis=1;
      break;
    case MSSTYLE:
      MSStyle=1;
      break;
    case PWHITE:
      PaperWhite=1;
      break;
    case SETFILE:
      return 1;
    }
  }
  else {
    if(com[0]=='-'||got_file==1){
      printf(" xppaut filename -silent -xorfix -convert -newseed -ee -allwin -white -setfile <filename> \n");
      exit(0);
    }
    else {
      strcpy(this_file,com);
      got_file=1;
    }
  }
  return 0;
}