Jspice3
arg.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3e2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1987 Jeffery M. Hsu
5  1992 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 /*
9  * This file contains the routines to evalute arguments to a command
10  * and prompt the user if necessary.
11  */
12 
13 #include "spice.h"
14 #include "ftedefs.h"
15 #include "scedio.h"
16 
17 #define MAXPROMPT 1024
18 static char buf[MAXPROMPT];
19 
20 #ifdef __STDC__
21 static int countargs(wordlist*);
22 static void common(char*,wordlist*,struct comm*);
23 #else
24 static int countargs();
25 static void common( );
26 #endif
27 
28 
29 static int
31 
32 wordlist *wl;
33 {
34 
35  int number=0;
36  wordlist *w;
37 
38  for (w = wl; w; w = w->wl_next) {
39  number++ ;
40  }
41  return(number);
42 
43 }
44 
45 
46 arg_print(wl, command)
47 wordlist *wl;
48 struct comm *command;
49 {
50 
51  common("which variable", wl, command);
52 
53 }
54 
55 arg_plot(wl, command)
56 wordlist *wl;
57 struct comm *command;
58 {
59 
60  common("which variable", wl, command);
61 
62 }
63 
64 arg_load(wl, command)
65 wordlist *wl;
66 struct comm *command;
67 {
68  /* just call com_load */
69  (*command->co_func) (wl);
70 
71 }
72 
73 arg_let(wl, command)
74 wordlist *wl;
75 struct comm *command;
76 {
77 
78  common("which vector", wl, command);
79 
80 }
81 
82 arg_set(wl, command)
83 wordlist *wl;
84 struct comm *command;
85 {
86 
87  common("which variable", wl, command);
88 
89 }
90 
92 {
93 
94  /* just return; display does the right thing */
95 
96 }
97 
98 /* a common prompt routine */
99 static void
100 common(string, wl, command)
101 
102 char *string;
103 struct wordlist *wl;
104 struct comm *command;
105 {
106 
107  struct wordlist *w;
108  char *buf;
109 
110  if (!countargs(wl)) {
111  w = outmenuprompt(string);
112  if (w == NULL)
113  return;
114  (*command->co_func) (w);
115  wl_free(w);
116  }
117 }
118 
119 
120 wordlist *
122 char *string;
123 {
124  wordlist *wl;
125  char buf[100], buf1[100];
126  char *c;
127 
128  sprintf(buf1, "%s: ", string);
129  if (SCEDfgets(buf,sizeof(buf),cp_in,buf1) == NULL)
130  return (NULL);
131  if ((c = strchr(buf,'\n')) != NULL)
132  *c = '\0';
133  wl = alloc(wordlist);
134  wl->wl_word = copy(buf);
135  cp_variablesubst(&wl);
136  cp_bquote(&wl);
137  cp_doglob(&wl);
138  return (wl);
139 }
static char buf[MAXPROMPT]
Definition: arg.c:18
static void common()
arg_print(wordlist *wl, struct comm *command)
Definition: arg.c:46
static int countargs()
void cp_bquote()
Definition: cddefs.h:169
Definition: library.c:18
void cp_doglob()
Definition: cpdefs.h:20
#define alloc(type)
Definition: cdmacs.h:21
arg_set(wordlist *wl, struct comm *command)
Definition: arg.c:82
char * copy()
void wl_free()
#define MAXPROMPT
Definition: arg.c:17
#define NULL
Definition: spdefs.h:121
char * SCEDfgets(char *s, int n, FILE *fp, char *prompt)
Definition: scedstub.c:41
static double c
Definition: vectors.c:16
Definition: cpstd.h:21
arg_load(wordlist *wl, struct comm *command)
Definition: arg.c:64
arg_plot(wordlist *wl, struct comm *command)
Definition: arg.c:55
void cp_variablesubst()
struct wordlist * wl_next
Definition: cpstd.h:23
char * wl_word
Definition: cpstd.h:22
void(* co_func)()
Definition: cpdefs.h:22
FILE * cp_in
Definition: help.c:101
arg_display()
Definition: arg.c:91
wordlist * outmenuprompt(char *string)
Definition: arg.c:121
arg_let(wordlist *wl, struct comm *command)
Definition: arg.c:73