nwpre.pp 5.1 KB

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