DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T m

⟦9fb6677ff⟧ TextFile

    Length: 2712 (0xa98)
    Types: TextFile
    Names: »misc.c«

Derivation

└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen
    └─ ⟦this⟧ »cph85dist/rman/daemon/misc.c« 

TextFile

#ifndef lint
static char *RCSid = "$Header: misc.c,v 1.6 85/08/27 15:17:00 broome Exp $";
#endif

/*
 * $Log:    misc.c,v $
 * Revision 1.6  85/08/27  15:17:00  broome
 * Last cleanup before release.
 * 
 * Revision 1.5  85/08/04  16:56:04  broome
 * Added new "any" routine.
 * 
 * Revision 1.4  85/07/06  16:56:01  broome
 * 
 * Revision 1.3  85/07/03  17:34:34  broome
 * 
 * Revision 1.2  85/07/02  21:05:56  broome
 * 
 * Revision 1.1  85/06/25  11:23:39  broome
 * Initial revision
 */

#include <stdio.h>
#include "response.h"
#include "defs.h"

/*
 *  Search for and print the path name to the topic and 
 *  section requested.  Duplicates the action used by 
 *  `cat()' and `raw()' without actually sending the file.
 */

dofind (argc, argv)
int    argc;
char  *argv[];
{
    struct where *wp;

    argv++, argc--;
    wp = find (argc, argv);
    if (wp->found)
        printf ("%d %s\r\n", OK_STAT, wp->man);
    else 
        notfound (wp);
}


/*
 *  Toggle debugging information.
 */

dbug ()
{
    debug = !debug;
    printf ("100 Debugging is now %s\n", debug ? "ON" : "OFF");
}


/*
 *  Show a list of all known directories.
 */

list ()
{
    DIR  *dir;
    char *suff;
    int  s;

    printf ("121-List of all known directories:\r\n");
    for (dir = dirs; dir; dir = dir->next) {
        printf ("120-Man: %s\n120-Cat: %s\r\n120-\tSuffixes: ", 
                dir->man, dir->cat);
        for (s = 0; suff = dir->suff[s]; s++)
            printf ("%s ", suff);
        puts ("\r");
    }
    printf ("122 That's all.\r\n");
}


/*
 *  Report that the requested file was not found.
 */

notfound (wp)
struct where *wp;
{
    printf ("%d No entry for %s in ", ERR_NOENT, wp->name);
    if (wp->section)
        printf ("section %s of ", wp->section);
    printf ("the manual.\r\n");
}


/*
 *   Allocate enough memory for the given string, then copy it in.
 */

char *
strsave (str)
char *str;
{
    char *s;
    char *malloc();

    s = malloc (strlen (str) + 1);
    strcpy (s, str);
    return (s);
}


/*
 *  Return 1 if ch is contained in str, else 0.
 */

any (ch, str)
register char ch;
register char *str;
{
    while (*str)
        if (ch == *str++)
            return (1);
    return (0);
}



/*
 *  Return the lower case version of a given character.
 *  Can't use a macro when arg is of the form `*foo++'.
 */

tolower (c)
register c;
{
    if ('A' <= c && c <= 'Z')
        return (c - 'A' + 'a');
    return (c);
}



/*
 *  Case insensitive version of strcmp(), returns 0 if equal, 1 if not.
 */

streql (a, b)
register char *a, *b;
{
    while (tolower (*a) == tolower (*b)) {
        if (*a == '\0')
            return (0);
        a++;
        b++;
    }
    return (1);
}