546b643da8289e605bafcb94f4b43c177d672fc6
[openafs.git] / src / WINNT / client_osi / osiltype.c
1 /* 
2  * Copyright (C) 1998, 1989 Transarc Corporation - All rights reserved
3  *
4  * (C) COPYRIGHT IBM CORPORATION 1987, 1988
5  * LICENSED MATERIALS - PROPERTY OF IBM
6  *
7  */
8
9 /* Copyright (C) 1994 Cazamar Systems, Inc. */
10
11
12 #include <afs/param.h>
13 #include <afs/stds.h>
14
15 #include <windows.h>
16 #include "osi.h"
17 #include <assert.h>
18
19 /* table of dynamic lock types.  First entry isn't used, since those are
20  * wired in for performance reasons.
21  */
22 osi_lockOps_t *osi_lockOps[OSI_NLOCKTYPES];
23 char *osi_lockOpNames[OSI_NLOCKTYPES];
24
25 /* first free slot in lock operations; slot 0 is not used */
26 int osi_lockTypeIndex = 1;
27
28 /* type to create generically */
29 int osi_lockTypeDefault = 0;
30
31 int osi_LockTypeFind(char *namep)
32 {
33         int i;
34
35         for(i=1; i<osi_lockTypeIndex; i++) {
36                 if (!strcmp(osi_lockOpNames[i], namep)) return i;
37         }
38         return -1;
39 }
40
41 void osi_LockTypeAdd(osi_lockOps_t *statOps, char *namep, int *indexp)
42 {
43         int i;
44         if ((i = osi_lockTypeIndex) >= OSI_NLOCKTYPES) return;
45         osi_lockOps[i] = statOps;
46         osi_lockOpNames[i] = namep;
47         *indexp = i;
48         osi_lockTypeIndex = i+1;
49 }
50
51 osi_LockTypeSetDefault(char *namep)
52 {
53         int index;
54
55         if (namep == (char *) 0)
56                 osi_lockTypeDefault = 0;
57         else {
58                 index = osi_LockTypeFind(namep);
59                 if (index > 0) osi_lockTypeDefault = index;
60         }
61         return 0;
62 }
63