[BACK]Return to modules.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / cvs

Annotation of src/usr.bin/cvs/modules.c, Revision 1.1

1.1     ! joris       1: /*     $OpenBSD$       */
        !             2: /*
        !             3:  * Copyright (c) 2008 Joris Vink <joris@openbsd.org>
        !             4:  *
        !             5:  * Permission to use, copy, modify, and distribute this software for any
        !             6:  * purpose with or without fee is hereby granted, provided that the above
        !             7:  * copyright notice and this permission notice appear in all copies.
        !             8:  *
        !             9:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
        !            10:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
        !            11:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
        !            12:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
        !            13:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
        !            14:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
        !            15:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
        !            16:  */
        !            17:
        !            18: #include <sys/param.h>
        !            19: #include <sys/dirent.h>
        !            20: #include <sys/resource.h>
        !            21:
        !            22: #include <errno.h>
        !            23: #include <limits.h>
        !            24: #include <stdlib.h>
        !            25: #include <string.h>
        !            26:
        !            27: #include "cvs.h"
        !            28: #include "config.h"
        !            29:
        !            30: TAILQ_HEAD(, module_info)      modules;
        !            31:
        !            32: void
        !            33: cvs_parse_modules(void)
        !            34: {
        !            35:        cvs_log(LP_TRACE, "cvs_parse_modules()");
        !            36:
        !            37:        TAILQ_INIT(&modules);
        !            38:        cvs_read_config(CVS_PATH_MODULES, modules_parse_line);
        !            39: }
        !            40:
        !            41: void
        !            42: modules_parse_line(char *line)
        !            43: {
        !            44:        int flags;
        !            45:        char *val, *p, *module;
        !            46:        struct module_info *mi;
        !            47:
        !            48:        flags = 0;
        !            49:        p = val = line;
        !            50:        while (*p != ' ' && *p != '\t')
        !            51:                p++;
        !            52:
        !            53:        *(p++) = '\0';
        !            54:        module = val;
        !            55:
        !            56:        while (*p == ' ' || *p == '\t')
        !            57:                p++;
        !            58:
        !            59:        if (*p == '\0') {
        !            60:                cvs_log(LP_NOTICE, "premature ending of CVSROOT/modules line");
        !            61:                return;
        !            62:        }
        !            63:
        !            64:        val = p;
        !            65:        while (*p != ' ' && *p != '\t')
        !            66:                p++;
        !            67:
        !            68:        if (*p == '\0') {
        !            69:                cvs_log(LP_NOTICE, "premature ending of CVSROOT/modules line");
        !            70:                return;
        !            71:        }
        !            72:
        !            73:        while (val[0] == '-') {
        !            74:                p = val;
        !            75:                while (*p != ' ' && *p != '\t' && *p != '\0')
        !            76:                        p++;
        !            77:
        !            78:                if (*p == '\0') {
        !            79:                        cvs_log(LP_NOTICE,
        !            80:                            "misplaced option in CVSROOT/modules");
        !            81:                        return;
        !            82:                }
        !            83:
        !            84:                *(p++) = '\0';
        !            85:
        !            86:                switch (val[1]) {
        !            87:                case 'a':
        !            88:                        break;
        !            89:                }
        !            90:
        !            91:                val = p;
        !            92:        }
        !            93:
        !            94:        mi = xmalloc(sizeof(*mi));
        !            95:        mi->mi_name = xstrdup(module);
        !            96:        mi->mi_repository = xstrdup(val);
        !            97:        TAILQ_INSERT_TAIL(&modules, mi, m_list);
        !            98: }
        !            99:
        !           100: char *
        !           101: cvs_module_lookup(char *name)
        !           102: {
        !           103:        struct module_info *mi;
        !           104:
        !           105:        TAILQ_FOREACH(mi, &modules, m_list) {
        !           106:                if (!strcmp(name, mi->mi_name))
        !           107:                        return (mi->mi_repository);
        !           108:        }
        !           109:
        !           110:        return (name);
        !           111: }