start.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2016 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Author: Novell, Inc. |
  16. +----------------------------------------------------------------------+
  17. */
  18. #include <library.h>
  19. #include <netware.h>
  20. #include <nks/synch.h>
  21. void *gLibHandle = (void *) NULL;
  22. rtag_t gAllocTag = (rtag_t) NULL;
  23. NXMutex_t *gLibLock = (NXMutex_t *) NULL;
  24. int gLibId = 0;
  25. int DisposeLibraryData( void *data)
  26. {
  27. return 0;
  28. }
  29. int _NonAppStart
  30. (
  31. void *NLMHandle,
  32. void *errorScreen,
  33. const char *cmdLine,
  34. const char *loadDirPath,
  35. size_t uninitializedDataLength,
  36. void *NLMFileHandle,
  37. int (*readRoutineP)( int conn, void *fileHandle, size_t offset,
  38. size_t nbytes, size_t *bytesRead, void *buffer ),
  39. size_t customDataOffset,
  40. size_t customDataSize,
  41. int messageCount,
  42. const char **messages
  43. )
  44. {
  45. NX_LOCK_INFO_ALLOC(liblock, "Per-Application Data Lock", 0);
  46. #pragma unused(cmdLine)
  47. #pragma unused(loadDirPath)
  48. #pragma unused(uninitializedDataLength)
  49. #pragma unused(NLMFileHandle)
  50. #pragma unused(readRoutineP)
  51. #pragma unused(customDataOffset)
  52. #pragma unused(customDataSize)
  53. #pragma unused(messageCount)
  54. #pragma unused(messages)
  55. /* Here we process our command line, post errors (to the error screen),
  56. * perform initializations and anything else we need to do before being able
  57. * to accept calls into us. If we succeed, we return non-zero and the NetWare
  58. * Loader will leave us up, otherwise we fail to load and get dumped.
  59. */
  60. /**
  61. gAllocTag = AllocateResourceTag(NLMHandle,
  62. "<library-name> memory allocations", AllocSignature);
  63. if (!gAllocTag) {
  64. OutputToScreen(errorScreen, "Unable to allocate resource tag for "
  65. "library memory allocations.\n");
  66. return -1;
  67. }
  68. **/
  69. gLibId = register_library(DisposeLibraryData);
  70. if (gLibId == -1) {
  71. OutputToScreen(errorScreen, "Unable to register library with kernel.\n");
  72. return -1;
  73. }
  74. gLibHandle = NLMHandle;
  75. gLibLock = NXMutexAlloc(0, 0, &liblock);
  76. if (!gLibLock) {
  77. OutputToScreen(errorScreen, "Unable to allocate library data lock.\n");
  78. return -1;
  79. }
  80. return 0;
  81. }
  82. void _NonAppStop( void )
  83. {
  84. /* Here we clean up any resources we allocated. Resource tags is a big part
  85. * of what we created, but NetWare doesn't ask us to free those.
  86. */
  87. (void) unregister_library(gLibId);
  88. NXMutexFree(gLibLock);
  89. }
  90. int _NonAppCheckUnload( void )
  91. {
  92. /* This function cannot be the first in the file for if the file is linked
  93. * first, then the check-unload function's offset will be nlmname.nlm+0
  94. * which is how to tell that there isn't one. When the check function is
  95. * first in the linked objects, it is ambiguous. For this reason, we will
  96. * put it inside this file after the stop function.
  97. *
  98. * Here we check to see if it's alright to ourselves to be unloaded. If not,
  99. * we return a non-zero value. Right now, there isn't any reason not to allow
  100. * it.
  101. */
  102. return 0;
  103. }