forked from joakimmelin/sklaffkom
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsklaff.h
More file actions
540 lines (456 loc) · 14.1 KB
/
Copy pathsklaff.h
File metadata and controls
540 lines (456 loc) · 14.1 KB
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
/* sklaff.h */
/*
* SklaffKOM, a simple conference system for UNIX.
*
* Copyright (C) 1993-1994 Torbj|rn B}}th, Peter Forsberg, Peter Lindberg,
* Odd Petersson, Carl Sundbom
*
* Program dedicated to the memory of Staffan Bergstr|m.
*
* For questions about this program, mail sklaff@sklaffkom.se
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <sys/types.h>
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <time.h>
/* Define language desired, one of: SWEDISH or ENGLISH */
#define SWEDISH
/* #define ENGLISH */
/* Define group ids and terminaltypes for modem_pool */
#define MODEM_POOL "silly"
#define MODEM_GROUP 50
#define INET_GROUP 60
/* Allow news postings in news-conferences */
/* #undef POSTING_OK */
/* #define POSTING_OK */
/* Machine name for news postings */
#define MACHINE_NAME "skom.se"
/* User to mail for new accounts */
#define SKLAFF_ACCT "sklaff"
/* For "batch" command */
#define SKLAFF_ID "SKOM II"
#define SKLAFF_LOC "Stockholm, Sweden"
#define SKLAFF_NUM "+46-8-7021174"
#define SKLAFF_SYSOP "Carl Sundbom"
/* User ID of survey reporter account */
#define SKLAFF_SURVEY_REPORTER 5000
/* Default terminal used for clear screen if TERM not correct */
#define NO_TERM "unknown"
#define SKLAFF_TERM "vt100"
/* Default number of days before texts expire */
#define EXP_DEF 10 /* Ordinary confs */
#define EXP_DEF_NEWS 3 /* News confs */
/* System files used by SklaffKOM */
#define UTMP_REC "/var/run/utmp"
#define MAIL_LIB "/var/mail"
#define NEWS_SPOOL "/var/spool/news"
#define NEWS_GROUPS "/var/lib/news/active"
/* Programs used by SklaffKOM */
#define SKLAFFSHELL "/bin/sh"
#define SKLAFFPASSWD "/usr/bin/passwd"
#define SKLAFFGREP "/usr/bin/grep"
#define GREPOPT "-i -F" /* option to grep */
#define SKLAFFAT "/usr/bin/at"
#define SKLAFFECHO "/bin/echo"
#define UPLOADPRGM "/usr/bin/rz"
#define ULOPT1 ""
#define DOWNLOADPRGM "/usr/bin/sz"
#define DLOPT1 ""
#define DLOPT2 ""
#define DLOPT3 ""
#define ZIPPRGM "/usr/bin/zip -9"
#define LSPRGM "/bin/ls"
#define LSOPT "-1" /* option to make one column */
#define MVPRGM "/bin/mv"
#define MAILPRGM "/usr/sbin/sendmail --"
#define NEWSPRGM "/usr/bin/inews"
#define SURVREPORT SKLAFFBIN "/srep"
/* SklaffKOM-files */
#define SKLAFF_DB SKLAFFDIR "/db"
#define USER_DB SKLAFFDIR "/user"
#define FILE_DB SKLAFFDIR "/files"
#define MBOX_DB SKLAFFDIR "/mbox"
#define LOGDIR SKLAFFDIR "/log"
#define USER_FILE SKLAFFDIR "/etc/user"
#define ACTIVE_FILE SKLAFFDIR "/etc/active"
#define CONF_FILE SKLAFFDIR "/etc/conf"
#define NEWS_FILE SKLAFFDIR "/etc/news"
#define INFO_FILE SKLAFFDIR "/etc/info"
#define LICENS_FILE SKLAFFDIR "/etc/COPYING"
#define DOWN_FILE SKLAFFDIR "/etc/down"
#define PAY_FILE SKLAFFDIR "/etc/pay"
#define INET_FILE SKLAFFDIR "/etc/inet"
#define ACCT_FILE SKLAFFDIR "/etc/newacct"
#define ACCT_LOG SKLAFFDIR "/etc/acctlog"
#define STD_CONFS SKLAFFDIR "/etc/stdconfs"
#define GLOBAL_SKLAFFRC SKLAFFDIR "/etc/sklaffrc"
#define STD_SKLAFFRC SKLAFFDIR "/etc/stdsklaffrc"
#define POST_INFO SKLAFFDIR "/etc/postnews"
#ifdef SWEDISH
#define PARSE_FILE SKLAFFDIR "/etc/parse.swe"
#define STD_MAILBOX SKLAFFDIR "/etc/stdmailbox.swe"
#define HELP_DIR SKLAFFDIR "/etc/help.swe"
#define HELP_FILE SKLAFFDIR "/etc/help.swe/general.help"
#else
#define PARSE_FILE SKLAFFDIR "/etc/parse.eng"
#define STD_MAILBOX SKLAFFDIR "/etc/stdmailbox.eng"
#define HELP_DIR SKLAFFDIR "/etc/help.eng"
#define HELP_FILE SKLAFFDIR "/etc/help.eng/general.help"
#endif
#define CONFRC_FILE "/confrc"
#define INDEX_FILE "/.index"
#define NEWINDEX_FILE "/.newindex"
#define MSG_FILE "/msg"
#define CONFS_FILE "/confs"
#define SKLAFFRC_FILE "/sklaffrc"
#define MAILBOX_FILE "/mailbox"
#define EDIT_FILE "/text.sklaff"
#define DEAD_FILE "/dead.sklaff"
#define TMP_NOTE "/tmplapp"
#define ACT_FILE "/act"
/* Log level (lower means less logs, 0 = no logs) */
#define LOGLEVEL 6
/* Change nothing below this line (unless it won't compile) */
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
/* Misc defines */
#define LINE_LEN 79
#define SUBJECT_LEN 70
#define LONG_LINE_LEN 2 * LINE_LEN
#define HUGE_LINE_LEN 32768
#define MAX_COMMANDS 256
#define HISTORY_SIZE 20
#define NEW_FILE_MODE 0600
#define NEW_DIR_MODE 0700
#define SIGNAL_NEW_TEXT SIGUSR1
#define SIGNAL_NEW_MSG SIGUSR2
#define FROM_FIELD_LEN 28
#define IDLE_RESOLUTION 60
#define IDLE_LIMIT 3
/* Defines for messages */
#define MSG_SAY 1
#define MSG_YELL 2
#define MSG_LOGIN 3
#define MSG_LOGOUT 4
#define MSG_I 5
#define MSG_SMS 6
#define MSG_MY 7
/* Defines for open_file */
#define OPEN_CREATE 1
#define OPEN_QUIET 2
#define OPEN_DEFAULT 0
/* Defines for conf_type */
#define OPEN_CONF 0
#define CLOSED_CONF 1
#define SECRET_CONF 2
#define NEWS_CONF 3
/* Defines for text types */
#define TYPE_TEXT 0
#define TYPE_SURVEY 1
/* Defines for expand_name */
#define USER 0x01 /* to search among users */
#define CONF 0x02 /* to search among confs. */
#define ACTIVE 0x04 /* to search among logged in users */
#define SUBSCRIBED 0x08 /* to search among subscribed confs. */
#define UNSUBSCRIBED 0x10 /* to search among unsubscribed confs. */
#define ALSOERASED 0x20 /* to search also among erased confs */
/* Defines for surveys */
#define SURVEY_SINGLECHOICE 0
#define SURVEY_MULTIPLECHOICE 1
#define SURVEY_FREETEXT 2
#define SURVEY_INTERVAL 3
#define SURVEY_FREENUMBER 4
#define TAKE_SURVEY 1
#define SHOW_SURVEY_RESULT 2
/* Other defines */
#define STATUS_INTERNAL 0
#define STATUS_EXTERNAL 1
#define WHO_INTERNAL 0
#define WHO_EXTERNAL 1
/* Typedefs */
typedef char LINE[LINE_LEN + 1];
typedef char LONG_LINE[LONG_LINE_LEN + 1];
typedef char HUGE_LINE[HUGE_LINE_LEN];
#include "struct.h"
#include "lang.h"
/* lib-funktioner */
int cmp_strings(char *, char *);
int copy_file(char *, char *);
void critical(void);
char *down_string(char *);
int file_exists(char *);
off_t file_size(int);
char *user_dir(int, char *);
char *in_string(char *, char *);
char *get_hostname(void);
void haffo(int);
void baffo(int);
char *input(char *, char *, int, int, int, int);
int input_extended(char *, char *, int, int, int, int, int, int);
void lock(int);
void non_critical(void);
int output(char *,...);
int outputex(char *,...);
int close_file(int);
int create_file(char *);
int open_file(char *, int);
int parse_strings(char *, char *, int, char *);
char *read_file(int);
int write_file(int, char *);
char *rtrim(char *);
char *ltrim(char *);
void sig_reset(void);
void sig_setup(void);
void sys_error(char *, int, char *);
char *time_string(time_t, char *, int);
void tty_raw(void);
void tty_reset(void);
void unlock(int);
char *up_string(char *);
int wc(char *);
char *fake_string(char *);
char *order_name(char *, char *);
char *real_string(char *);
char *reorder_name(char *, char *);
char *prog_name(char *);
char *mbox_dir(int, char *);
/* Debugging */
/* void *my_malloc (size_t); */
/* void my_free (void *); */
/* commands.c */
int cmd_add_rights(char *);
int cmd_change_conf(char *);
int cmd_comment(char *);
int cmd_create_conf(char *);
int cmd_delete_conf(char *);
int cmd_delete_text(char *);
int cmd_display_commented(char *);
int cmd_display_last(char *);
int cmd_display_rot13(char *);
int cmd_display_time(char *);
int cmd_end_session(char *);
int cmd_restart(char *);
int cmd_on_flag(char *);
int cmd_off_flag(char *);
int cmd_goto_text(char *);
int cmd_help(char *);
int cmd_info(char *);
int cmd_jump_over(char *);
int cmd_jump_tree(char *);
int cmd_licens(char *);
int cmd_list_confs(char *);
int cmd_list_flags(char *);
int cmd_list_last(char *);
int cmd_list_member(char *);
int cmd_list_news(char *);
int cmd_list_rights(char *);
int cmd_list_subj(char *);
int cmd_list_users(char *);
int cmd_long_help(char *);
int cmd_mail(char *);
int cmd_mod_note(char *);
int cmd_mod_sig(char *);
int cmd_mod_login(char *);
int cmd_mod_pinfo(char *);
int cmd_mod_timeout(char *);
int cmd_next_comment(char *);
int cmd_next_conf(char *);
int cmd_next_text(char *);
int cmd_only(char *);
int cmd_personal(char *);
int cmd_post_text(char *);
int cmd_read_text(char *);
int cmd_whole_text(char *);
int cmd_say(char *);
int cmd_show_status(char *);
int cmd_sub_rights(char *);
int cmd_subscribe(char *);
int cmd_unread_text(char *);
int cmd_unread_tree(char *);
int cmd_unsubscribe(char *);
int cmd_where(char *);
int cmd_who(char *);
int cmd_yell(char *);
int cmd_change_cname(char *);
int cmd_change_comc(char *);
int cmd_change_passwd(char *);
int cmd_cls(char *);
int cmd_grep(char *);
int cmd_global_grep(char *);
int cmd_list_files(char *);
int cmd_download(char *);
int cmd_upload(char *);
int cmd_unlink(char *);
int cmd_describe(char *);
int cmd_I(char *);
int cmd_alias(char *);
int cmd_my(char *);
int cmd_prio(char *);
int cmd_deprio(char *);
int cmd_back_text(char *);
int cmd_readall(char *);
int cmd_readsome(char *);
int cmd_sendbatch(char *);
int cmd_survey_result(char *);
int cmd_unreadsub(char *);
int cmd_jumpsub(char *);
int cmd_jumpuser(char *);
int cmd_answermsg(char *);
int cmd_from(char *);
int cmd_list_says(char *);
int cmd_list_yells(char *);
int cmd_post_survey(char *);
int cmd_read_last_text(char *);
int cmd_reclaim_unread(char *);
/* admin.c */
char *display_prompt(char *, char *, int);
void display_welcome(void);
void display_news(void);
void check_open(void);
void out_onoff(int);
int grep(int, char *);
void exec_logout(int);
void exec_login(void);
void timeout(int);
void debuglog(char *, int);
int strip_string(char *, char *);
int show_status(int, int, int);
int list_who(int);
/* buf.c */
char *get_active_entry(char *, struct ACTIVE_ENTRY *);
char *get_conf_entry(char *, struct CONF_ENTRY *);
struct USER_LIST *get_confrc_users(char *);
char *get_confs_entry(char *, struct CONFS_ENTRY *);
char *get_msg_entry(char *, struct MSG_ENTRY *);
char *get_parse_entry(char *, struct PARSE_ENTRY *);
char *get_text_entry(char *, struct TEXT_ENTRY *);
char *get_user_entry(char *, struct USER_ENTRY *);
char *get_file_entry(char *, struct FILE_ENTRY *);
/* conf.c */
char *conf_name(int, char *);
int conf_num(char *);
int can_see_conf(int, int, int, int);
int is_conf_creator(int, int);
int set_conf(int);
int set_first_conf();
int member_of(int, int);
void free_confs_entry(struct CONFS_ENTRY *);
void free_userlist(struct USER_LIST *);
struct CONF_ENTRY *get_conf_struct(int);
struct USER_LIST *get_confrc_struct(int);
char *replace_conf(struct CONF_ENTRY *, char *);
char *replace_confs(struct CONFS_ENTRY *, char *);
char *stringify_confs_struct(struct CONFS_ENTRY *, char *);
char *stringify_conf_struct(struct CONF_ENTRY *, char *);
long num_unread(int, int, long);
int conf_right(struct USER_LIST *, int, int, int);
int list_confs(int, int);
int more_conf(void);
int force_unsubscribe(void);
long last_text(int, int);
long first_text(int, int);
struct CEN *sort_conf(struct CEL *, int);
int list_news(int);
struct CONF_ENTRY *get_all_confs(void);
/* edit.c */
void abort_edit(int);
int resume_aborted_edit(void);
struct TEXT_HEADER *
line_ed(char *, struct TEXT_HEADER *, int, int,
int, int *, char *);
/* file.c */
int rebuild_index_file(void);
/* flag.c */
void set_flags(char *);
int check_flag(char *, char *);
int turn_flag(int, char *);
/* msg.c */
void add_to_mlist(struct MSG_ENTRY *);
void list_mlist(int, int);
void newmsg(int);
int display_msg(int);
int send_msg(int, int, char *, int);
int send_msg_to_all(int, char *);
void notify_all_processes(int);
void notify_user(int, int);
/* parse.c */
int (*parse(char *, char *)) ();
void buggy_sunOS_fix(int);
int parse_init(char *);
char *expand_name(char *, int, int, int *);
/* text.c */
int check_if_read(long, int);
void clear_comment(void);
void display_header(struct TEXT_HEADER *, int, int, int, char *);
int display_text(int, long, int, int);
int display_survey_result(int, long);
int list_subj(char *);
int mark_as_read(long, int);
int mark_as_unread(long, int);
long next_text(int);
long parse_text(char *);
long pop_comment(void);
int push_comment(long);
long pop_unread(int *);
int push_unread(int, long);
long pop_unread2(int *);
int push_unread2(int, long);
long pop_read(int *);
int push_read(int, long);
int stack_text(long);
int tree_top(long);
long save_text(char *, struct TEXT_HEADER *, int);
int more_comment(void);
int more_text(void);
void free_text_entry(struct TEXT_ENTRY *);
long save_mailcopy(char *, char *, char *);
void cnvnat(char *, int);
void int2ms(int, char[4]); /* modified on 2025-07-12, PL */
long age_to_textno(long);
/* user.c */
struct USER_ENTRY *get_user_struct(int);
time_t last_session(int);
int user_is_active(int);
int user_is_avail(int);
char *replace_active(struct ACTIVE_ENTRY *, char *);
int set_avail(int, int);
int set_from(int, char *);
char *user_name(int, char *);
int user_uid(char *);
int setup_new_user(void);
char *stringify_user_struct(struct USER_ENTRY *, char *);
int add_active(void);
int remove_active(void);
struct ACTIVE_ENTRY *check_active(int, struct ACTIVE_ENTRY *);
long active_time(int);
long idle_time(int);
void make_activity_note();
int disp_note(int);
int list_user(int, int, int);
struct UEN *sort_user(struct UEL *, int);
struct SKLAFFRC *read_sklaffrc(int);
int write_sklaffrc(int, struct SKLAFFRC *);
/* survey.c */
int make_survey(char *, int *, LINE, int);
int save_survey_result(long, int, char *, int);
char *show_survey_result(long, int, struct TEXT_BODY *, int);
int mark_survey_as_taken(long, int);
int check_if_survey_taken(long, int);
time_t get_survey_time(time_t);
int get_no_survey_questions(char *);