]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/doscmd/setver.c
This commit was generated by cvs2svn to compensate for changes in r70243,
[FreeBSD/FreeBSD.git] / usr.bin / doscmd / setver.c
1 /*
2  * Copyright (c) 1992, 1993, 1996
3  *      Berkeley Software Design, Inc.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *      This product includes software developed by Berkeley Software
16  *      Design, Inc.
17  *
18  * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  *      BSDI setver.c,v 2.2 1996/04/08 19:33:04 bostic Exp
31  *
32  * $FreeBSD$
33  */
34
35 #include "doscmd.h"
36
37 #if 1 /*XXXXX*/
38 int ms_version = 622;
39 #else
40 int ms_version = 410;
41 #endif
42
43 typedef struct setver_t {
44     short               version;
45     char                command[14];
46     struct setver_t     *next;
47 } setver_t;
48
49 static setver_t *setver_root;
50
51 void
52 setver(char *cmd, short version)
53 {
54     if (cmd) {
55         setver_t *s = (setver_t *)malloc(sizeof(setver_t));
56
57         strncpy(s->command, cmd, 14);
58         s->version = version;
59         s->next = setver_root;
60         setver_root = s;
61     } else {
62         ms_version = version;
63     }
64 }
65
66 short
67 getver(char *cmd)
68 {
69     if (cmd) {
70         setver_t *s = setver_root;
71
72         while (s) {
73             if (strncasecmp(cmd, s->command, 14) == 0)
74                 return(s->version);
75             s = s->next;
76         }
77     }
78     return(ms_version);
79 }