Files
mars-nwe/include/core/guid.h
OpenAI 32bfd2ccbd
Some checks failed
Source release / source-package (push) Failing after 10m58s
core: import NSS GUID and ID helpers into libnwcore
2026-06-12 21:18:49 +02:00

155 lines
5.0 KiB
C

/****************************************************************************
|
| (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| This program is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
|
| You should have received a copy of the GNU General Public License
| along with this program; if not, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| NetWare Advance File Services (NSS) module
|
|---------------------------------------------------------------------------
|
| $Author: vandana $
| $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $
|
| $RCSfile$
| $Revision: 1177 $
|
|---------------------------------------------------------------------------
| This module is used to:
| NSS Library Routine
|
| WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
|
| This header file should ONLY be used for NSS internal development.
| This includes Semantic Agents (SA) and Loadable Storage Services (LSS).
| Any other use may cause conflicts which NSS will NOT fix.
+-------------------------------------------------------------------------*/
#ifndef _GUID_H_
#define _GUID_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _ZOMNI_H_
#include <zOmni.h>
#endif
#ifndef _NSS_STRING_H_
#include <string.h>
#endif
/* Size needed to hold the standard GUID formatted string */
#define GUID_FORMAT_SIZE 38
extern GUID_t zZERO_GUID;
extern GUID_t zINVALID_GUID;
extern GUID_t zADMINVOL_GUID;
extern void LB_GUIDGenerate( GUID_t *retGuid );
#define LB_GUIDCompare(_g1, _g2) \
((SNINT)((((LONG *)(_g1))[0] != ((LONG *)(_g2))[0]) \
? (((LONG *)(_g1))[0] > ((LONG *)(_g2))[0]) \
? 1 \
: -1 \
: (((LONG *)(_g1))[1] != ((LONG *)(_g2))[1]) \
? (((LONG *)(_g1))[1] > ((LONG *)(_g2))[1]) \
? 1 \
: -1 \
: (((LONG *)(_g1))[2] != ((LONG *)(_g2))[2]) \
? (((LONG *)(_g1))[2] > ((LONG *)(_g2))[2]) \
? 1 \
: -1 \
: (((LONG *)(_g1))[3] != ((LONG *)(_g2))[3]) \
? (((LONG *)(_g1))[3] > ((LONG *)(_g2))[3]) \
? 1 \
: -1 \
: 0))
/* Special compare for ZLSS BT blocks, they store the blocks
* volume block number in the first 4 bytes of the mac address.
* Therefore this routine skips those fields. Added for NW65
* SP4 so that when change is made the customer can still roll
* back.
*/
#define LB_GUIDCompareWithBlock(_g1, _g2) \
((SNINT)((((LONG *)(_g1))[0] != ((LONG *)(_g2))[0]) \
? (((LONG *)(_g1))[0] > ((LONG *)(_g2))[0]) \
? 1 \
: -1 \
: (((LONG *)(_g1))[1] != ((LONG *)(_g2))[1]) \
? (((LONG *)(_g1))[1] > ((LONG *)(_g2))[1]) \
? 1 \
: -1 \
: (((WORD *)(_g1))[4] != ((WORD *)(_g2))[4]) \
? (((WORD *)(_g1))[4] > ((WORD *)(_g2))[4]) \
? 1 \
: -1 \
: (((WORD *)(_g1))[7] != ((WORD *)(_g2))[7]) \
? (((WORD *)(_g1))[7] > ((WORD *)(_g2))[7]) \
? 1 \
: -1 \
: 0))
/*
#define LB_GUIDCompare(_g1, _g2) \
((SNINT)((((QUAD *)(_g1))[0] != ((QUAD *)(_g2))[0]) \
? (((QUAD *)(_g1))[0] > ((QUAD *)(_g2))[0]) \
? 1 \
: -1 \
: (((QUAD *)(_g1))[1] != ((QUAD *)(_g2))[1]) \
? (((QUAD *)(_g1))[1] > ((QUAD *)(_g2))[1]) \
? 1 \
: -1 \
: 0))
*/
/* Problem when comparing numbers with opposite signs
#define LB_GUIDCompare(_g1, _g2) \
((SLONG)((((LONG *)(_g1))[0] - ((LONG *)(_g2))[0]) \
? (((LONG *)(_g1))[0] - ((LONG *)(_g2))[0]) \
: ((((LONG *)(_g1))[1] - ((LONG *)(_g2))[1]) \
? (((LONG *)(_g1))[1] - ((LONG *)(_g2))[1]) \
: ((((LONG *)(_g1))[2] - ((LONG *)(_g2))[2]) \
? (((LONG *)(_g1))[2] - ((LONG *)(_g2))[2]) \
: (((LONG *)(_g1))[3] - ((LONG *)(_g2))[3])))))
*/
/*
#define LB_GUIDCompare(_guid1,_guid2) \
(memcmp((_guid1),(_guid2),sizeof(GUID_t)))
*/
extern QUAD GUID_getTime(void);
extern void GUID_init(void);
extern int LB_GUIDValidate( GUID_t *TESTGuid );
STATUS LB_GUIDFromUTF8( utf8_t *p, GUID_t *guid );
STATUS LB_GUIDToString( const GUID_t *guid, unsigned int bufferSize, char *buffer );
STATUS LB_GUIDToVolumeName( const GUID_t *guid, NINT bufferSize, unicode_t *buffer );
STATUS LB_GUIDTimeToShortVolumeName( const GUID_t *guid, NINT bufferSize, unicode_t *buffer );
#ifdef __cplusplus
}
#endif
#endif /* _GUID_H_ */