1 | /* |
---|
2 | * |
---|
3 | * Copyright (C) 1988, 1989 by the Massachusetts Institute of Technology |
---|
4 | * Developed by the MIT Student Information Processing Board (SIPB). |
---|
5 | * For copying information, see the file mit-copyright.h in this release. |
---|
6 | * |
---|
7 | */ |
---|
8 | /* |
---|
9 | * $Id: crmtgs.c,v 1.5 1999-01-22 23:10:08 ghudson Exp $ |
---|
10 | * |
---|
11 | * Fill out a .meetings file with the primary name of all the |
---|
12 | * meetings in it. This requires that the meeting be accessible |
---|
13 | * at this time; however, this program may be run several times |
---|
14 | * to get it right.. |
---|
15 | * |
---|
16 | */ |
---|
17 | |
---|
18 | #ifndef lint |
---|
19 | static char rcsid_crmtgs_c[] = |
---|
20 | "$Id: crmtgs.c,v 1.5 1999-01-22 23:10:08 ghudson Exp $"; |
---|
21 | #endif /* lint */ |
---|
22 | |
---|
23 | #include <discuss/discuss.h> |
---|
24 | |
---|
25 | extern char *getenv (); |
---|
26 | |
---|
27 | main(argc, argv) |
---|
28 | int argc; |
---|
29 | char **argv; |
---|
30 | { |
---|
31 | int n_matches, code; |
---|
32 | register name_blk *nbp; |
---|
33 | name_blk *set; |
---|
34 | int i; |
---|
35 | mtg_info info; |
---|
36 | char **aliasv; |
---|
37 | int naliases; |
---|
38 | |
---|
39 | init_dsc_err_tbl(); |
---|
40 | |
---|
41 | dsc_expand_mtg_set(getenv("USER"), "*", &set, &n_matches, &code); |
---|
42 | |
---|
43 | if (code) |
---|
44 | punt_code("Can't expand meeting set", code); |
---|
45 | |
---|
46 | if (!n_matches) |
---|
47 | punt("No meetings?"); |
---|
48 | |
---|
49 | for (nbp = set; nbp < set + n_matches; ++nbp) { |
---|
50 | dsc_get_mtg_info(nbp, &info, &code); |
---|
51 | if (code) { |
---|
52 | printf("%s: %s\n", nbp->aliases[0], |
---|
53 | error_message(code)); |
---|
54 | continue; |
---|
55 | } |
---|
56 | if (strcmp(nbp->aliases[0], info.long_name)) { |
---|
57 | printf("Adding long_name %s to %s\n", |
---|
58 | info.long_name, nbp->aliases[0]); |
---|
59 | |
---|
60 | /* |
---|
61 | * Beware of dragons and fenceposts in the |
---|
62 | * following code. |
---|
63 | */ |
---|
64 | aliasv = nbp->aliases; |
---|
65 | while (*aliasv++) continue; |
---|
66 | naliases = aliasv - nbp->aliases; |
---|
67 | nbp->aliases = (char **) realloc(nbp->aliases, |
---|
68 | ++naliases * sizeof(nbp->aliases)); |
---|
69 | aliasv = nbp->aliases + naliases; |
---|
70 | while(naliases--) { |
---|
71 | *aliasv = aliasv[-1]; |
---|
72 | --aliasv; |
---|
73 | } |
---|
74 | if (aliasv != nbp->aliases) abort(); |
---|
75 | *aliasv = info.long_name; |
---|
76 | } else printf("Long name %s already present\n", |
---|
77 | info.long_name); |
---|
78 | } |
---|
79 | dsc_update_mtg_set(getenv("USER"), set, n_matches, &code); |
---|
80 | if (code) |
---|
81 | punt_code("update_mtg_set failed", code); |
---|
82 | } |
---|
83 | |
---|
84 | punt(string) |
---|
85 | char *string; |
---|
86 | { |
---|
87 | puts(string); |
---|
88 | exit(1); |
---|
89 | } |
---|
90 | |
---|
91 | punt_code(string, code) |
---|
92 | char *string; |
---|
93 | int code; |
---|
94 | { |
---|
95 | printf("%s: %s", string, error_message(code)); |
---|
96 | exit(1); |
---|
97 | } |
---|
98 | |
---|
99 | |
---|