From edf0bc2352227fefe7a2fa4b547679a6573c7d8e Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Sun, 14 Jun 2026 04:01:51 +0000 Subject: [PATCH] 0497 core: import NSS registration error output base --- include/core/DisplayVersion.h | 99 +++++++ include/core/register.h | 150 +++++++++++ src/core/CMakeLists.txt | 11 + src/core/displayVersion.c | 135 ++++++++++ src/core/errprintf.c | 171 ++++++++++++ src/core/register.c | 293 +++++++++++++++++++++ tests/CMakeLists.txt | 1 + tests/core/CMakeLists.txt | 1 + tests/core/register/CMakeLists.txt | 9 + tests/core/register/test_nwcore_register.c | 30 +++ 10 files changed, 900 insertions(+) create mode 100644 include/core/DisplayVersion.h create mode 100644 include/core/register.h create mode 100644 src/core/displayVersion.c create mode 100644 src/core/errprintf.c create mode 100644 src/core/register.c create mode 100644 tests/core/register/CMakeLists.txt create mode 100644 tests/core/register/test_nwcore_register.c diff --git a/include/core/DisplayVersion.h b/include/core/DisplayVersion.h new file mode 100644 index 0000000..e2df329 --- /dev/null +++ b/include/core/DisplayVersion.h @@ -0,0 +1,99 @@ +/**************************************************************************** + | + | (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: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | 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 _DISPLAYVERSION_H_ +#define _DISPLAYVERSION_H_ + +#ifndef _ZOMNI_H_ +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------- + * Structure which defines VERSION information + *-------------------------------------------------------------------------*/ +typedef struct VersionInformation_s +{ + NINT majorVersion; /* 1-nn */ + NINT minorVersion; /* 0-nn */ + NINT subVersion; /* 0-25 */ + NINT buildNumber; /* 1-nnn */ + NINT patentInfo; /* 0-2 */ +} VersionInformation_s; + +#define VERINFO_NO_PATENT 0 +#define VERINFO_PATENT_PENDING 1 +#define VERINFO_PATENT 2 + /* any other value will come through as NO_PATENT */ + + +/*------------------------------------------------------------------------- + * Function prototypes + *-------------------------------------------------------------------------*/ +extern void DisplayVersionInformation( + char *appName, + VersionInformation_s *versionInfo, + char *flashString); /* may be NULL, if defined end with a "\n" */ + +/*------------------------------------------------------------------------- + * This will format the version number into a string. + *-------------------------------------------------------------------------*/ +extern char *FormatVersionString( + VersionInformation_s *vi, + char *retBuffer); /* assumed to be a 16 byte buffer or larger */ + +/*------------------------------------------------------------------------- + * This will display the default version information used standard names + * for NSS. + *-------------------------------------------------------------------------*/ +#define DISPLAY_DEFAULT_VERSION_INFORMATION(flashString) \ + DisplayVersionInformation(COMN_Resource.name,&COMN_Resource.verInfo,flashString); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/core/register.h b/include/core/register.h new file mode 100644 index 0000000..3cbf69b --- /dev/null +++ b/include/core/register.h @@ -0,0 +1,150 @@ +/**************************************************************************** + | + | (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: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library source + | + | 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 _REGISTER_H_ +#define _REGISTER_H_ + +#ifndef _OMNI_H_ +# include +#endif + +#ifndef _DISPLAYVERSION_H_ +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define LIBMODULE_NAME "NSSLIB" +extern const char LibModule[]; + +/*------------------------------------------------------------------------- + * Resource structure definition + *-------------------------------------------------------------------------*/ +typedef struct Resource_s +{ + ObjName_t name; /* product name */ + VersionInformation_s verInfo; +#ifdef __linux__ + void *moduleHandle; +#else + NINT serverMajorVersion; + NINT serverMinorVersion; + NINT serverSubVersion; + struct LoadDefinitionStructure *moduleHandle; +#endif + struct WFile_s *stdio; /* struct ScreenStruct *printfScreenID;*/ +#ifdef __linux__ + void *consoleScreenID; + void *debuggerScreenID; +#endif +#ifndef __linux__ + struct ScreenStruct *consoleScreenID; + struct ScreenStruct *debuggerScreenID; +#endif + +#ifdef __linux__ + void *memoryRTag; + void *timerRTag; + void *workToDoRTag; + void *eventBlkRTag; +#endif +#ifndef __linux__ + struct ResourceTagStructure *memoryRTag; +#endif + +#ifndef __linux__ + struct ResourceTagStructure *eventRTag; + struct ResourceTagStructure *timerRTag; + struct ResourceTagStructure *workToDoRTag; + struct ResourceTagStructure *mmAppRTag; + struct ResourceTagStructure *processRTag; + struct ResourceTagStructure *screenRTag; + struct ResourceTagStructure *aespRTag; + struct ResourceTagStructure *cmdLineRTag; + struct ResourceTagStructure *consoleCmdRTag; + struct ResourceTagStructure *connectionTag; + struct ResourceTagStructure *setCmdCategoryRTag; + struct ResourceTagStructure *setCmdRTag; + struct ResourceTagStructure *debugCmdRTag; + struct ResourceTagStructure *eventBlkRTag; + struct ResourceTagStructure *systemCallRTag; +#endif +} Resource_s; + +extern Resource_s COMN_Resource; + +/*------------------------------------------------------------------------- + * Functions for initialization + *-------------------------------------------------------------------------*/ +/* This is a special entry point in case you need the Resource tags inited + * before the library is initialized. The routine RegisterLibraryOwner + * normally calls this */ +#ifndef __linux__ +extern STATUS COMN_RegisterLibraryResourceTags( + char *applicationName, + struct LoadDefinitionStructure *handle, + struct ScreenStruct *printfScreenID ); +#endif +#ifdef __linux__ +extern STATUS COMN_RegisterLibraryResourceTags( + char *applicationName ); +#endif + +/* Init the library */ +extern STATUS COMN_RegisterLibraryOwner( + char *applicationName, +#ifndef __linux__ + struct LoadDefinitionStructure *applicationHandle, + struct ScreenStruct *printfScreenID, +#endif + VersionInformation_s *versionInfo); + +/* cleanup the library */ +extern void COMN_UnregisterLibraryOwner(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index f6c9443..72ffdd0 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -91,6 +91,14 @@ configure_file( "${CMAKE_SOURCE_DIR}/include/core/xStdio.h" "${NWCORE_BUILD_INCLUDE_DIR}/xStdio.h" COPYONLY) +configure_file( + "${CMAKE_SOURCE_DIR}/include/core/register.h" + "${NWCORE_BUILD_INCLUDE_DIR}/register.h" + COPYONLY) +configure_file( + "${CMAKE_SOURCE_DIR}/include/core/DisplayVersion.h" + "${NWCORE_BUILD_INCLUDE_DIR}/DisplayVersion.h" + COPYONLY) configure_file( "${CMAKE_SOURCE_DIR}/include/core/wio.h" "${NWCORE_BUILD_INCLUDE_DIR}/wio.h" @@ -223,6 +231,9 @@ add_library(nwcore SHARED mailbox.c pssDebug.c pssmpk.c + errprintf.c + register.c + displayVersion.c snprintf.c sprintf.c vsprintf.c diff --git a/src/core/displayVersion.c b/src/core/displayVersion.c new file mode 100644 index 0000000..c493c64 --- /dev/null +++ b/src/core/displayVersion.c @@ -0,0 +1,135 @@ +/**************************************************************************** + | + | (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: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library routine + +-------------------------------------------------------------------------*/ +#include +#include +#include +#include + +/************************************************************************** + * This will generate a VERSION string. This assumes the return buffer + * is at least 16 bytes long. + ***************************************************************************/ +char *FormatVersionString( + VersionInformation_s *vi, + char *retBuffer) +{ + NINT tmp; + char subver[2]; + + if (vi->subVersion == 0) + { + subver[0] = 0; + } + else + { + tmp = 'a' + vi->subVersion-1; + if (tmp < 'a') + tmp = 'a'; + else if (tmp > 'z') + tmp = 'z'; + subver[0] = tmp; + subver[1] = 0; + } + + LB_sprintf(retBuffer,MSG("%d.%02d%s", 2), + vi->majorVersion, + vi->minorVersion, + subver); + + return retBuffer; +} + +/************************************************************************** + * displays the current version of this NLM + ***************************************************************************/ +void DisplayVersionInformation( + char *appName, + VersionInformation_s *vi, + char *flashString) /* may be NULL */ +{ + char verStr[16]; + char build[32]; + char *patentStr; + + /* get VERSION string */ + ASSERT_MPKNSS_LOCK(); + FormatVersionString(vi,verStr); + + /* BUILD NUMBER */ + if (vi->buildNumber == 0) + { + build[0] = 0; + } + else + { + LB_sprintf(build,MSG(" (Build %d%s)", 3), + vi->buildNumber, +#ifdef UNOPT + MSG(" unoptimized", 4) +#else + MSGNot("") +#endif + ); + } + + /* FLASH STRING */ + if (flashString == NULL) + flashString = MSGNot(""); + + /* PATENT INFO */ + switch (vi->patentInfo) + { + case VERINFO_PATENT_PENDING: + patentStr = MSG("Patent Pending.\n", 5); + break; + case VERINFO_PATENT: + patentStr = MSG("Patented\n", 6); + break; + case VERINFO_NO_PATENT: + default: + patentStr = MSGNot(""); + break; + } + + /* display information */ + LB_aprintf(LCYAN,MSG("%s: %sVersion: %s%s\n%s", 7), + appName, + flashString, + verStr, + build, + patentStr); +} diff --git a/src/core/errprintf.c b/src/core/errprintf.c new file mode 100644 index 0000000..84f1c70 --- /dev/null +++ b/src/core/errprintf.c @@ -0,0 +1,171 @@ +/**************************************************************************** + | + | (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: taysom $ + | $Date: 2007-10-06 01:42:31 +0530 (Sat, 06 Oct 2007) $ + | + | $RCSfile$ + | $Revision: 2229 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library source + +-------------------------------------------------------------------------*/ +#include +#include +#include +#include + +#include +#include + +/* + * Table of ranges for error numbers -- note: these are not error codes + * but rather numbers that identify the error so they can be documented. + * + * Range Last Module + * ===== ==== ====== + * -1 Default until error number has been assigned. + * 1-200 075 GUI -- these don't go through errPrintf. + * 201-400 230 Library -- module name should be ModLibrary + * 401-600 408 NSS + * 601-800 741 COMN + * 801-1000 825 NWSA + * 1001-1200 1017 MMPRV + * 1201-1400 1205 NWPRV + * 1401-1600 1490 ZLSS CGAO changed to 1490 + * 1601-2000 1671 CDDVD + * 2001-2200 2002 DOSFAT + * 2201-2400 2209 MAL + * 2401-2600 2401 GSEG + * 2601-2800 2601 MENUCFG + * 2801-3000 0000 MENUDBG + * 3001-3200 0000 MENUNSS + * 3201-3400 3239 VLDB + * 3401-3600 3413 VOLMAN + * + * 5001-5200 5006 Alerts -- system alerts + * + * 100000 TEST_MODULE all tests should use the same #define TEST_MODULE + * + * Usage: + * errPrintf(WHERE, [Module LibModule NULL], errnum, + * MSG("format", 0) [, args ...]); + * + * Conventions: + * 1. errPrintf thru errnum must be on one line. + * 2. format does not need last '\n' + * + * Examples: + * errPrintf(WHERE, LibModule, 234, + * MSG("crazy error %d %d\n", 348), status, id); + * + * errPrintf(WHERE, Module, 1432, + * MSG("Things are really bad %d\n", 238), status); + * + * New Message: + * errPrintf(WHERE, Module, -1, + * MSG("Need to restore volume\n", 0)); + * + */ + +const char LibModule[] = LIBMODULE_NAME; + + +/************************************************************************** + * This will display a standard error message on the printf screen. If + * the printf screen is not defined yet, it will output to the CONSOLE. + ***************************************************************************/ +void LB_errPrintf( + const char *where, + const char *moduleName, /* may be NULL if no seperate MODULE name */ + int errnum, + const char *format, + ...) +{ + va_list args; + typedef struct Stack_s { + char errstr[16]; + char verstr[16]; /* holds version number */ + char time[32]; + char mname[64]; + char msgBuf[1024]; + } Stack_s; + STACK_ALLOC(); + + if (errnum != -1) + { + LB_sprintf(aStack->errstr, MSGNot("%d"), errnum); + } + else + { + strcpy(aStack->errstr, MSGNot("xxxx")); + } + + if (moduleName != NULL) + { + LB_sprintf(aStack->mname,MSG("<%s>",110),moduleName); + } + else + { + aStack->mname[0] = 0; /* make a NULL string */ + } + + LB_aprintf(LRED,MSG("\n%s %s%s-%s-%s: %s\n", 111), + UTCTime2Str(GetUTCTime(),aStack->time), + COMN_Resource.name, + aStack->mname, + FormatVersionString(&COMN_Resource.verInfo,aStack->verstr), + aStack->errstr, + where); + va_start(args,format); + LB_vsprintf(aStack->msgBuf,format,args); + va_end( args ); + LB_aprintf(LGRAY,MSG(" %s\n\n",112),aStack->msgBuf); + +#ifdef MPK + /* Above if is a kludge to get CMD to link. Technicaly, errPrintf + * should not be calling NSS, but I did not want to modify the 400+ + * callers of errPrintf to call a NSS specific routine. + */ + + /* Place the error message into the C:NSS.LOG */ + (void)NSSLOG_printf( + NULL, + where, LOG_ERR, NSSLOG_TYPE_ERRPRINTF, +// MSGNot("%s %s%s-%s-%s: %s\n %s" ), + MSGNot("%s %s%s-%s-%s:\n %s" ), + UTCTime2Str(GetUTCTime(),aStack->time), + COMN_Resource.name, + aStack->mname, + FormatVersionString(&COMN_Resource.verInfo,aStack->verstr), + aStack->errstr, +// where, + aStack->msgBuf ); +#endif + STACK_FREE(); +//#endif +} diff --git a/src/core/register.c b/src/core/register.c new file mode 100644 index 0000000..af33cb2 --- /dev/null +++ b/src/core/register.c @@ -0,0 +1,293 @@ +/**************************************************************************** + | + | (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: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library source + +-------------------------------------------------------------------------*/ +#include /* NetWare includes*/ +#include /* NSS Include to do conditional compilation */ + + +#include /* NSS Library includes*/ +#include +#include +#include +#include +#include +#include +#include + +/* Linux userspace port: the NSS intmem free-list checker belongs to the + * kernel/private allocator backend. malloc.c maps allocation to libc here. */ +#ifndef LB_CHECK_FREE_LIST +#define LB_CHECK_FREE_LIST() ((void)0) +#endif + +/*------------------------------------------------------------------------- + * Registration structure + *-------------------------------------------------------------------------*/ +Resource_s COMN_Resource = +{ + {MSGNot("UNKNOWN")}, /* name */ + {0}, /* majorVersion */ + 0, /* minorVersion */ + 0, /* subVersion */ + 0, /* buildNumber */ +}; + +typedef struct Tag_s +{ + ObjName_t label; + LONG signature; + struct ResourceTagStructure **tag; + NINT flags; +} Tag_s; + +#define TFLG_OPTIONAL 0x00000001 + + +#ifndef __linux__ // LINUX_ResourceTags +STATIC Tag_s InternalTags[] = +{ + {MSGNot("Memory"), AllocSignature, &COMN_Resource.memoryRTag ,0 }, + {MSGNot("Event"), EventSignature, &COMN_Resource.eventRTag ,0 }, + {MSGNot("Timer"), TimerSignature, &COMN_Resource.timerRTag ,0 }, + {MSGNot("WorkToDo"), WorkCallBackSignature, &COMN_Resource.workToDoRTag ,0 }, + {MSGNot("MM App."), MMApplicationSignature, &COMN_Resource.mmAppRTag ,0 }, + {MSGNot("Process"), ProcessSignature, &COMN_Resource.processRTag ,0 }, + {MSGNot("Screen"), ScreenSignature, &COMN_Resource.screenRTag ,0 }, + {MSGNot("AESProcess"), AESProcessSignature, &COMN_Resource.aespRTag ,0 }, + {MSGNot("Command Line"), CommandLineServicesSignature, &COMN_Resource.cmdLineRTag ,0 }, + {MSGNot("ConsoleCommand"), ConsoleCommandSignature, &COMN_Resource.consoleCmdRTag ,0 }, + {MSGNot("Connection"), ConnectionSignature, &COMN_Resource.connectionTag ,0 }, + {MSGNot("Set Category"), SetParameterCategorySignature, &COMN_Resource.setCmdCategoryRTag ,TFLG_OPTIONAL }, + {MSGNot("Set Commands"), SetableParameterSignature, &COMN_Resource.setCmdRTag ,0 }, + {MSGNot("Debug Commands"), DebugCommandSignature, &COMN_Resource.debugCmdRTag ,0 }, + {MSGNot("Event Block"), EVENT_BLOCK_SIGNATURE, &COMN_Resource.eventBlkRTag ,TFLG_OPTIONAL}, + {MSGNot("System Call"), SystemCallSignature, &COMN_Resource.systemCallRTag ,0 }, + {MSGNot(""), 0, NULL ,0 } +}; +#endif + +/*--------------------------------------------------------------------------- + * Global varaibles which point to internal netware data items + *---------------------------------------------------------------------------*/ + +/************************************************************************** + * This routine will allocate the Resource Tags + ***************************************************************************/ +#ifndef __linux__ // LINUX_ResourceTags +extern STATUS COMN_RegisterLibraryResourceTags( + char *name, + struct LoadDefinitionStructure *handle, + struct ScreenStruct *printfScreenID ) +#endif +#ifdef __linux__ // LINUX_ResourceTags +extern STATUS COMN_RegisterLibraryResourceTags( + char *name ) +#endif +{ +#ifndef __linux__ // LINUX_ResourceTags + Tag_s *tag; +#endif + BOOL resourceTagFailure = FALSE; + static BOOL didAllocateTags = FALSE; + + ASSERT_MPKNSS_LOCK(); + +/*------------------------------------------------------------------------- + * See if this routine was already called. If so just return OK + *-------------------------------------------------------------------------*/ + if (didAllocateTags) + return zOK; + didAllocateTags = TRUE; +/*------------------------------------------------------------------------- + * Do default initialization + *-------------------------------------------------------------------------*/ + LB_strmcpy(COMN_Resource.name, name, sizeof(COMN_Resource.name)); + COMN_Resource.stdio = NULL; +#ifdef __linux__ // LINUX_ResourceTags +//FixFixFix(linux) caller should be passing in HANDLE!! + COMN_Resource.moduleHandle = 0; +#endif +#ifndef __linux__ // LINUX_ResourceTags + COMN_Resource.moduleHandle = handle; + ZOS_GetSystemConsoleScreen(COMN_Resource.consoleScreenID); +/*--------------------------------------------------------------------------- + * Get desired Resource tags. + *---------------------------------------------------------------------------*/ + for (tag = InternalTags; tag->tag != NULL; ++tag) + { + char string[3 * sizeof(ObjName_t)]; + + if (*tag->tag == NULL) /* see if RTAG already present*/ + { + strcpy(string, COMN_Resource.name); + strcat(string, MSGNot(" ")); + strcat(string, tag->label); + ZOS_AllocateResourceTag(*tag->tag, + COMN_Resource.moduleHandle, + string, + tag->signature); + if (*tag->tag == NULL) + { + if ( !(tag->flags & TFLG_OPTIONAL) ) + { + OutputToScreenWithAttribute(printfScreenID,LRED, + MSG("\nNSS-2.70-225: Unable to allocate \"%s\" resource tag.\n" + "A non-NSS error has occurred. Contact your Novell Technical Support Provider.\n", 224), + string); + resourceTagFailure = TRUE; + } + } + } + } +#endif + return ((resourceTagFailure) ? zFAILURE : zOK); +} + +/************************************************************************** + * This routine allocates Resource tags and initializes the library system + * This routine can be called more than once if some options need to be + * changed. + ***************************************************************************/ +STATUS COMN_RegisterLibraryOwner( + char *name, +#ifndef __linux__ // LINUX_ResourceTags + struct LoadDefinitionStructure *handle, + struct ScreenStruct *printfScreenID, +#endif + VersionInformation_s *versionInfo) +{ + ASSERT_MPKNSS_LOCK(); + srand(GetUTCTime()); + LB_strmcpy(COMN_Resource.name, name, sizeof(COMN_Resource.name)); +#ifndef __linux__ // LINUX_ResourceTags + COMN_Resource.moduleHandle = handle; +#endif + COMN_Resource.stdio = NULL; +#ifdef __linux__ // LINUX_ResourceTags + COMN_Resource.consoleScreenID = NULL; +#endif +#ifndef __linux__ // LINUX_ResourceTags + ZOS_GetSystemConsoleScreen(COMN_Resource.consoleScreenID); //MP-safe - Abhijit +#endif + /* Set application version numbers */ + COMN_Resource.verInfo = *versionInfo; + +#ifndef __linux__ // LINUX_ResourceTags + /* Acquire and store the version of the operating system */ + ZOS_GetFileServerMajorVersionNumber(COMN_Resource.serverMajorVersion); //MP-safe - Abhijit + ZOS_GetFileServerMinorVersionNumber(COMN_Resource.serverMinorVersion); //MP-safe - Abhijit + ZOS_GetFileServerRevisionNumber(COMN_Resource.serverSubVersion); //MP-safe - Abhijit +#endif + +/*--------------------------------------------------------------------------- + * Get desired Resource tags. + *---------------------------------------------------------------------------*/ +#ifndef __linux__ // LINUX_ResourceTags + if (COMN_RegisterLibraryResourceTags(name,handle,printfScreenID) != zOK) + return zFAILURE; +#endif +#ifdef __linux__ // LINUX_ResourceTags + if (COMN_RegisterLibraryResourceTags(name) != zOK) + { + return zFAILURE; + } +#endif +#ifndef __linux__ // LINUX_ResourceTags + LB__wioInit(); +/*--------------------------------------------------------------------------- + * Initialize common sub-systems + *---------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------- + * see if we need to create a screen + *-------------------------------------------------------------------------*/ + if (printfScreenID == NULL) + COMN_Resource.stdio = wOpen(name,0); /* always switch to screen*/ + else + COMN_Resource.stdio = LB__wioCreateWFile(printfScreenID,WFLAGS_SCREEN_EXTERNAL); + + if (COMN_Resource.stdio == NULL) + { + errPrintf(WHERE, LibModule, 204, + MSG("Unable to initialize screen \"%s\".\n" + "A non-NSS error has occurred. Contact your Novell Technical Support Provider.", + 225), name); + LB__wioUninit(); + return zFAILURE; + } +#endif +/*------------------------------------------------------------------------- + * Finish initialization. + *-------------------------------------------------------------------------*/ +//FixFixFix5: -- temporarily taken out until we decide to use this stuff +// SPD 190440 +// if (PSSSetCmdInit() != zOK) +// { +// status = zFAILURE; +// goto error_cleanup; +// } + + return zOK; +/*--------------------------------------------------------------------------- + * General ERROR handling + *---------------------------------------------------------------------------*/ +//error_cleanup: +// UnregisterLibraryOwner(); +// return status; +} + + +/************************************************************************** + * This will cleanup the library code. + ***************************************************************************/ +void COMN_UnregisterLibraryOwner() +{ +//FixFixFix5 -- temporarily taken out until we decide to use this stuff +// SPD 190440 +// PSSSetCmdUnInit(); + + if (COMN_Resource.stdio != NULL) + { +#ifndef __linux__ // LINUX_ResourceTags + wClose(COMN_Resource.stdio); +#endif + COMN_Resource.stdio = NULL; + } +#ifndef __linux__ // LINUX_ResourceTags + LB__wioUninit(); +#endif + LB_CHECK_FREE_LIST(); +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b801598..f6c0e80 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -22,6 +22,7 @@ if(MARS_NWE_BUILD_NWFS_TESTS) add_subdirectory(core/pssmpk) add_subdirectory(core/mailbox) add_subdirectory(core/pssdebug) + add_subdirectory(core/register) add_subdirectory(core/zalloc) add_subdirectory(core/stdio) add_subdirectory(core/wio) diff --git a/tests/core/CMakeLists.txt b/tests/core/CMakeLists.txt index f1d34bd..efed937 100644 --- a/tests/core/CMakeLists.txt +++ b/tests/core/CMakeLists.txt @@ -8,6 +8,7 @@ add_subdirectory(spinlock) add_subdirectory(pssmpk) add_subdirectory(mailbox) add_subdirectory(pssdebug) +add_subdirectory(register) add_subdirectory(bit) add_subdirectory(bitmap) add_subdirectory(crc) diff --git a/tests/core/register/CMakeLists.txt b/tests/core/register/CMakeLists.txt new file mode 100644 index 0000000..dc82f03 --- /dev/null +++ b/tests/core/register/CMakeLists.txt @@ -0,0 +1,9 @@ +add_executable(test_nwcore_register + test_nwcore_register.c) + +target_compile_features(test_nwcore_register PRIVATE c_std_99) +target_include_directories(test_nwcore_register PRIVATE + "${CMAKE_SOURCE_DIR}/include/core") +target_link_libraries(test_nwcore_register PRIVATE mars_nwe::core) + +add_test(NAME nwcore.register COMMAND test_nwcore_register) diff --git a/tests/core/register/test_nwcore_register.c b/tests/core/register/test_nwcore_register.c new file mode 100644 index 0000000..f68b0e2 --- /dev/null +++ b/tests/core/register/test_nwcore_register.c @@ -0,0 +1,30 @@ +#include + +#include +#include +#include + +int main(void) +{ + VersionInformation_s vi = {1, 26, 2, 0, VERINFO_NO_PATENT}; + char version[16]; + + if (strcmp(FormatVersionString(&vi, version), "1.26b") != 0) + return 1; + + if (COMN_RegisterLibraryOwner("nwcore", &vi) != zOK) + return 2; + + if (strcmp(COMN_Resource.name, "nwcore") != 0) + return 3; + + if (COMN_Resource.verInfo.majorVersion != 1 || + COMN_Resource.verInfo.minorVersion != 26 || + COMN_Resource.verInfo.subVersion != 2) + return 4; + + LB_errPrintf(WHERE, LibModule, 209, "register smoke %s", "ok"); + COMN_UnregisterLibraryOwner(); + + return 0; +}