Annotation of 43BSDReno/contrib/isode-beta/others/quipu/uips/fred/miscellany.c, revision 1.1

1.1     ! root        1: /* miscellany.c - fred miscellaneous functions */
        !             2: 
        !             3: #ifndef        lint
        !             4: static char *rcsid = "$Header: /f/osi/others/quipu/uips/fred/RCS/miscellany.c,v 7.9 90/07/27 08:45:28 mrose Exp $";
        !             5: #endif
        !             6: 
        !             7: /* 
        !             8:  * $Header: /f/osi/others/quipu/uips/fred/RCS/miscellany.c,v 7.9 90/07/27 08:45:28 mrose Exp $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       miscellany.c,v $
        !            12:  * Revision 7.9  90/07/27  08:45:28  mrose
        !            13:  * update
        !            14:  * 
        !            15:  * Revision 7.8  90/06/11  10:55:27  mrose
        !            16:  * UFN
        !            17:  * 
        !            18:  * Revision 7.7  90/05/12  17:03:22  mrose
        !            19:  * sync
        !            20:  * 
        !            21:  * Revision 7.6  90/02/19  13:10:39  mrose
        !            22:  * update
        !            23:  * 
        !            24:  * Revision 7.5  90/01/16  21:22:42  mrose
        !            25:  * one more time
        !            26:  * 
        !            27:  * Revision 7.4  90/01/16  20:43:35  mrose
        !            28:  * last check-out
        !            29:  * 
        !            30:  * Revision 7.3  90/01/11  18:36:37  mrose
        !            31:  * real-sync
        !            32:  * 
        !            33:  * Revision 7.2  89/12/01  10:45:09  mrose
        !            34:  * touch-up
        !            35:  * 
        !            36:  * Revision 7.1  89/11/27  10:32:24  mrose
        !            37:  * sync
        !            38:  * 
        !            39:  * Revision 7.0  89/11/23  22:09:01  mrose
        !            40:  * Release 6.0
        !            41:  * 
        !            42:  */
        !            43: 
        !            44: /*
        !            45:  *                               NOTICE
        !            46:  *
        !            47:  *    Acquisition, use, and distribution of this module and related
        !            48:  *    materials are subject to the restrictions of a license agreement.
        !            49:  *    Consult the Preface in the User's Manual for the full terms of
        !            50:  *    this agreement.
        !            51:  *
        !            52:  */
        !            53: 
        !            54: 
        !            55: #include <ctype.h>
        !            56: #include "fred.h"
        !            57: 
        !            58: /*    DATA */
        !            59: 
        !            60: int    area_quantum = 0;
        !            61: char   *myarea = NULL;
        !            62: 
        !            63: struct area_guide areas[] = {
        !            64:     W_ORGANIZATION,
        !            65:        "organization", "-singlelevel", "organization",         "o",    NULL,
        !            66: 
        !            67:     W_UNIT,
        !            68:        "unit",         "-subtree",     "organizationalUnit",   "ou",   NULL,
        !            69: 
        !            70:     W_LOCALITY,
        !            71:        "locality",     "-singlelevel", "locality",             "l",    NULL,
        !            72: 
        !            73:     W_PERSON,
        !            74:        "person",       "-subtree",     "person",               "cn",   NULL,
        !            75: 
        !            76:     W_DSA,
        !            77:        "dsa",          "-singlelevel", "dsa",                  "cn",   NULL,
        !            78: 
        !            79:     W_ROLE,
        !            80:        "role",         "-subtree",     "organizationalRole",   "cn",   NULL,
        !            81: 
        !            82:     NULL
        !            83: };
        !            84: 
        !            85: /*    ALIAS */
        !            86: 
        !            87: /* ARGSUSED */
        !            88: 
        !            89: int    f_alias (vec)
        !            90: char  **vec;
        !            91: {
        !            92:     char   *cp,
        !            93:            buffer[BUFSIZ];
        !            94: 
        !            95:     if ((cp = *++vec) == NULL)
        !            96:        return dish ("squid -fred -sequence default", 0);
        !            97: 
        !            98:     if (strcmp (cp, "-help") == 0) {
        !            99:        fprintf (stdfp, "alias [name]\n");
        !           100:        fprintf (stdfp, "    with no arguments, reports on active aliases\n");
        !           101:        fprintf (stdfp,
        !           102:                 "    with one argument, defines an alias for the given name\n");
        !           103: 
        !           104:        return OK;
        !           105:     }
        !           106: 
        !           107:     (void) sprintf (buffer, "squid -fred -alias \"%s\"", cp);
        !           108:     return dish (buffer, runcom);
        !           109: }
        !           110: 
        !           111: /*    AREA */
        !           112: 
        !           113: int    f_area (vec)
        !           114: char  **vec;
        !           115: {
        !           116:     int            status;
        !           117:     char   *cp,
        !           118:           *dp,
        !           119:            buffer[BUFSIZ];
        !           120:     register struct area_guide *ag;
        !           121: 
        !           122:     if ((cp = *++vec) == NULL) {
        !           123:        if (myarea == NULL) {
        !           124:            if (dish ("moveto -pwd", 0) == NOTOK)
        !           125:                return NOTOK;
        !           126:        }
        !           127:        else
        !           128:            fprintf (stdfp, "                     default area %s\n", myarea);
        !           129: 
        !           130:        for (ag = areas; ag -> ag_record; ag++)
        !           131:            if (ag -> ag_area)
        !           132:                fprintf (stdfp, "area for record-type %-12.12s %s\n",
        !           133:                         ag -> ag_key, ag -> ag_area);
        !           134: 
        !           135:        return OK;
        !           136:     }
        !           137: 
        !           138:     if (strcmp (cp, "-help") == 0) {
        !           139:        fprintf (stdfp, "area [[record] location]\n");
        !           140:        fprintf (stdfp,
        !           141:                 "    with no arguments, lists areas current defined for various searches\n");
        !           142:        fprintf (stdfp,
        !           143:                 "    with one argument, sets the default area for general searches\n");
        !           144:        fprintf (stdfp,
        !           145:                 "    with two arguments, sets the default area for the given record type\n");
        !           146: 
        !           147:        return OK;
        !           148:     }
        !           149: 
        !           150:     if ((dp = *++vec) == NULL) {
        !           151:        (void) sprintf (buffer, "moveto -pwd \"%s\"", cp);
        !           152:        if (dish (buffer, 1) == NOTOK) {
        !           153:            advise (NULLCP, "bad area: \"%s\"", cp);
        !           154:            return NOTOK;
        !           155:        }
        !           156:        if (!runcom)
        !           157:            fprintf (stdfp, "%s\n", myarea);
        !           158: 
        !           159:        area_quantum++;
        !           160:        return OK;
        !           161:     }
        !           162: 
        !           163:     for (ag = areas; ag -> ag_record; ag++)
        !           164:        if (strcmp (ag -> ag_key, cp) == 0)
        !           165:            break;
        !           166:     if (!ag -> ag_record) {
        !           167:        advise (NULLCP, "invalid record-type: \"%s\"", cp);
        !           168:        return NOTOK;
        !           169:     }
        !           170: 
        !           171:     if (cp = myarea)
        !           172:        myarea = NULL;
        !           173: 
        !           174:     (void) sprintf (buffer, "moveto -pwd \"%s\"", dp);
        !           175:     if ((status = dish (buffer, 1)) == OK) {
        !           176:        if (ag -> ag_area)
        !           177:            free (ag -> ag_area);
        !           178:        ag -> ag_area = myarea;
        !           179: 
        !           180:        if (!runcom)
        !           181:            fprintf (stdfp, "area for record-type %s: %s\n",
        !           182:                     ag -> ag_key, ag -> ag_area);
        !           183:     }
        !           184:     else {
        !           185:        advise (NULLCP, "bad area: \"%s\"", dp);
        !           186:        if (myarea)
        !           187:            free (myarea), myarea = NULL;
        !           188:     }
        !           189: 
        !           190:     if (myarea = cp) {
        !           191:        (void) sprintf (buffer, "moveto -pwd \"%s\"", myarea);
        !           192:        (void) dish (buffer, 1);
        !           193:     }
        !           194: 
        !           195:     area_quantum++;
        !           196:     return status;
        !           197: }
        !           198: 
        !           199: /*    DISH */
        !           200: 
        !           201: int    f_dish (vec)
        !           202: char  **vec;
        !           203: {
        !           204:     register char *bp,
        !           205:                  *cp;
        !           206:     char    buffer[BUFSIZ];
        !           207: 
        !           208:     if ((cp = *++vec) == NULL)
        !           209:        return dish ("squid -fred", 0);
        !           210:     if (strcmp (cp, "-help") == 0) {
        !           211:        fprintf (stdfp, "dish [command [arguments ...]]\n");
        !           212:        fprintf (stdfp, "    with no arguments, reports on status of dish\n");
        !           213:        fprintf (stdfp, "    with arguments, passes those directly to dish\n");
        !           214: 
        !           215:        return OK;
        !           216:     }
        !           217: 
        !           218:     (void) strcpy (bp = buffer, cp);
        !           219:     bp += strlen (bp);
        !           220: 
        !           221:     while (cp = *++vec) {
        !           222:        (void) sprintf (bp, " \"%s\"", cp);
        !           223:        bp += strlen (bp);
        !           224:     }
        !           225: 
        !           226:     return dish (buffer, runcom);
        !           227: }
        !           228: 
        !           229: /*    EDIT */
        !           230: 
        !           231: int    f_edit (vec)
        !           232: char  **vec;
        !           233: {
        !           234:     int            result;
        !           235:     char    buffer[BUFSIZ];
        !           236: 
        !           237:     if (*++vec != NULL && strcmp (*vec, "-help") == 0) {
        !           238:        fprintf (stdfp, "edit\n");
        !           239:        fprintf (stdfp, "    edit entry in the white pages\n");
        !           240: 
        !           241:        return OK;
        !           242:     }
        !           243: 
        !           244:     if (mydn == NULL) {
        !           245:        advise (NULLCP, "who are you?  use the \"thisis\" command first...");
        !           246:        return NOTOK;
        !           247:     }
        !           248: 
        !           249:     (void) sprintf (buffer, "modify -dontusecopy -newdraft \"%s\"", mydn);
        !           250:     dontpage = 1;
        !           251:     result = dish (buffer, 0);
        !           252:     dontpage = 0;
        !           253: 
        !           254:     if (result != OK)
        !           255:        return result;
        !           256: 
        !           257:     (void) sprintf (buffer, "showentry \"%s\" -fred -dontusecopy", mydn);
        !           258:     (void) dish (buffer, 0);
        !           259:     return OK;
        !           260: }
        !           261: 
        !           262: /*    MANUAL */
        !           263: 
        !           264: int    f_manual (vec)
        !           265: char  **vec;
        !           266: {
        !           267:     char   buffer[BUFSIZ];
        !           268:     FILE  *fp;
        !           269: 
        !           270:     if (*++vec != NULL && strcmp (*vec, "-help") == 0) {
        !           271:        fprintf (stdfp, "manual\n");
        !           272:        fprintf (stdfp, "    print detailed information\n");
        !           273: 
        !           274:        return OK;
        !           275:     }
        !           276: 
        !           277:     (void) strcpy (buffer, isodefile ("fred.0", 0));
        !           278:     if (fp = fopen (buffer, "r")) {
        !           279:        while (fgets (buffer, sizeof buffer, fp))
        !           280:            paginate (stdfp, buffer, strlen (buffer));
        !           281:        paginate (stdfp, NULLCP, 0);
        !           282: 
        !           283:        (void) fclose (fp);
        !           284:     }
        !           285:     else
        !           286:        advise (buffer, "unable to open");
        !           287: 
        !           288:     return OK;
        !           289: }
        !           290: 
        !           291: /*    REPORT */
        !           292: 
        !           293: int    f_report (vec)
        !           294: char  **vec;
        !           295: {
        !           296:     register char   *bp;
        !           297:     char   *cp,
        !           298:            buffer[BUFSIZ];
        !           299: 
        !           300:     if (*++vec != NULL && strcmp (*vec, "-help") == 0) {
        !           301:        fprintf (stdfp, "report [subject]\n");
        !           302:        fprintf (stdfp, "    send report to white pages manager\n");
        !           303: 
        !           304:        return OK;
        !           305:     }
        !           306: 
        !           307:     if (readonly)
        !           308:        (void) strcpy (buffer, _isodefile (isodebinpath, "mhmail"));
        !           309:     bp = buffer;
        !           310:     cp = strcmp (manager, "internal") ? manager
        !           311:                                      : "[email protected]";
        !           312: 
        !           313:     if (!readonly || access (buffer, 0x01) == NOTOK) {
        !           314:        (void) strcpy (bp, "/usr/ucb/Mail ");
        !           315:        bp += strlen (bp);
        !           316: 
        !           317:        if (debug) {
        !           318:            (void) sprintf (bp, "-v ");
        !           319:            bp += strlen (bp);
        !           320:        }
        !           321: 
        !           322:        if (readonly) {
        !           323:            (void) sprintf (bp, "-r \"%s\" ", cp);
        !           324:            bp += strlen (bp);
        !           325:        }
        !           326: 
        !           327:        (void) sprintf (bp, "-s");
        !           328:     }
        !           329:     else {
        !           330:        bp += strlen (bp);
        !           331: 
        !           332:        (void) sprintf (bp, " -subject");
        !           333:     }
        !           334:     bp += strlen (bp);
        !           335: 
        !           336:     (void) sprintf (bp, " \"%s\" \"%s\"",
        !           337:                    *vec ? *vec : "White Pages report", cp);
        !           338:     bp += strlen (bp);
        !           339:                        
        !           340: 
        !           341:     fprintf (stdfp, "End report with CTRL-D%s\n",
        !           342:        readonly ? ", it will then take 30 seconds to post message" : "");
        !           343:     (void) fflush (stdfp);
        !           344: 
        !           345:     if (watch) {
        !           346:        fprintf (stderr, "%s\n", buffer);
        !           347:        (void) fflush (stderr);
        !           348:     }
        !           349:     if (system (buffer))
        !           350:        advise (NULLCP, "problem sending report");
        !           351: 
        !           352:     return OK;
        !           353: }
        !           354: 
        !           355: /*    THISIS */
        !           356: 
        !           357: int    f_thisis (vec)
        !           358: char  **vec;
        !           359: {
        !           360:     register char   *bp;
        !           361:     char   *cp,
        !           362:            buffer[BUFSIZ];
        !           363: 
        !           364: again: ;
        !           365:     if ((cp = *++vec) == NULL) {
        !           366:        if (mydn == NULL) {
        !           367:            advise (NULLCP, "who are you?");
        !           368:            return NOTOK;
        !           369:        }
        !           370: 
        !           371:        printf ("you are \"%s\"\n", mydn);
        !           372:        return OK;
        !           373:     }
        !           374: 
        !           375:     if (strcmp (cp, "-help") == 0) {
        !           376:        fprintf (stdfp, "thisis [name]\n");
        !           377:        fprintf (stdfp,
        !           378:                 "    with no arguments, lists your name in the white pages\n");
        !           379:        fprintf (stdfp,
        !           380:                 "    with one argument, identifies you in the white pages\n");
        !           381: 
        !           382:        return OK;
        !           383:     }
        !           384: 
        !           385:     if (strcmp (cp, "is") == 0)
        !           386:        goto again;
        !           387: 
        !           388:     if (*cp == '!')
        !           389:        cp++;
        !           390:     for (bp = cp; isdigit (*bp); bp++)
        !           391:        continue;
        !           392:     if (*bp && (index (cp, '@') == NULL || index (cp, '=') == NULL)) {
        !           393:        advise (NULLCP,
        !           394:        "expecting a distinguished name (if you don't know what this is, punt)"
        !           395:                );
        !           396:        return NOTOK;
        !           397:     }
        !           398: 
        !           399:     bp = buffer;
        !           400: 
        !           401:     (void) sprintf (bp, "bind -user \"%s\"", cp);
        !           402:     bp += strlen (bp);
        !           403: 
        !           404:     if (*++vec) {
        !           405:        if (runcom && (rcmode & 077))
        !           406:            adios (NULLCP,
        !           407:                   "incorrect mode for runcom file -- use \"chmod 0600 $HOME/.fredrc\"");
        !           408: 
        !           409:        (void) sprintf (bp, " -password \"%s\"", *vec);
        !           410:        bp += strlen (bp);
        !           411:     }
        !           412: 
        !           413:     if (dish (buffer, 0) != OK) {
        !           414:        (void) f_quit (NULLVP);
        !           415:        exit (1);       /* NOT REACHED */
        !           416:     }
        !           417: 
        !           418:     if (runcom)
        !           419:        didbind = 1;
        !           420: 
        !           421:     (void) dish ("squid -fred -user", 1);
        !           422: 
        !           423:     return OK;
        !           424: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.