1 | /* |
---|
2 | * |
---|
3 | * List request for DISCUSS |
---|
4 | * |
---|
5 | * $Id: nls.c,v 1.6 1999-02-08 14:46:51 danw Exp $ |
---|
6 | * |
---|
7 | * Copyright (C) 1986 by the MIT Student Information Processing Board |
---|
8 | * |
---|
9 | */ |
---|
10 | #ifndef lint |
---|
11 | static char *rcsid_discuss_c = "$Id: nls.c,v 1.6 1999-02-08 14:46:51 danw Exp $"; |
---|
12 | #endif /* lint */ |
---|
13 | |
---|
14 | #include <stdio.h> |
---|
15 | #include <string.h> |
---|
16 | #include "discuss_err.h" |
---|
17 | #include <ss/ss.h> |
---|
18 | #include "tfile.h" |
---|
19 | #include "interface.h" |
---|
20 | #include "config.h" |
---|
21 | #include "dsc_et.h" |
---|
22 | #include "globals.h" |
---|
23 | #include "trn_spec.h" |
---|
24 | |
---|
25 | char *ctime(), *malloc(), *local_realm(), *error_message(), *short_time(); |
---|
26 | static int time_now, time_sixmonthsago, time_plusthreemonths; |
---|
27 | static list_it(),delete_it(),retrieve_it(); |
---|
28 | static int performed; /* true if trn was acted upon */ |
---|
29 | static int barred; /* true if access was denied sometime */ |
---|
30 | |
---|
31 | void map_trns(); |
---|
32 | |
---|
33 | static |
---|
34 | list_it(ti) |
---|
35 | trn_info *ti; |
---|
36 | { |
---|
37 | char newtime[26]; |
---|
38 | char *cp; |
---|
39 | int code; |
---|
40 | |
---|
41 | strcpy(newtime, short_time(&ti->date_entered)); |
---|
42 | /* |
---|
43 | * If author ends with current realm, punt the realm. |
---|
44 | */ |
---|
45 | if ((cp=strchr(ti->author, '@')) != NULL) |
---|
46 | if (!strcmp(cp+1, local_realm())) |
---|
47 | *cp = '\0'; |
---|
48 | |
---|
49 | if (strlen(ti->author) > 15) { |
---|
50 | (void) strcpy(&ti->author[12], "..."); |
---|
51 | } |
---|
52 | (void) sprintf(buffer, "(%d)", ti->num_lines); |
---|
53 | if (strlen(ti->subject) > 35) { |
---|
54 | (void) strcpy(&ti->subject[32], "..."); |
---|
55 | } |
---|
56 | (void) printf(" [%04d]%c%5s %s %-15s %-20s\n", |
---|
57 | ti->current, |
---|
58 | (ti->current == dsc_public.current)?'*':' ', |
---|
59 | buffer, |
---|
60 | newtime, |
---|
61 | ti->author, |
---|
62 | ti->subject); |
---|
63 | punt: |
---|
64 | (void) free (ti->author); |
---|
65 | (void) free (ti->subject); |
---|
66 | } |
---|
67 | |
---|
68 | nlist(argc, argv) |
---|
69 | int argc; |
---|
70 | char **argv; |
---|
71 | { |
---|
72 | trans_gen *tg; |
---|
73 | int code; |
---|
74 | extern int interrupt; |
---|
75 | |
---|
76 | (void) time(&time_now); |
---|
77 | time_sixmonthsago = time_now - 6*30*24*60*60; |
---|
78 | time_plusthreemonths = time_now + 6*30*24*60*60; |
---|
79 | |
---|
80 | if (code = parse_trans_spec(&argv, &argc, &dsc_public, "all", &tg)) { |
---|
81 | ss_perror(sci_idx, code, "before listing transactions"); |
---|
82 | goto punt; |
---|
83 | } |
---|
84 | if (argc) { |
---|
85 | int i; |
---|
86 | printf("Remaining args:\n"); |
---|
87 | for (i = 0; i < argc; i++) { |
---|
88 | printf("\"%s\" ", argv[i]); |
---|
89 | } |
---|
90 | printf("\n"); |
---|
91 | } |
---|
92 | |
---|
93 | flag_interrupts(); |
---|
94 | |
---|
95 | if ((code = tg_next_trn(tg)) == 0) { |
---|
96 | #ifdef notdef |
---|
97 | dsc_public.current = tg->current; |
---|
98 | #endif /* notdef */ |
---|
99 | list_it(&tg->tinfo); |
---|
100 | while (!interrupt && (code = tg_next_trn(tg)) == 0) { |
---|
101 | if (interrupt) break; |
---|
102 | list_it(&tg->tinfo); |
---|
103 | } |
---|
104 | } |
---|
105 | if (code && code != DSC_NO_MORE) |
---|
106 | ss_perror(sci_idx, code, "while listing transactions"); |
---|
107 | |
---|
108 | punt: |
---|
109 | dont_flag_interrupts(); |
---|
110 | return; |
---|
111 | } |
---|
112 | |
---|