/*************************************************************************** $name: KeyValue.c $version: 1.0 $date_modified: 101399 $description: Demonstrates some rudimentary use of the key-value pair. $owner: NKS Product Manager Copyright (c) 1999 Novell, Inc. All Rights Reserved. THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND TREATIES. USE AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO THE LICENSE AGREEMENT ACCOMPANYING THE SOFTWARE DEVELOPMENT KIT (SDK) THAT CONTAINS THIS WORK. PURSUANT TO THE SDK LICENSE AGREEMENT, NOVELL HEREBY GRANTS TO DEVELOPER A ROYALTY-FREE, NON-EXCLUSIVE LICENSE TO INCLUDE NOVELL'S SAMPLE CODE IN ITS PRODUCT. NOVELL GRANTS DEVELOPER WORLDWIDE DISTRIBUTION RIGHTS TO MARKET, DISTRIBUTE, OR SELL NOVELL'S SAMPLE CODE AS A COMPONENT OF DEVELOPER'S PRODUCTS. NOVELL SHALL HAVE NO OBLIGATIONS TO DEVELOPER OR DEVELOPER'S CUSTOMERS WITH RESPECT TO THIS CODE. ****************************************************************************/ #include <time.h> #include <nks/thread.h> void OurDataDestructor ( void *data ) { /* ** Since no actual allocation is stored as data (only the time_t value), there ** is nothing to dispose of. If we had stored a whole struct tm, we would have ** to call NXMemFree here. We could have registered no destructor at all. */ return; } int gErrorExit = -1; int THR_TIME_KEY = 0; // after instantiation, will become like a constant int main ( int argc, char **argv ) { int err; time_t time; err = NXKeyCreate(OurDataDestructor, (void *) NULL, &THR_TIME_KEY); if (err) // error: NX_EAGAIN (out of key slots) or NX_ENOMEM NXThreadExit(&gErrorExit); // set first thread time as 18 January 1997, 17h20:00... err = NXKeySetValue(THR_TIME_KEY, (void *) 0x32E168B0); // code goes here. . . // get the thread time as marked on this thread... err = NXKeyGetValue(THR_TIME_KEY, (void **) &time); // more code goes here. . . NXKeyDelete(THR_TIME_KEY); return 0; }