cleanup-licensing-and-transarc-references-20030309
[openafs.git] / src / WINNT / client_osi / osiutils.c
1 /* 
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /* Copyright (C) 1994 Cazamar Systems, Inc. */
11
12 #include <afs/param.h>
13 #include <afs/stds.h>
14
15 #include <windows.h>
16 #include <stdlib.h>
17 #include <stdio.h>
18 #include <assert.h>
19
20 #include <rpc.h>
21 #include "osiutils.h"
22
23 void osi_LongToUID(long inval, UUID *outuidp)
24 {
25         /* generic UUID whose seconds field we'll never use again */
26         UUID genericCazamarUUID = { /* 7C45E3F8-5F73-101B-89A3-204C4F4F5020 */
27                 0x7C45E3F8,
28                 0x5F73,
29                 0x101B,
30                 {0x89, 0xa3, 0x20, 0x4C, 0x4F, 0x4F, 0x50, 0x20}
31         };
32
33         genericCazamarUUID.Data1 = inval;
34         memcpy(outuidp, &genericCazamarUUID, sizeof(UUID));
35 }
36
37 /* compare two UIDs in the dictionary ordering */
38 int osi_UIDCmp(UUID *uid1p, UUID *uid2p)
39 {
40         register int i;
41         unsigned int v1;
42         unsigned int v2;
43         unsigned char *t1p;
44         unsigned char *t2p;
45         
46         if (uid1p->Data1 < uid2p->Data1) return -1;
47         else if (uid1p->Data1 > uid2p->Data1) return 1;
48
49         if (uid1p->Data2 < uid2p->Data2) return -1;
50         else if (uid1p->Data2 > uid2p->Data2) return 1;
51
52         if (uid1p->Data3 < uid2p->Data3) return -1;
53         else if (uid1p->Data3 > uid2p->Data3) return 1;
54
55         t1p = uid1p->Data4;
56         t2p = uid2p->Data4;
57
58         for(i=0; i<8; i++) {
59                 v1 = *t1p++;
60                 v2 = *t2p++;
61                 if (v1 < v2) return -1;
62                 else if (v1 > v2) return 1;
63         }
64         return 0;
65 }
66
67 void * __RPC_API MIDL_user_allocate(size_t size)
68 {
69   return (void *) malloc(size);
70 }
71
72 void __RPC_API MIDL_user_free(void *p)
73 {
74   free(p);
75 }