[313] | 1 | /* |
---|
[1936] | 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 | /* |
---|
[12894] | 9 | * $Id: crmtgs.c,v 1.7 1999-04-12 16:47:06 ghudson Exp $ |
---|
[313] | 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 |
---|
[1480] | 19 | static char rcsid_crmtgs_c[] = |
---|
[12894] | 20 | "$Id: crmtgs.c,v 1.7 1999-04-12 16:47:06 ghudson Exp $"; |
---|
[1480] | 21 | #endif /* lint */ |
---|
[313] | 22 | |
---|
[12894] | 23 | #include <stdio.h> |
---|
[1646] | 24 | #include <discuss/discuss.h> |
---|
[313] | 25 | |
---|
[1480] | 26 | extern char *getenv (); |
---|
| 27 | |
---|
[313] | 28 | main(argc, argv) |
---|
| 29 | int argc; |
---|
| 30 | char **argv; |
---|
| 31 | { |
---|
| 32 | int n_matches, code; |
---|
| 33 | register name_blk *nbp; |
---|
| 34 | name_blk *set; |
---|
| 35 | int i; |
---|
| 36 | mtg_info info; |
---|
| 37 | char **aliasv; |
---|
| 38 | int naliases; |
---|
| 39 | |
---|
[23271] | 40 | #if defined(__APPLE__) && defined(__MACH__) |
---|
| 41 | add_error_table(&et_dsc_error_table); |
---|
| 42 | #else |
---|
[22864] | 43 | initialize_dsc_error_table(); |
---|
[23271] | 44 | #endif |
---|
[313] | 45 | |
---|
[12889] | 46 | dsc_expand_mtg_set(NULL, "*", &set, &n_matches, &code); |
---|
[313] | 47 | |
---|
| 48 | if (code) |
---|
| 49 | punt_code("Can't expand meeting set", code); |
---|
| 50 | |
---|
| 51 | if (!n_matches) |
---|
| 52 | punt("No meetings?"); |
---|
| 53 | |
---|
| 54 | for (nbp = set; nbp < set + n_matches; ++nbp) { |
---|
| 55 | dsc_get_mtg_info(nbp, &info, &code); |
---|
| 56 | if (code) { |
---|
| 57 | printf("%s: %s\n", nbp->aliases[0], |
---|
| 58 | error_message(code)); |
---|
| 59 | continue; |
---|
| 60 | } |
---|
| 61 | if (strcmp(nbp->aliases[0], info.long_name)) { |
---|
| 62 | printf("Adding long_name %s to %s\n", |
---|
| 63 | info.long_name, nbp->aliases[0]); |
---|
| 64 | |
---|
| 65 | /* |
---|
| 66 | * Beware of dragons and fenceposts in the |
---|
| 67 | * following code. |
---|
| 68 | */ |
---|
| 69 | aliasv = nbp->aliases; |
---|
| 70 | while (*aliasv++) continue; |
---|
| 71 | naliases = aliasv - nbp->aliases; |
---|
| 72 | nbp->aliases = (char **) realloc(nbp->aliases, |
---|
| 73 | ++naliases * sizeof(nbp->aliases)); |
---|
| 74 | aliasv = nbp->aliases + naliases; |
---|
| 75 | while(naliases--) { |
---|
| 76 | *aliasv = aliasv[-1]; |
---|
| 77 | --aliasv; |
---|
| 78 | } |
---|
| 79 | if (aliasv != nbp->aliases) abort(); |
---|
| 80 | *aliasv = info.long_name; |
---|
| 81 | } else printf("Long name %s already present\n", |
---|
| 82 | info.long_name); |
---|
| 83 | } |
---|
[12889] | 84 | dsc_update_mtg_set(NULL, set, n_matches, &code); |
---|
[313] | 85 | if (code) |
---|
| 86 | punt_code("update_mtg_set failed", code); |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | punt(string) |
---|
| 90 | char *string; |
---|
| 91 | { |
---|
| 92 | puts(string); |
---|
| 93 | exit(1); |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | punt_code(string, code) |
---|
| 97 | char *string; |
---|
| 98 | int code; |
---|
| 99 | { |
---|
| 100 | printf("%s: %s", string, error_message(code)); |
---|
| 101 | exit(1); |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | |
---|