nwpre.pp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by the Free Pascal development team
  4. Copyright (c) 2001 Armin Diehl
  5. This unit implements the startup code for a netware nlm. It must be the first object file
  6. linked. Currently the 'old-style', similar to novell's prelude.obj is used. With the newer
  7. way (novells nwpre.obj) i only got abends. Dont know what's different in novells nwpre.
  8. See the file COPYING.FPC, included in this distribution,
  9. for details about the copyright.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. **********************************************************************}
  14. unit nwpre;
  15. interface
  16. { 2000/08/29 armin: first version, untested
  17. 2000/09/02 armin: Dont know why its not working with kNLMInfo...
  18. It always abends in TerminateNLM, so i am using the old style
  19. 2001/04/15 armin: Added comments, S-
  20. Removed dead code }
  21. {$DEFINE OldPrelude}
  22. FUNCTION _Prelude (NLMHandle : LONGINT;
  23. initErrorScreenID : LONGINT;
  24. cmdLineP : PCHAR;
  25. loadDirectoryPath : PCHAR;
  26. uninitializedDataLength : LONGINT;
  27. NLMFileHandle : LONGINT;
  28. readRoutineP : POINTER;
  29. customDataOffset : LONGINT;
  30. customDataSize : LONGINT) : LONGINT; CDECL;
  31. implementation
  32. {$S-}
  33. FUNCTION _TerminateNLM (NLMInformation : POINTER;
  34. threadID, status : LONGINT) : LONGINT; CDECL; EXTERNAL;
  35. FUNCTION _SetupArgV_411 (MainProc : POINTER) : LONGINT; CDECL; EXTERNAL;
  36. FUNCTION _StartNLM (NLMHandle : LONGINT;
  37. initErrorScreenID : LONGINT;
  38. cmdLineP : PCHAR;
  39. loadDirectoryPath : PCHAR;
  40. uninitializedDataLength : LONGINT;
  41. NLMFileHandle : LONGINT;
  42. readRoutineP : POINTER;
  43. customDataOffset : LONGINT;
  44. customDataSize : LONGINT;
  45. NLMInformation : POINTER;
  46. userStartFunc : POINTER) : LONGINT; CDECL; EXTERNAL;
  47. {**************************************************************************************************}
  48. CONST TRADINIONAL_NLM_INFO_SIGNATURE = 0;
  49. TRADINIONAL_FLAVOR = 0;
  50. TRADINIONAL_VERSION = 0;
  51. LIBERTY_VERSION = 1;
  52. TERMINATE_BY_EXTERNAL_THREAD = 0;
  53. TERMINATE_BY_UNLOAD = 5;
  54. {$IFDEF OldPrelude}
  55. CONST NLMID : LONGINT = 0;
  56. {$ELSE}
  57. TYPE
  58. kNLMInfoT =
  59. PACKED RECORD
  60. Signature : ARRAY [0..3] OF CHAR; // LONG
  61. Flavor : LONGINT;
  62. Version : LONGINT;
  63. LongDoubleSize : LONGINT;
  64. wchar_tSize : LONGINT;
  65. END;
  66. CONST NLM_INFO_SIGNATURE = 'NLMI'; // 0x494d3c3e;
  67. kNLMInfo : kNLMInfoT =
  68. (Signature : NLM_INFO_SIGNATURE;
  69. Flavor : TRADINIONAL_FLAVOR; // 0
  70. Version : LIBERTY_VERSION; // 1
  71. LongDoubleSize : 8;
  72. wchar_tSize : 2);
  73. {$ENDIF}
  74. {**************************************************************************************************}
  75. { _nlm_main is defined in system.pp. It sets command line parameters and calls PASCALMAIN }
  76. FUNCTION _nlm_main (Argc : LONGINT; ArgV : ARRAY OF PCHAR) : LONGINT; CDECL;
  77. EXTERNAL;
  78. FUNCTION _Stop : LONGINT; CDECL;
  79. BEGIN
  80. {$IFDEF OldPrelude}
  81. _Stop := _TerminateNLM (POINTER(NLMID),0,TERMINATE_BY_UNLOAD);
  82. {$ELSE}
  83. _Stop := _TerminateNLM (@kNLMInfo,0,TERMINATE_BY_UNLOAD);
  84. {$ENDIF}
  85. END;
  86. FUNCTION _cstart_ : LONGINT; CDECL;
  87. BEGIN
  88. _cstart_ := _SetupArgV_411 (@_nlm_main);
  89. END;
  90. FUNCTION _Prelude (NLMHandle : LONGINT;
  91. initErrorScreenID : LONGINT;
  92. cmdLineP : PCHAR;
  93. loadDirectoryPath : PCHAR;
  94. uninitializedDataLength : LONGINT;
  95. NLMFileHandle : LONGINT;
  96. readRoutineP : POINTER;
  97. customDataOffset : LONGINT;
  98. customDataSize : LONGINT) : LONGINT; CDECL;
  99. BEGIN
  100. _Prelude := _StartNLM
  101. (NLMHandle,
  102. initErrorScreenID,
  103. cmdLineP,
  104. loadDirectoryPath,
  105. uninitializedDataLength,
  106. NLMFileHandle,
  107. readRoutineP,
  108. customDataOffset,
  109. customDataSize,
  110. {$IFDEF OldPrelude}
  111. @NLMID,
  112. {$ELSE}
  113. @kNLMInfo,
  114. {$ENDIF}
  115. @_cstart_);
  116. END;
  117. end.