source: trunk/third/sysinfo/devdefine.c @ 12269

Revision 12269, 2.1 KB checked in by ghudson, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12268, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * Copyright (c) 1992-1998 Michael A. Cooper.
3 * This software may be freely used and distributed provided it is not
4 * sold for profit or used in part or in whole for commercial gain
5 * without prior written agreement, and the author is credited
6 * appropriately.
7 */
8
9#ifndef lint
10static char *RCSid = "$Revision: 1.1.1.3 $";
11#endif
12
13/*
14 * Device Definetion functions
15 */
16#include "defs.h"
17
18/*
19 * Master list of definetions
20 */
21DevDefine_t                    *DevDefinetions = NULL;
22
23/*
24 * Add a definetion to the master list.
25 */
26extern void DevDefAdd(DevDefine)
27    DevDefine_t                *DevDefine;
28{
29    static DevDefine_t         *Last = NULL;
30
31    /*
32     * Add Define
33     */
34    if (!DevDefinetions)
35        Last = DevDefinetions = DevDefine;
36    else {
37        Last->Next = DevDefine;
38        Last = DevDefine;
39    }
40}
41
42/*
43 * Get device data tab entry having a name of "Name" and/or Type + Ident.
44 */
45extern DevDefine_t *DevDefGet(Name, Type, Ident)
46    char                       *Name;
47    int                         Type;
48    int                         Ident;
49{
50    register DevDefine_t       *Ptr;
51    register char             **cpp;
52    register int                i;
53    int                         NameMatch = FALSE;
54    int                         IdentMatch = FALSE;
55
56    if (!Name && !Ident)
57        return((DevDefine_t *) NULL);
58
59    for (Ptr = DevDefinetions; Ptr; Ptr = Ptr->Next) {
60        if (Name && Ptr->Name) {
61            if (FLAGS_ON(Ptr->Flags, DDT_LENCMP)) {
62                if (EQN(Name, Ptr->Name, strlen(Ptr->Name)))
63                    NameMatch = TRUE;
64            } else {
65                if (EQ(Name, Ptr->Name))
66                    NameMatch = TRUE;
67            }
68        }
69        if (Name && !NameMatch) {
70            /* Check name aliases */
71            for (cpp = Ptr->Aliases; !NameMatch && cpp && *cpp; ++cpp)
72                if (EQ(Name, *cpp))
73                    NameMatch = TRUE;
74        }
75
76        if (Type && Ident)
77            if (Ptr->Type == Type && Ptr->Ident == Ident)
78                IdentMatch = TRUE;
79        /*
80         * If we're suppose to match everything and it does...
81         */
82        if ((Name && Type && Ident) && (NameMatch && IdentMatch))
83            return(Ptr);
84        /* Just Name checking and it does match */
85        else if (Name && NameMatch)
86            return(Ptr);
87        /* Just Ident checking and it does match */
88        else if (Type && Ident && IdentMatch)
89            return(Ptr);
90    }
91
92    return((DevDefine_t *) NULL);
93}
Note: See TracBrowser for help on using the repository browser.