-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPROMPT.C
139 lines (123 loc) · 3.19 KB
/
PROMPT.C
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
#include <stdio.h>
#include <ctype.h>
#include <bbs.h>
/* Change the privelege levels for the Main Commands, write it back out. */
set_main(p)
char *p;
{
int f;
f= _xopen("mainpriv.bbs",2); /* open the file, */
if (f == -1) /* if not exist, make one, */
f= _xcreate("mainpriv.bbs",2);
cmd_table(p,&main_priv); /* process commands, */
_xwrite(f,&main_priv,sizeof(main_priv));
_xclose(f);
}
/* Change the privelege levels for the msg Commands, write it back out. */
set_msg(p)
char *p;
{
int f;
f= _xopen("msgpriv.bbs",2); /* open the file, */
if (f == -1) /* if not exist, make one, */
f= _xcreate("msgpriv.bbs",2);
cmd_table(p,&msg_priv); /* process commands, */
_xwrite(f,&msg_priv,sizeof(msg_priv));
_xclose(f);
}
/* Change the privelege levels for the mail Commands, write it back out. */
set_m_msg(p)
char *p;
{
int f;
f= _xopen("mailpriv.bbs",2); /* open the file, */
if (f == -1) /* if not exist, make one, */
f= _xcreate("mailpriv.bbs",2);
cmd_table(p,&mail_priv); /* process commands, */
_xwrite(f,&mail_priv,sizeof(mail_priv));
_xclose(f);
}
/* Change the privelege levels for the file Commands, write it back out. */
set_file(p)
char *p;
{
int f;
f= _xopen("filepriv.bbs",2); /* open the file, */
if (f == -1) /* if not exist, make one, */
f= _xcreate("filepriv.bbs",2);
cmd_table(p,&file_priv); /* process commands, */
_xwrite(f,&file_priv,sizeof(file_priv));
_xclose(f);
}
/* Display and change the table of command names. */
cmd_table(p,t)
char *p;
struct _cmd *t;
{
char ps[80];
if (num_args(p) < 2) { /* if not enough args, */
while (*t-> name) {
mprintf("%-15s ",t-> name);
getpriv(t-> priv);
mprintf("\r\n");
++t;
}
} else if (*p == '?') {
mprintf("Change/display command privelege levels. To change,\r\n");
mprintf("enter the command letter followed by the priv level:\r\n");
mprintf("3 A NORMAL or 3 R PRIVEL, etc. The levels are: TWIT,\r\n");
mprintf("DISGRACE, NORMAL, PRIVEL, EXTRA, SYSOP.\r\n");
} else { /* else attempt to change */
while (*t-> name) {
if (tolower(*p) == tolower(*t-> name)) {
cpyarg(ps,next_arg(p));
stolower(ps);
setpriv(ps,&t-> priv);
break;
}
++t;
}
}
}
/* Build a menu from the structure passed. This accomodates the
set user screen width. If flag is set, then it lists only the first
char of each command name. Commands are only listed if the privelege
level is high enough. */
prompt(t,flag)
struct _cmd *t;
int flag;
{
int width;
int maxw;
maxw= user-> width;
if (maxw > 40) maxw= 40;
width= 0;
while (*t-> name) {
if (user-> priv >= t-> priv) {
if (flag) {
mprintf("%c ",*t-> name);
} else {
mprintf("%s ",t-> name);
width+= strlen(t-> name);
}
}
++t;
if ((width + strlen(t-> name)) >= maxw) {
mprintf("\r\n");
width= 0;
}
}
}
/* Return true if the character is a command in the table, and the
users privelege level is high enough. */
is_cmd(c,t)
char c;
struct _cmd *t;
{
while (*t-> name) {
if ((tolower(c) == tolower(*t-> name)) && (user-> priv >= t-> priv) )
return(1);
++t;
}
return(0);
}