1 | /* |
---|
2 | * This file is part of the OLC On-Line Consulting System. |
---|
3 | * It contains definitions for the OLC daemon. |
---|
4 | * |
---|
5 | * Win Treese |
---|
6 | * Dan Morgan |
---|
7 | * Bill Saphir |
---|
8 | * MIT Project Athena |
---|
9 | * |
---|
10 | * Ken Raeburn |
---|
11 | * MIT Information Systems |
---|
12 | * |
---|
13 | * Tom Coppeto |
---|
14 | * MIT Project Athena |
---|
15 | * |
---|
16 | * Copyright (c) 1988 by the Massachusetts Institute of Technology |
---|
17 | * |
---|
18 | * $Source: /afs/dev.mit.edu/source/repository/athena/bin/olc/include/olcd.h,v $ |
---|
19 | * $Author: tjcoppet $ |
---|
20 | */ |
---|
21 | |
---|
22 | /* Important files. */ |
---|
23 | |
---|
24 | extern char *NF_PREFIX; |
---|
25 | extern char *LOG_DIR; |
---|
26 | extern char *BACKUP_FILE; |
---|
27 | extern char *BACKUP_TEMP; |
---|
28 | extern char *ERROR_LOG; |
---|
29 | extern char *STATUS_LOG; |
---|
30 | extern char *ADMIN_LOG; |
---|
31 | extern char *STDERR_LOG; |
---|
32 | extern char *DATABASE_FILE; |
---|
33 | extern char *TOPIC_FILE; |
---|
34 | extern char *MOTD_FILE; |
---|
35 | extern char *SPECIALTY_DIR; |
---|
36 | extern char *ACL_DIR; |
---|
37 | |
---|
38 | #ifdef KERBEROS |
---|
39 | extern char K_INSTANCEbuf[]; |
---|
40 | extern char *SRVTAB_FILE; |
---|
41 | #endif KERBEROS |
---|
42 | |
---|
43 | /* system defines */ |
---|
44 | |
---|
45 | #define NOW (time((time_t *)NULL)) |
---|
46 | #define DAEMON_TIME_OUT 10 |
---|
47 | #define MAX_CACHE_SIZE 500 |
---|
48 | |
---|
49 | #ifdef SYSLOG |
---|
50 | #define SYSLOG_LEVEL LOG_LOCAL8 |
---|
51 | #endif SYSLOG |
---|
52 | |
---|
53 | /* for notifications */ |
---|
54 | |
---|
55 | #define OLCD_TIMEOUT 10 |
---|
56 | |
---|
57 | /* random internal flags */ |
---|
58 | |
---|
59 | #define NULL_FLAG 0 |
---|
60 | #define FORWARD 1 |
---|
61 | #define NOTIFY 2 |
---|
62 | #define UNANSWERED 3 /* Question was never answered. */ |
---|
63 | #define ANSWERED 4 /* Question was answered. */ |
---|
64 | #define PING 5 |
---|
65 | #define NO_RESPOND 6 |
---|
66 | |
---|
67 | /* Additional size constants. */ |
---|
68 | |
---|
69 | #define DB_LINE 1000 /* maximum length of a database line.*/ |
---|
70 | #define MAX_SEEN 81 /* Maximum number of consultants to */ |
---|
71 | #define SPEC_SIZE 10 |
---|
72 | |
---|
73 | /* priority queues */ |
---|
74 | |
---|
75 | #define EMERGENCY_Q 1 /* she's having a baby */ |
---|
76 | #define ACTIVE_Q 2 /* alive and well */ |
---|
77 | #define INACTIVE_Q 4 /* runaway */ |
---|
78 | #define PIT_Q 8 /* the ish list */ |
---|
79 | |
---|
80 | /* type classifiers */ |
---|
81 | |
---|
82 | #define IS_TOPIC 500 |
---|
83 | #define IS_SUBTOPIC 501 |
---|
84 | |
---|
85 | |
---|
86 | #define DEFAULT_TITLE "user" |
---|
87 | #define DEFAULT_TITLE2 "consultant" |
---|
88 | |
---|
89 | /* OLCD data definitions */ |
---|
90 | |
---|
91 | typedef struct tUSER |
---|
92 | { |
---|
93 | struct tKNUCKLE **knuckles; /* all user instances */ |
---|
94 | int uid; /* user id */ |
---|
95 | char username[LOGIN_SIZE]; /* user name */ |
---|
96 | char realname[NAME_LENGTH]; |
---|
97 | char nickname[NAME_LENGTH]; |
---|
98 | char title1[NAME_LENGTH]; /* title of user in OLC */ |
---|
99 | char title2[NAME_LENGTH]; /* title of consultant in OLC */ |
---|
100 | char machine[NAME_LENGTH]; /* user location */ |
---|
101 | char realm[NAME_LENGTH]; |
---|
102 | int specialties[SPEC_SIZE]; /* Specialty list. */ |
---|
103 | int no_specialties; |
---|
104 | int permissions; |
---|
105 | int status; /* status of the user |
---|
106 | (logout, idle, etc) */ |
---|
107 | int no_knuckles; /* number of current connections */ |
---|
108 | int max_ask; /* maximum allowable connections */ |
---|
109 | int max_answer; |
---|
110 | } USER; |
---|
111 | |
---|
112 | |
---|
113 | typedef struct tKNUCKLE |
---|
114 | { |
---|
115 | struct tQUESTION *question; /* question */ |
---|
116 | struct tKNUCKLE *connected; /* connected user */ |
---|
117 | struct tUSER *user; /* central user */ |
---|
118 | char title[NAME_LENGTH]; |
---|
119 | int instance; |
---|
120 | int priority; |
---|
121 | int queue; |
---|
122 | long timestamp; /* specific to type */ |
---|
123 | int status; /* status of this instance |
---|
124 | (on priorities, pending, etc..) */ |
---|
125 | char cusername[LOGIN_SIZE]; |
---|
126 | int cinstance; |
---|
127 | char *new_messages; /* new messages from this connection */ |
---|
128 | } KNUCKLE; |
---|
129 | |
---|
130 | typedef struct tQUESTION |
---|
131 | { |
---|
132 | struct tKNUCKLE *owner; |
---|
133 | char logfile[NAME_SIZE]; /* Name of the logfile. */ |
---|
134 | long logfile_timestamp; /* timestamp used for logfile caching */ |
---|
135 | int seen[MAX_SEEN]; /* UIDs of users who have seen |
---|
136 | this question */ |
---|
137 | int nseen; /* Number who have seen it. */ |
---|
138 | char topic[TOPIC_SIZE]; /* topic of this question. */ |
---|
139 | int topic_code; /* number version of the above */ |
---|
140 | char title[NAME_SIZE]; /* Title for log. */ |
---|
141 | char note[NOTE_SIZE]; |
---|
142 | char comment[COMMENT_SIZE]; |
---|
143 | } QUESTION; |
---|
144 | |
---|
145 | typedef struct tTOPIC |
---|
146 | { |
---|
147 | char acl[NAME_LENGTH]; |
---|
148 | char name[NAME_LENGTH]; |
---|
149 | int value; |
---|
150 | struct tTOPIC **subtopic; |
---|
151 | } TOPIC; |
---|
152 | |
---|
153 | typedef struct tOLC_PROC |
---|
154 | { |
---|
155 | int proc_code; /* Request code. */ |
---|
156 | FUNCTION olc_proc; /* Procedure to execute. */ |
---|
157 | char *description; /* What it does. */ |
---|
158 | } PROC; |
---|
159 | |
---|
160 | /* OLC status structure. */ |
---|
161 | |
---|
162 | typedef struct tQUEUE_STATUS |
---|
163 | { |
---|
164 | int consultants; /* Number of visible consultants. */ |
---|
165 | int invisible; /* Number of invisible consultants; */ |
---|
166 | int busy; /* Number of busy consultants. */ |
---|
167 | int waiting; /* Number of waiting users. */ |
---|
168 | } QUEUE_STATUS; |
---|
169 | |
---|
170 | |
---|
171 | typedef struct t_ACL |
---|
172 | { |
---|
173 | int code; |
---|
174 | char *file; |
---|
175 | char *name; |
---|
176 | } ACL; |
---|
177 | |
---|
178 | /* Declarations of functions. */ |
---|
179 | |
---|
180 | |
---|
181 | /* OLC procedure declarations. */ |
---|
182 | |
---|
183 | extern olc_topic(); /* Change the current topic. */ |
---|
184 | extern olc_comment(); /* Insert a comment in the log. */ |
---|
185 | extern olc_describe(); /* Make more comments */ |
---|
186 | extern olc_done(); /* Mark a question done. */ |
---|
187 | extern olc_forward(); /* Forward a question. */ |
---|
188 | extern olc_list(); /* List current conversations. */ |
---|
189 | extern olc_mail(); /* Send mail to a user. */ |
---|
190 | extern olc_on(); /* Sign on to OLC. */ |
---|
191 | extern olc_off(); /* Sign off of OLC. */ |
---|
192 | extern olc_replay(); /* Replay the conversation. */ |
---|
193 | extern olc_send(); /* Send a message. */ |
---|
194 | extern olc_who(); /* Print user's name. */ |
---|
195 | extern olc_startup(); /* Start up an OLCR session. */ |
---|
196 | extern olc_show(); /* Show any new messages. */ |
---|
197 | extern olc_grab(); /* Grab a question on the queue. */ |
---|
198 | extern olc_cancel(); /* Cancel a question. */ |
---|
199 | extern olc_status(); /* Print user status information. */ |
---|
200 | extern olc_ask(); /* ask a question */ |
---|
201 | extern olc_chtopic(); /* change a topic */ |
---|
202 | extern olc_list_topics(); /* list topics */ |
---|
203 | extern olc_create_instance(); /* create a new instance */ |
---|
204 | extern olc_default_instance(); |
---|
205 | extern olc_motd(); /* retrieve the olc motd */ |
---|
206 | extern olc_dump(); /* debugging info */ |
---|
207 | extern olc_cancel(); |
---|
208 | extern olc_verify_topic(); |
---|
209 | extern olc_verify_instance(); |
---|
210 | extern olc_load_user(); |
---|
211 | extern olc_change_motd(); |
---|
212 | extern olc_change_acl(); |
---|
213 | extern olc_get_dbinfo(); |
---|
214 | extern olc_list_acl(); |
---|
215 | extern olc_change_dbinfo(); |
---|
216 | extern olc_get_accesses(); |
---|
217 | |
---|
218 | /* Other external declarations. */ |
---|
219 | |
---|
220 | extern void backup_data(); /* Backup the current state. */ |
---|
221 | |
---|
222 | KNUCKLE *create_user(); |
---|
223 | KNUCKLE *create_knuckle(); |
---|
224 | |
---|
225 | void delete_user(); |
---|
226 | void delete_knuckle(); |
---|
227 | void init_user(); |
---|
228 | QUEUE_STATUS *get_status_info(); |
---|
229 | |
---|
230 | extern char *get_next_word(); |
---|
231 | |
---|
232 | /* System functions. */ |
---|
233 | |
---|
234 | extern char *malloc(), *realloc(); |
---|
235 | |
---|
236 | |
---|
237 | /* Global variables */ |
---|
238 | |
---|
239 | extern KNUCKLE **Knuckle_List; |
---|
240 | extern TOPIC **Topic_List; |
---|
241 | extern int needs_backup; |
---|
242 | |
---|
243 | /* useful macros */ |
---|
244 | |
---|
245 | #define is_allowed(u,a) (u->permissions & a) |
---|
246 | #define is_connected(k) k->connected |
---|
247 | #define has_question(k) k->question |
---|
248 | #define is_signed_on(k) (k->status & SIGNED_ON) |
---|
249 | #define sign_on(k,code) k->status |= code |
---|
250 | #define sign_off(k) k->status = 0 |
---|
251 | #define is_logout(k) (k->user->status & LOGGED_OUT) |
---|
252 | #define is_pitted(k) (k->queue & PIT_Q) |
---|
253 | #define is_busy(k) (k->status & BUSY) |
---|
254 | #define add_status(k,s) k->status |= s |
---|
255 | #define sub_status(k,s) k->status &= ~s |
---|
256 | #define set_status(k,s) k->status = s |
---|
257 | #define is_active(k) ((k->status) || (k->connected)) |
---|
258 | #define deactivate(k) k->status = 0; |
---|
259 | #define is_me(r,t) (r->user == t->user) |
---|
260 | #define is_connected_to(t,r) (r->connected) && (t->connected) && \ |
---|
261 | (r->connected == t) && (t->connected == r) |
---|
262 | #define is_specialty(user,code) is_topic(user->specialties,code) |
---|
263 | |
---|
264 | #define ON_ACL 1<<1 |
---|
265 | #define MONITOR_ACL 1<<2 |
---|
266 | #define OLC_ACL 1<<3 |
---|
267 | #define CONSULT_ACL 1<<4 |
---|
268 | #define GRAB_ACL 1<<5 |
---|
269 | #define GRESOLVE_ACL 1<<6 |
---|
270 | #define GASK_ACL 1<<7 |
---|
271 | #define GCOMMENT_ACL 1<<8 |
---|
272 | #define GMESSAGE_ACL 1<<9 |
---|
273 | #define ADMIN_ACL 1<<10 |
---|
274 | #define GCHTOPIC_ACL 1<<11 |
---|
275 | #define MOTD_ACL 1<<12 |
---|
276 | |
---|