// Sample code file: SGUID.H

// Warning: This code has been marked up for HTML
#ifndef   _SGUID_H_
#define   _SGUID_H_
/**************************************************************************
 *
 * (C) Copyright 1998 by Novell, Inc.
 * All Rights Reserved.
 *
 * This program is an unpublished copyrighted work which is proprietary
 * to Novell, Inc. and contains confidential information that is not
 * to be reproduced or disclosed to any other person or entity without
 * prior written consent from Novell, Inc. in each and every instance.
 *
 * WARNING:  Unauthorized reproduction of this program as well as
 * unauthorized preparation of derivative works based upon the
 * program or distribution of copies by sale, rental, lease or
 * lending are violations of federal copyright laws and state trade
 * secret laws, punishable by civil and criminal penalties.
 *
 **************************************************************************
 *
 *     Header file for the server SGUID.NLM
 *
 ***********************************************************************
*/

/* ======== Defines =================================================== */

/* Errors */
#define SGUID_OK                  0
#define SGUID_ERR_BAD_FORMAT      -1
#define SGUID_ERR_BAD_VERSION      -2
#define SGUID_ERR_REGISTRY_ERROR   -3

/* warnings */
#define SGUID_WARN_RANDOM_NODE   1      /* no Ethernet node known, used random number */

/* length of a formatted guid string */
#define GUID_STRING_LENGTH      36

/* ======== Structures ================================================ */

typedef struct GUID {
   UINT32 time_low;
   UINT16 time_mid;
   UINT16 time_hi_and_version;
   UINT8  clk_seq_hi_res;
   UINT8  clk_seq_low;
   UINT8    node[6];
} GUID;

/* ======== Prototypes ================================================ */

/* create a null guid */
void SGUIDCreateNil(GUID *guidBfr);

/* return a newly-generated guid */
int SGUIDCreate(GUID *guidBfr);

/* return multiple newly-generated guids */
int SGUIDCreateMultiple(GUID *guidBfr, UINT32 bfrSize, UINT32 *inOutGuidCount);

/* return the server's guid */
int SGUIDReturnServerGUID(GUID *guidBfr);

/* set the server's guid */
int SGUIDSetServerGUID(GUID *guidBfr);

/* Convert a guid to a displayable string. guid strings are 36 characters
 *      plus a terminating null.
 *      guid string form: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx */
int SGUIDToString(GUID *guidBfr, BYTE *strBfr, UINT32 bufMax);

/* Convert a displayable guid string to its binary form.
 *      assumes source string is null-terminated. */
int SGUIDFromString(GUID *guidBfr, BYTE *strBfr);

/* compare two guids for equality. Returns 1 iff equal, 0 iff unequal */
BOOLEAN SGUIDEqual(GUID *guidA, GUID *guidB);

/* compare a guid to the null guid. Returns 1 iff equal, 0 iff unequal */
BOOLEAN SGUIDIsNil(GUID *guid);

#endif /* _SGUID_H_ */