@lpc-lang/core 1.1.2-5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/README.md +255 -0
  2. package/bin/lpc +4 -0
  3. package/bin/lpcserver +4 -0
  4. package/cancellationToken/cancellationToken.d.ts +8 -0
  5. package/cancellationToken/cancellationToken.d.ts.map +1 -0
  6. package/cancellationToken/serverCancellationToken.d.ts +21 -0
  7. package/cancellationToken/serverCancellationToken.d.ts.map +1 -0
  8. package/cli/_namespaces/lpc.d.ts +2 -0
  9. package/cli/_namespaces/lpc.d.ts.map +1 -0
  10. package/cli/lpc.d.ts +2 -0
  11. package/cli/lpc.d.ts.map +1 -0
  12. package/compiler/LpcConfig.d.ts +17 -0
  13. package/compiler/LpcConfig.d.ts.map +1 -0
  14. package/compiler/_namespaces/lpc.d.ts +49 -0
  15. package/compiler/_namespaces/lpc.d.ts.map +1 -0
  16. package/compiler/_namespaces/lpc.moduleSpecifiers.d.ts +2 -0
  17. package/compiler/_namespaces/lpc.moduleSpecifiers.d.ts.map +1 -0
  18. package/compiler/_namespaces/lpc.performance.d.ts +2 -0
  19. package/compiler/_namespaces/lpc.performance.d.ts.map +1 -0
  20. package/compiler/binder.d.ts +2 -0
  21. package/compiler/binder.d.ts.map +1 -0
  22. package/compiler/builderPublic.d.ts +76 -0
  23. package/compiler/builderPublic.d.ts.map +1 -0
  24. package/compiler/checker.d.ts +2 -0
  25. package/compiler/checker.d.ts.map +1 -0
  26. package/compiler/commandLineParser.d.ts +47 -0
  27. package/compiler/commandLineParser.d.ts.map +1 -0
  28. package/compiler/core.d.ts +3 -0
  29. package/compiler/core.d.ts.map +1 -0
  30. package/compiler/corePublic.d.ts +19 -0
  31. package/compiler/corePublic.d.ts.map +1 -0
  32. package/compiler/debug.d.ts +71 -0
  33. package/compiler/debug.d.ts.map +1 -0
  34. package/compiler/diagnosticInformation.d.ts +518 -0
  35. package/compiler/diagnosticInformation.d.ts.map +1 -0
  36. package/compiler/emitter.d.ts +11 -0
  37. package/compiler/emitter.d.ts.map +1 -0
  38. package/compiler/executeCommandLine.d.ts +15 -0
  39. package/compiler/executeCommandLine.d.ts.map +1 -0
  40. package/compiler/expressionToTypeNode.d.ts +2 -0
  41. package/compiler/expressionToTypeNode.d.ts.map +1 -0
  42. package/compiler/factory/baseNodeFactory.d.ts +2 -0
  43. package/compiler/factory/baseNodeFactory.d.ts.map +1 -0
  44. package/compiler/factory/emitHelper.d.ts +2 -0
  45. package/compiler/factory/emitHelper.d.ts.map +1 -0
  46. package/compiler/factory/emitNode.d.ts +22 -0
  47. package/compiler/factory/emitNode.d.ts.map +1 -0
  48. package/compiler/factory/nodeChildren.d.ts +2 -0
  49. package/compiler/factory/nodeChildren.d.ts.map +1 -0
  50. package/compiler/factory/nodeConverters.d.ts +2 -0
  51. package/compiler/factory/nodeConverters.d.ts.map +1 -0
  52. package/compiler/factory/nodeFactory.d.ts +4 -0
  53. package/compiler/factory/nodeFactory.d.ts.map +1 -0
  54. package/compiler/factory/parenthesizerRules.d.ts +2 -0
  55. package/compiler/factory/parenthesizerRules.d.ts.map +1 -0
  56. package/compiler/factory/utilities.d.ts +2 -0
  57. package/compiler/factory/utilities.d.ts.map +1 -0
  58. package/compiler/factory/utilitiesPublic.d.ts +4 -0
  59. package/compiler/factory/utilitiesPublic.d.ts.map +1 -0
  60. package/compiler/lpcFileHandler.d.ts +10 -0
  61. package/compiler/lpcFileHandler.d.ts.map +1 -0
  62. package/compiler/lpcJsHelpers.d.ts +17 -0
  63. package/compiler/lpcJsHelpers.d.ts.map +1 -0
  64. package/compiler/lpcbuild.d.ts +2 -0
  65. package/compiler/lpcbuild.d.ts.map +1 -0
  66. package/compiler/lpcbuildPublic.d.ts +26 -0
  67. package/compiler/lpcbuildPublic.d.ts.map +1 -0
  68. package/compiler/moduleNameResolver.d.ts +55 -0
  69. package/compiler/moduleNameResolver.d.ts.map +1 -0
  70. package/compiler/moduleSpecifiers.d.ts +2 -0
  71. package/compiler/moduleSpecifiers.d.ts.map +1 -0
  72. package/compiler/nodeTests.d.ts +115 -0
  73. package/compiler/nodeTests.d.ts.map +1 -0
  74. package/compiler/parser.d.ts +65 -0
  75. package/compiler/parser.d.ts.map +1 -0
  76. package/compiler/path.d.ts +2 -0
  77. package/compiler/path.d.ts.map +1 -0
  78. package/compiler/perfLoger.d.ts +2 -0
  79. package/compiler/perfLoger.d.ts.map +1 -0
  80. package/compiler/performance.d.ts +2 -0
  81. package/compiler/performance.d.ts.map +1 -0
  82. package/compiler/performanceCore.d.ts +2 -0
  83. package/compiler/performanceCore.d.ts.map +1 -0
  84. package/compiler/program.d.ts +72 -0
  85. package/compiler/program.d.ts.map +1 -0
  86. package/compiler/resolutionCache.d.ts +6 -0
  87. package/compiler/resolutionCache.d.ts.map +1 -0
  88. package/compiler/resolver.d.ts +1 -0
  89. package/compiler/resolver.d.ts.map +1 -0
  90. package/compiler/scanner.d.ts +85 -0
  91. package/compiler/scanner.d.ts.map +1 -0
  92. package/compiler/sourcemap.d.ts +2 -0
  93. package/compiler/sourcemap.d.ts.map +1 -0
  94. package/compiler/sys.d.ts +56 -0
  95. package/compiler/sys.d.ts.map +1 -0
  96. package/compiler/tracing.d.ts +31 -0
  97. package/compiler/tracing.d.ts.map +1 -0
  98. package/compiler/transformers/declarations.d.ts +2 -0
  99. package/compiler/transformers/declarations.d.ts.map +1 -0
  100. package/compiler/transformers.d.ts +2 -0
  101. package/compiler/transformers.d.ts.map +1 -0
  102. package/compiler/types.d.ts +3284 -0
  103. package/compiler/types.d.ts.map +1 -0
  104. package/compiler/utilities.d.ts +57 -0
  105. package/compiler/utilities.d.ts.map +1 -0
  106. package/compiler/utilitiesPublic.d.ts +213 -0
  107. package/compiler/utilitiesPublic.d.ts.map +1 -0
  108. package/compiler/visitorPublic.d.ts +72 -0
  109. package/compiler/visitorPublic.d.ts.map +1 -0
  110. package/compiler/watch.d.ts +2 -0
  111. package/compiler/watch.d.ts.map +1 -0
  112. package/compiler/watchPublic.d.ts +44 -0
  113. package/compiler/watchPublic.d.ts.map +1 -0
  114. package/compiler/watchUtilities.d.ts +14 -0
  115. package/compiler/watchUtilities.d.ts.map +1 -0
  116. package/config-types.d.ts +33 -0
  117. package/config-types.d.ts.map +1 -0
  118. package/harness/harnessIO.d.ts +4 -0
  119. package/harness/harnessIO.d.ts.map +1 -0
  120. package/lpc/_namespaces/lpc.d.ts +6 -0
  121. package/lpc/_namespaces/lpc.d.ts.map +1 -0
  122. package/lpc/_namespaces/lpc.server.d.ts +2 -0
  123. package/lpc/_namespaces/lpc.server.d.ts.map +1 -0
  124. package/lpc/lpc.d.ts +2 -0
  125. package/lpc/lpc.d.ts.map +1 -0
  126. package/lpcserver/document.d.ts +1 -0
  127. package/lpcserver/document.d.ts.map +1 -0
  128. package/lpcserver/nodeServer.d.ts +25 -0
  129. package/lpcserver/nodeServer.d.ts.map +1 -0
  130. package/lpcserver/protocol.const.d.ts +46 -0
  131. package/lpcserver/protocol.const.d.ts.map +1 -0
  132. package/lpcserver/server.d.ts +3 -0
  133. package/lpcserver/server.d.ts.map +1 -0
  134. package/lpcserver/textRendering.d.ts +14 -0
  135. package/lpcserver/textRendering.d.ts.map +1 -0
  136. package/lpcserver/typeConverters.d.ts +44 -0
  137. package/lpcserver/typeConverters.d.ts.map +1 -0
  138. package/lpcserver/utils.d.ts +14 -0
  139. package/lpcserver/utils.d.ts.map +1 -0
  140. package/package.json +48 -0
  141. package/parse-fluff-docs.d.ts +2 -0
  142. package/parse-fluff-docs.d.ts.map +1 -0
  143. package/parse-ld-docs.d.ts +2 -0
  144. package/parse-ld-docs.d.ts.map +1 -0
  145. package/server/_namespaces/lpc.d.ts +5 -0
  146. package/server/_namespaces/lpc.d.ts.map +1 -0
  147. package/server/_namespaces/lpc.server.d.ts +11 -0
  148. package/server/_namespaces/lpc.server.d.ts.map +1 -0
  149. package/server/_namespaces/lpc.server.protocol.d.ts +2 -0
  150. package/server/_namespaces/lpc.server.protocol.d.ts.map +1 -0
  151. package/server/editorServices.d.ts +261 -0
  152. package/server/editorServices.d.ts.map +1 -0
  153. package/server/project.d.ts +143 -0
  154. package/server/project.d.ts.map +1 -0
  155. package/server/protocol.d.ts +962 -0
  156. package/server/protocol.d.ts.map +1 -0
  157. package/server/scriptInfo.d.ts +53 -0
  158. package/server/scriptInfo.d.ts.map +1 -0
  159. package/server/scriptVersionCache.d.ts +2 -0
  160. package/server/scriptVersionCache.d.ts.map +1 -0
  161. package/server/session.d.ts +150 -0
  162. package/server/session.d.ts.map +1 -0
  163. package/server/types.d.ts +24 -0
  164. package/server/types.d.ts.map +1 -0
  165. package/server/utilities.d.ts +2 -0
  166. package/server/utilities.d.ts.map +1 -0
  167. package/server/utilitiesPublic.d.ts +37 -0
  168. package/server/utilitiesPublic.d.ts.map +1 -0
  169. package/server.d.ts +2 -0
  170. package/server.d.ts.map +1 -0
  171. package/services/_namespaces/lpc.Completions.StringCompletions.d.ts +2 -0
  172. package/services/_namespaces/lpc.Completions.StringCompletions.d.ts.map +1 -0
  173. package/services/_namespaces/lpc.Completions.d.ts +4 -0
  174. package/services/_namespaces/lpc.Completions.d.ts.map +1 -0
  175. package/services/_namespaces/lpc.FindAllReferences.d.ts +3 -0
  176. package/services/_namespaces/lpc.FindAllReferences.d.ts.map +1 -0
  177. package/services/_namespaces/lpc.GoToDefinition.d.ts +2 -0
  178. package/services/_namespaces/lpc.GoToDefinition.d.ts.map +1 -0
  179. package/services/_namespaces/lpc.JsDoc.d.ts +2 -0
  180. package/services/_namespaces/lpc.JsDoc.d.ts.map +1 -0
  181. package/services/_namespaces/lpc.NavigationBar.d.ts +2 -0
  182. package/services/_namespaces/lpc.NavigationBar.d.ts.map +1 -0
  183. package/services/_namespaces/lpc.Rename.d.ts +2 -0
  184. package/services/_namespaces/lpc.Rename.d.ts.map +1 -0
  185. package/services/_namespaces/lpc.SignatureHelp.d.ts +2 -0
  186. package/services/_namespaces/lpc.SignatureHelp.d.ts.map +1 -0
  187. package/services/_namespaces/lpc.SymbolDisplay.d.ts +2 -0
  188. package/services/_namespaces/lpc.SymbolDisplay.d.ts.map +1 -0
  189. package/services/_namespaces/lpc.codefix.d.ts +3 -0
  190. package/services/_namespaces/lpc.codefix.d.ts.map +1 -0
  191. package/services/_namespaces/lpc.d.ts +30 -0
  192. package/services/_namespaces/lpc.d.ts.map +1 -0
  193. package/services/_namespaces/lpc.formatting.d.ts +7 -0
  194. package/services/_namespaces/lpc.formatting.d.ts.map +1 -0
  195. package/services/_namespaces/lpc.textChanges.d.ts +2 -0
  196. package/services/_namespaces/lpc.textChanges.d.ts.map +1 -0
  197. package/services/classifier2020.d.ts +2 -0
  198. package/services/classifier2020.d.ts.map +1 -0
  199. package/services/codefixes/helpers.d.ts +2 -0
  200. package/services/codefixes/helpers.d.ts.map +1 -0
  201. package/services/codefixes/importFixes.d.ts +2 -0
  202. package/services/codefixes/importFixes.d.ts.map +1 -0
  203. package/services/completions.d.ts +2 -0
  204. package/services/completions.d.ts.map +1 -0
  205. package/services/documentRegistry.d.ts +90 -0
  206. package/services/documentRegistry.d.ts.map +1 -0
  207. package/services/exportInfoMap.d.ts +5 -0
  208. package/services/exportInfoMap.d.ts.map +1 -0
  209. package/services/findAllReferences.d.ts +2 -0
  210. package/services/findAllReferences.d.ts.map +1 -0
  211. package/services/formatting/formatting.d.ts +2 -0
  212. package/services/formatting/formatting.d.ts.map +1 -0
  213. package/services/formatting/formattingContext.d.ts +2 -0
  214. package/services/formatting/formattingContext.d.ts.map +1 -0
  215. package/services/formatting/rule.d.ts +2 -0
  216. package/services/formatting/rule.d.ts.map +1 -0
  217. package/services/formatting/rules.d.ts +2 -0
  218. package/services/formatting/rules.d.ts.map +1 -0
  219. package/services/formatting/rulesMap.d.ts +2 -0
  220. package/services/formatting/rulesMap.d.ts.map +1 -0
  221. package/services/formatting/smartIndenter.d.ts +2 -0
  222. package/services/formatting/smartIndenter.d.ts.map +1 -0
  223. package/services/goToDefinition.d.ts +2 -0
  224. package/services/goToDefinition.d.ts.map +1 -0
  225. package/services/importTracker.d.ts +2 -0
  226. package/services/importTracker.d.ts.map +1 -0
  227. package/services/jsDoc.d.ts +2 -0
  228. package/services/jsDoc.d.ts.map +1 -0
  229. package/services/navigationBar.d.ts +2 -0
  230. package/services/navigationBar.d.ts.map +1 -0
  231. package/services/rename.d.ts +2 -0
  232. package/services/rename.d.ts.map +1 -0
  233. package/services/services.d.ts +54 -0
  234. package/services/services.d.ts.map +1 -0
  235. package/services/signatureHelp.d.ts +2 -0
  236. package/services/signatureHelp.d.ts.map +1 -0
  237. package/services/sourcemaps.d.ts +2 -0
  238. package/services/sourcemaps.d.ts.map +1 -0
  239. package/services/stringCompletions.d.ts +2 -0
  240. package/services/stringCompletions.d.ts.map +1 -0
  241. package/services/suggestionDiagnostics.d.ts +2 -0
  242. package/services/suggestionDiagnostics.d.ts.map +1 -0
  243. package/services/symbolDisplay.d.ts +2 -0
  244. package/services/symbolDisplay.d.ts.map +1 -0
  245. package/services/textChanges.d.ts +2 -0
  246. package/services/textChanges.d.ts.map +1 -0
  247. package/services/types.d.ts +901 -0
  248. package/services/types.d.ts.map +1 -0
  249. package/services/utilities.d.ts +3 -0
  250. package/services/utilities.d.ts.map +1 -0
  251. package/src/cli.js +58 -0
  252. package/src/cli.js.map +7 -0
  253. package/src/efuns/fluffos/arrays.h +205 -0
  254. package/src/efuns/fluffos/async.h +84 -0
  255. package/src/efuns/fluffos/buffers.h +80 -0
  256. package/src/efuns/fluffos/calls.h +275 -0
  257. package/src/efuns/fluffos/contrib.h +805 -0
  258. package/src/efuns/fluffos/db.h +125 -0
  259. package/src/efuns/fluffos/driver.h +107 -0
  260. package/src/efuns/fluffos/ed.h +48 -0
  261. package/src/efuns/fluffos/efuns.fluffos.h +75 -0
  262. package/src/efuns/fluffos/external.h +30 -0
  263. package/src/efuns/fluffos/filesystem.h +154 -0
  264. package/src/efuns/fluffos/floats.h +136 -0
  265. package/src/efuns/fluffos/functions.h +104 -0
  266. package/src/efuns/fluffos/general.h +548 -0
  267. package/src/efuns/fluffos/interactive.h +777 -0
  268. package/src/efuns/fluffos/internals.h +455 -0
  269. package/src/efuns/fluffos/lpc-config.json +10 -0
  270. package/src/efuns/fluffos/mappings.h +205 -0
  271. package/src/efuns/fluffos/misc.h +43 -0
  272. package/src/efuns/fluffos/mudlib.h +228 -0
  273. package/src/efuns/fluffos/numbers.h +41 -0
  274. package/src/efuns/fluffos/objects.h +365 -0
  275. package/src/efuns/fluffos/parsing.h +220 -0
  276. package/src/efuns/fluffos/pcre.h +75 -0
  277. package/src/efuns/fluffos/sockets.h +276 -0
  278. package/src/efuns/fluffos/strings.h +542 -0
  279. package/src/efuns/fluffos/system.h +408 -0
  280. package/src/efuns/fluffos/zh-cn/arrays.zh-cn.h +167 -0
  281. package/src/efuns/fluffos/zh-cn/async.zh-cn.h +81 -0
  282. package/src/efuns/fluffos/zh-cn/buffers.zh-cn.h +69 -0
  283. package/src/efuns/fluffos/zh-cn/calls.zh-cn.h +242 -0
  284. package/src/efuns/fluffos/zh-cn/contrib.zh-cn.h +767 -0
  285. package/src/efuns/fluffos/zh-cn/db.zh-cn.h +113 -0
  286. package/src/efuns/fluffos/zh-cn/ed.zh-cn.h +42 -0
  287. package/src/efuns/fluffos/zh-cn/efuns.fluffos.h +76 -0
  288. package/src/efuns/fluffos/zh-cn/external.zh-cn.h +25 -0
  289. package/src/efuns/fluffos/zh-cn/filesystem.zh-cn.h +140 -0
  290. package/src/efuns/fluffos/zh-cn/floats.zh-cn.h +129 -0
  291. package/src/efuns/fluffos/zh-cn/functions.zh-cn.h +87 -0
  292. package/src/efuns/fluffos/zh-cn/general.zh-cn.h +506 -0
  293. package/src/efuns/fluffos/zh-cn/interactive.zh-cn.h +659 -0
  294. package/src/efuns/fluffos/zh-cn/internals.zh-cn.h +356 -0
  295. package/src/efuns/fluffos/zh-cn/mappings.zh-cn.h +188 -0
  296. package/src/efuns/fluffos/zh-cn/misc.zh-cn.h +43 -0
  297. package/src/efuns/fluffos/zh-cn/mudlib.zh-cn.h +190 -0
  298. package/src/efuns/fluffos/zh-cn/numbers.zh-cn.h +36 -0
  299. package/src/efuns/fluffos/zh-cn/objects.zh-cn.h +280 -0
  300. package/src/efuns/fluffos/zh-cn/parsing.zh-cn.h +212 -0
  301. package/src/efuns/fluffos/zh-cn/pcre.zh-cn.h +67 -0
  302. package/src/efuns/fluffos/zh-cn/sockets.zh-cn.h +230 -0
  303. package/src/efuns/fluffos/zh-cn/strings.zh-cn.h +484 -0
  304. package/src/efuns/fluffos/zh-cn/system.zh-cn.h +366 -0
  305. package/src/efuns/ldmud/defines.h +69 -0
  306. package/src/efuns/ldmud/efun.h +10449 -0
  307. package/src/efuns/ldmud/efuns.ldmud.h +87 -0
  308. package/src/efuns/ldmud/lpc-config.json +9 -0
  309. package/src/efuns/ldmud/obsolete.h +2168 -0
  310. package/src/lpc.js +82486 -0
  311. package/src/lpc.js.map +6 -0
  312. package/src/server.js +129 -0
  313. package/src/server.js.map +7 -0
  314. package/types.d.ts +23 -0
  315. package/types.d.ts.map +1 -0
  316. package/utils.d.ts +21 -0
  317. package/utils.d.ts.map +1 -0
@@ -0,0 +1,408 @@
1
+ // system.h
2
+
3
+ /**
4
+ * uptime() - return the number of seconds elapsed since the last driver
5
+ reboot
6
+ *
7
+ * This function returns the number of seconds since the last driver
8
+ * reboot.
9
+ *
10
+ */
11
+ int uptime( void );
12
+
13
+ /**
14
+ * trace_start - start collecting driver trace
15
+ *
16
+ * Calling this function will start collecting tracing information from the
17
+ * driver. This includes LPC function level execution information.
18
+ *
19
+ * The trace collection will stop and write the json data to `filename` on
20
+ * `trace_end()` or after `auto_stop_sec` seconds, which defaults to 30
21
+ * seconds.
22
+ *
23
+ * Note: do not leave tracing enabled for too long or you will risk running
24
+ * out of memory.
25
+ * @param filename the file to write the trace data to
26
+ * @param auto_stop_sec the number of seconds to collect trace data before stopping, defaults to 30 seconds
27
+ */
28
+ varargs void trace_start(string filename, int auto_stop_sec);
29
+
30
+ /**
31
+ * trace_end - stop collecting driver trace
32
+ *
33
+ * Calling this function will stop an active trace and write out the result
34
+ * to the file provided by `trace_start(filename)`.
35
+ *
36
+ * Note: do not leave tracing enabled for too long or you will risk running
37
+ * out of memory.
38
+ *
39
+ */
40
+ void trace_end();
41
+
42
+ /**
43
+ * time_ns() - return the number of nanoseconds since January 1, 1970
44
+ *
45
+ * Return the number of nanoseconds since midnight (GMT) January 1, 1970.
46
+ *
47
+ */
48
+ int time_ns( void );
49
+
50
+ /**
51
+ * time() - return the number of seconds since January 1, 1970
52
+ *
53
+ * Return the number of seconds since midnight (GMT) January 1, 1970.
54
+ *
55
+ */
56
+ int time( void );
57
+
58
+ /**
59
+ * sys_reload_tls() - Reload the TLS certificate and key for given port.
60
+ *
61
+ * Reload the TLS certificate and key for given port index, as specified in config file.
62
+ *
63
+ * For example, if you defined external_port_1_tls in the config then you can calling sys_reload_tls(1) to reload
64
+ * it. This allows you to update the certificate and key without restarting the server.
65
+ *
66
+ * Note:
67
+ * - you have to overwrite the previous cert/key file on disk before calling this function.
68
+ * - reloading TLS for websocket port is not currently supported.
69
+ *
70
+ */
71
+ void sys_reload_tls ( int port_index );
72
+
73
+ /**
74
+ * sys_network_ports() - display the active network ports
75
+ *
76
+ * Returns an array of arrays; one for each network port that is being actively
77
+ * used.
78
+ *
79
+ */
80
+ mixed *sys_network_ports(void);
81
+
82
+ /**
83
+ * strptime() - parse string as local time
84
+ *
85
+ * Parse given time 'str' with a format string, see:
86
+ * https://man7.org/linux/man-pages/man3/strptime.3.html
87
+ *
88
+ */
89
+ int strptime( string fmt, string str );
90
+
91
+ /**
92
+ * strftime() - format time as string
93
+ *
94
+ * Format given time with a format string, see:
95
+ * https://man7.org/linux/man-pages/man3/strftime.3.html
96
+ *
97
+ */
98
+ string strftime( string fmt, int time );
99
+
100
+ /**
101
+ * shutdown() - shutdown the driver
102
+ *
103
+ * This function shuts down the driver in a controlled fashion (as opposed
104
+ * to how a crash would shut it down). The 'how' argument specifes what
105
+ * integer value that driver should pass to exit(). The convention is to
106
+ * pass 'how' as -1 when the script that restarts the driver should die as
107
+ * well. Thus a reboot command would use shutdown() while a halt command
108
+ * would use shutdown(-1). The script must explicitly check the return
109
+ * value to see if it is -1 if you wish to use this convention. Obvi‐
110
+ * ously, shutdown() is a sensitive function and should be secured. As
111
+ * with exec(), the way to make it secure is to add a simul_efun of the
112
+ * same name which does the appropriate security checks. Be sure to set
113
+ * valid_override(4) up (in master.c) to protect against efun::shutdown().
114
+ *
115
+ */
116
+ varargs void shutdown( int how );
117
+
118
+ /**
119
+ * set_reset - modify the time until reset on an object
120
+ *
121
+ * Sets the time until reset on 'ob' to 'time' seconds from now. If
122
+ * 'time' is omitted, the driver's normal reset time setting formula is
123
+ * applied to 'ob', that is,
124
+ *
125
+ * reset time = current_time + reset_time / 2 + random(reset_time / 2)
126
+ *
127
+ */
128
+ varargs void set_reset( object ob, int time );
129
+
130
+ /**
131
+ * set_eval_limit() - set the maximum evaluation cost
132
+ *
133
+ * set_eval_limit(), with a nonzero argument, sets the maximum evaluation
134
+ * cost that is allowed for any one thread before a runtime error occurs.
135
+ * With a zero argument, it sets the current evaluation counter to zero,
136
+ * and the maximum cost is returned. set_eval_limit(-1) returns the
137
+ * remaining evaluation cost.
138
+ *
139
+ */
140
+ void set_eval_limit( int );
141
+
142
+ /**
143
+ * reset_eval_cost() - resets the evaluation cost remaining
144
+ *
145
+ * reset_eval_cost(), resets the evaluation cost remaining to the maximum
146
+ * evaluation cost.
147
+ *
148
+ * Returns the new eval cost.
149
+ *
150
+ */
151
+ int reset_eval_cost();
152
+
153
+ /**
154
+ * replace_program() - replaces the program in this_object()
155
+ *
156
+ * replace_program() replaces the program in this_object() with that of an
157
+ * object it inherits. The string argument is the filename of the object
158
+ * whose program is to be used. Once the replacement takes place, the
159
+ * current object effectively becomes a clone of that other object, but
160
+ * with its current filename and global variable values. The program is
161
+ * not actually replaced until the current execution is completed.
162
+ *
163
+ */
164
+ void replace_program( string str );
165
+
166
+ /**
167
+ * reclaim_objects - reclaim any lingering objets
168
+ *
169
+ * Cycles through all objects that are loaded, and frees any lingering
170
+ * objects that it can. This could result in a sizable amount of memory
171
+ * being freed up, depending on how the mud is coded. Objects are typi‐
172
+ * cally left lingering when a global variable in more than one object
173
+ * contains a pointer to it, and the object gets destructed. This efun
174
+ * returns the number of destructed objects encountered in variables.
175
+ *
176
+ */
177
+ int reclaim_objects( void );
178
+
179
+ /**
180
+ * perf_counter_ns() - gives epoch time measurement in nanoseconds
181
+ *
182
+ * Return the number of nanoseconds since midnight (GMT) January 1, 1970.
183
+ *
184
+ */
185
+ int perf_counter_ns( void );
186
+
187
+ /**
188
+ * max_eval_cost() - returns the maximum evaluation cost
189
+ *
190
+ * max_eval_cost() returns the number of instructions that can be executed
191
+ * before the driver decides it is in an infinite loop.
192
+ *
193
+ */
194
+ void max_eval_cost();
195
+
196
+ /**
197
+ * localtime() - convert to local time
198
+ *
199
+ * localtime() converts a time value (as returned by time()) into an array
200
+ * of values which represents the time locally. In the past time() was
201
+ * used to get the time in GMT (UTC), and then local definitions were used
202
+ * to determine the local offset from GMT. This roundabout approach is no
203
+ * longer necessary. localtime() returns the seconds, minutes and hours,
204
+ * the day, month and year, day of the week, day of the year, the name of
205
+ * the local timezone and how far the MUD is from GMT. This information
206
+ * is retrieved directly from the operating system and made available to
207
+ * the driver without the use of MUD-specific configuration files.
208
+ *
209
+ * localtime() returns an array containing the values specified above.
210
+ * The index for each value is defined symbolically in localtime.h. The
211
+ * following table summarizes the array returned by localtime().
212
+ *
213
+ * int LT_SEC Seconds after the minute (0..59)
214
+ * int LT_MIN Minutes after the hour (0..59)
215
+ * int LT_HOUR Hour since midnight (0..23)
216
+ * int LT_MDAY Day of the month (1..31)
217
+ * int LT_MON Months since January (0..11)
218
+ * int LT_YEAR Year (guarenteed to be >= 1900)
219
+ * int LT_WDAY Days since Sunday (0..6)
220
+ * int LT_YDAY Days since January 1 (0..365)
221
+ * int LT_GMTOFF Seconds after GMT (UTC)
222
+ * string LT_ZONE Timezone name
223
+ * int LT_ISDST If DST is currently being observed
224
+ *
225
+ */
226
+ mixed *localtime( int time );
227
+
228
+ /**
229
+ * inherits() - determine if an object inherits a given file
230
+ *
231
+ * inherits() returns 0 if obj does not inherit file, 1 if it inherits the
232
+ * most recent copy of file, and 2 if it inherits an old copy of file.
233
+ *
234
+ * If no object is passed as the second argument, this efun will default
235
+ * to this_object().
236
+ *
237
+ */
238
+ int inherits( string file, object obj );
239
+
240
+ /**
241
+ * inherit_list() - get a list of parents of an object
242
+ *
243
+ * Returns an array of filenames of objects inherited by obj. Only
244
+ * directly inherited files are returned. E.g. if A inherits B which
245
+ * inherits C, inherit_list(A) will return an array with B, but not C.
246
+ *
247
+ * If no object is supplied, this efun will default to this_object().
248
+ *
249
+ */
250
+ string *inherit_list( object obj );
251
+
252
+ /**
253
+ * function_profile() - get function profiling information for an object
254
+ *
255
+ * Returns function profiling information for 'ob', or this_object() if
256
+ * 'ob' is not specified. This is only available if the driver was com‐
257
+ * piled with PROFILE_FUNCTIONS defined.
258
+ *
259
+ */
260
+ mixed *function_profile( object ob );
261
+
262
+ /**
263
+ * function_exists() - find the file containing a given function in an
264
+ object
265
+ * @param str the name of the function to check for
266
+ * @param ob the object to check in
267
+ * @returns the file name of the object that defines the function 'str' in
268
+ * object 'ob'. The returned value can be other than 'file_name(ob)' if
269
+ * the function is defined by an inherited object.
270
+ *
271
+ * 0 is returned if the function was not defined.
272
+ *
273
+ * Note that function_exists() does not check shadows.
274
+ *
275
+ * If no object is passed as the second argument, this efun will default
276
+ * to this_object().
277
+ *
278
+ */
279
+ varargs string function_exists( string str, object ob );
280
+
281
+ /**
282
+ * flush_messages - send all pending messages to a user
283
+ *
284
+ * Normally, messages are queued, then sent all at once to minimize the
285
+ * number of packets required. This efun forces all pending messages to
286
+ * be written immediately. If no user is specified, messages for ALL users
287
+ * are flushed.
288
+ *
289
+ */
290
+ int flush_messages();
291
+ int flush_messages(object user);
292
+
293
+ /**
294
+ * find_call_out() - find a call out scheduled to be called
295
+ *
296
+ * Find a call out scheduled to be called either by function name or by
297
+ * handle.
298
+ *
299
+ * If the argument is a string, then the first call out due to be executed
300
+ * for function 'func' is found, and the time left in seconds is returned.
301
+ * If no call out is found, then return -1.
302
+ *
303
+ * If the argument is an integer, then the call out with handle 'handle'
304
+ * is found, and the time left in seconds is returned. If no call out is
305
+ * found, then return -1.
306
+ *
307
+ * This will find call outs scheduled by call_out() or call_out_walltime().
308
+ *
309
+ * If the time remaining is fractional, then the result will be an integer,
310
+ * the value of which will be floored.
311
+ *
312
+ * Example:
313
+ * int handle = call_out("func", 10);
314
+ * printf("Remaining time: %O\n", find_call_out(handle));
315
+ * // Remaining time: 10
316
+ *
317
+ * int handle = call_out("func", 10.75);
318
+ * printf("Remaining time: %O\n", find_call_out(handle));
319
+ * // Remaining time: 10
320
+ *
321
+ * This efun will only find call outs initiated by this_object().
322
+ *
323
+ */
324
+ int find_call_out( string func ) ;
325
+ int find_call_out( int handle ) ;
326
+
327
+ /**
328
+ * eval_cost() - returns the evaluation cost remaining
329
+ *
330
+ * eval_cost() returns the number of instructions that can be executed
331
+ * before the driver decides it is in an infinite loop.
332
+ *
333
+ */
334
+ int eval_cost();
335
+
336
+ /**
337
+ * errorp() - determine whether or not a given variable is an error code
338
+ *
339
+ * Returns 1 if 'arg' is an integer that is an error code.
340
+ *
341
+ * Eventually efuns will be modified to return standard error codes so
342
+ * that code like this will be possible:
343
+ *
344
+ * if (errorp(result = efun_call()))
345
+ * printf("error = %d\n", result);
346
+ *
347
+ * In future, there will also be a perror(result) efun to return error
348
+ * string that goes with a particular error integer.
349
+ *
350
+ */
351
+ int errorp( mixed arg );
352
+
353
+ /**
354
+ * error - generate a run-time error
355
+ *
356
+ * A run-time error 'err' will be generated when error() is called. Exe‐
357
+ * cution of the current thread will halt, and the trace will be recorded
358
+ * to the debug log. 'err' itself is allowed to have a length of maximal
359
+ * 2045 characters not counting an optional '\n' as last character.
360
+ * Before processing if the error the optional '\n' will be removed, a '*'
361
+ * will be prepended and an unconditional '\n' gets appended.
362
+ * @throws err
363
+ */
364
+ void error( string err );
365
+
366
+ /**
367
+ * deep_inherit_list() - get a list of ancestors of an object
368
+ *
369
+ * Returns an array of filenames of all objects inherited (directly and
370
+ * indirectly) by obj.
371
+ *
372
+ * If no object is supplied, this efun will default to this_object().
373
+ *
374
+ */
375
+ string *deep_inherit_list( object obj );
376
+
377
+ /**
378
+ * ctime() - return a time string
379
+ *
380
+ * Gives a nice string with current date and time, with the argument
381
+ * 'clock' that is the number of seconds since 1970.
382
+ *
383
+ * If no arguments are provided, it will use the current time.
384
+ *
385
+ */
386
+ string ctime(void| int clock );
387
+
388
+ /**
389
+ * call_out_info() - get pending call_out() information
390
+ *
391
+ * Get information about all pending call outs. An array is returned,
392
+ * where every item in the array consists 4 elements: the object, the
393
+ * function, the delay to go, and the optional argument.
394
+ *
395
+ */
396
+ mixed *call_out_info( void );
397
+
398
+ /**
399
+ * all_previous_objects() - returns an array of objects that called the
400
+ current function
401
+ *
402
+ * Returns an array of objects that called current function. Note that
403
+ * local function calls do not set previous_object() to the current
404
+ * object, but leave it unchanged.
405
+ *
406
+ */
407
+ object *all_previous_objects();
408
+
@@ -0,0 +1,167 @@
1
+ // arrays.h
2
+
3
+ #undef ALL_ARRAY_TYPES
4
+ #define ALL_ARRAY_TYPES string*|int*|float*|object*|mixed*|function*
5
+ #undef ALL_PRIMITIVE_TYPES
6
+ #define ALL_PRIMITIVE_TYPES string|int|float|object|mixed|function
7
+
8
+
9
+ /**
10
+ * unique_array() - 将对象数组分区为组
11
+ *
12
+ * 根据'separator'函数返回的相同值将对象组合在一起。'obarr'
13
+ * 应该是一个对象数组,其他类型将被忽略。'separator'函数只会在
14
+ * 'obarr'中的每个对象上调用一次。可选的'skip'参数允许对
15
+ * 'obarr'进行预过滤,跳过与'skip'匹配的元素。第二种形式则稍稍
16
+ * 不同,数组的每个元素将被传递给f,并根据f的返回值进行分区。
17
+ * 特别是,数组不需要由对象组成。
18
+ *
19
+ */
20
+ mixed unique_array( object *obarr, string separator, void | mixed skip);
21
+ mixed unique_array( mixed *arr, function f, void | mixed skip );
22
+
23
+ /**
24
+ * sort_array() - 对数组进行排序
25
+ *
26
+ * 第一种形式返回一个与'arr'具有相同元素的数组,但是
27
+ * 根据'ob->fun()'中的规则进行升序快速排序。
28
+ * 'ob->fun()' 将在每次调用中传递两个参数。它应该
29
+ * 返回 -1、0 或 1,具体取决于两个参数之间的关系
30
+ * (小于、等于、大于)。
31
+ *
32
+ * 第二种形式执行相同的操作,但允许使用函数指针。
33
+ *
34
+ * 第三种形式返回一个与'arr'具有相同元素的数组,但是
35
+ * 使用内置排序例程进行快速排序。'direction'为1或0时
36
+ * 将快速排序为升序,而'direction'为-1时将快速排序为
37
+ * 降序。内置排序例程的一个限制是,数组必须是同类的,
38
+ * 完全由单一类型组成,其中该类型可以是string、int或float。
39
+ * 数组中的数组通过基于第一个元素进行排序,从而使数据库
40
+ * 排序成为可能。
41
+ * @template {ALL_ARRAY_TYPES} T
42
+ * @param {T} arr 要排序的数组
43
+ * @returns {T} 排序后的数组
44
+ */
45
+ mixed *sort_array( mixed *arr, string fun, object ob );
46
+ mixed *sort_array( mixed *arr, function f );
47
+ mixed *sort_array( mixed *arr, int direction );
48
+
49
+ /**
50
+ * shuffle() - 将数组中的元素随机排列
51
+ *
52
+ * 随机打乱数组并返回。
53
+ * @template {ALL_ARRAY_TYPES} T
54
+ * @param {T} arr 要打乱的数组
55
+ * @returns {T} 打乱后的数组
56
+ */
57
+ mixed *shuffle(mixed *arr);
58
+
59
+ /**
60
+ * pointerp() - 确定给定变量是否为数组
61
+ * @param {mixed} arg 要检查的参数
62
+ * @returns {arg is mixed*} 如果'arg'是数组,则返回1,否则返回0。
63
+ * @example
64
+ * int is_array = pointerp( ({ 1, 2, 3, 4 }) ); // 1
65
+ * int is_array = pointerp( "Foo" ); // 0
66
+ *
67
+ */
68
+ int pointerp( mixed arg );
69
+
70
+ /**
71
+ * member_array() - 返回给定项在数组或字符串中出现的索引
72
+ *
73
+ * 返回'item'在数组'arr'中第一次出现的索引,或者
74
+ * 从'start'开始或之后的第一次出现。如果未找到
75
+ * 项,则返回 -1。
76
+ *
77
+ * 注意,如果第二个参数是一个字符串,第一个参数必须是一个
78
+ * int,表示您在提供的字符串中要查找的字符。
79
+ * @example
80
+ * ```c
81
+ * member_array( "red", ({ "red", "blue", "red", "green", "red", }) ) ;
82
+ * // 0
83
+ *
84
+ * member_array( "red", ({ "red", "blue", "red", "green", "red", }) , 1) ;
85
+ * // 2
86
+ *
87
+ * member_array( "blue", ({ "red", "blue", "red", "green", "red", }) , 3) ;
88
+ * // -1
89
+ *
90
+ * member_array( "purple", ({ "red", "blue", "red", "green", "red", }) ) ;
91
+ * // -1
92
+ *
93
+ * member_array('F', "Drink the FluffOS Kool-Aid!") ;
94
+ * // 10
95
+ *
96
+ * member_array('Z', "Drink the FluffOS Kool-Aid!") ;
97
+ * // -1
98
+ * ```
99
+ */
100
+ varargs int member_array( mixed item, mixed * | string arr, void | int start );
101
+
102
+ /**
103
+ * map_array() - 通过应用函数修改元素数组
104
+ *
105
+ * 返回一个数组,包含通过'ob->fun()'或'f'映射的'arr'项目。
106
+ * 对'arr'中的每个元素调用该函数,并将该元素作为参数传递。
107
+ * 如果提供了第二个参数'extra',则在每次调用中也会传递它。
108
+ * 主函数:
109
+ * ```c
110
+ * foreach (index) arr[index] = ob->fun(arr[index],extra);
111
+ * ```
112
+ * 'ob->fun(arr[.index.], extra)'返回的值替换数组中的现有元素。
113
+ * 如果'arr'不是一个数组,则返回0。
114
+ *
115
+ */
116
+ mixed *map_array( mixed *arr, string fun, object ob, mixed extra... );
117
+ mixed *map_array( mixed *arr, function f, mixed extra... );
118
+
119
+ /**
120
+ * filter_array() - 返回选择性的子数组
121
+ *
122
+ * filter_array() 返回一个数组,持有在数组<arr>中成功通过
123
+ * 在对象<ob>中找到的函数<fun>的项目。对于'arr'中的每个
124
+ * 元素,调用该函数作为参数。
125
+ * 第二个参数<extra>及后续参数将在每次调用时传递
126
+ * 如果给出。被认为已经成功通过<fun>(因此被包括在
127
+ * 返回数组中)的对象是如果<fun>返回1。如果传入f,
128
+ * 则将使用它替代ob->fun()。
129
+ * 如果<arr>不是一个数组,则返回0。
130
+ *
131
+ */
132
+ mixed *filter_array( mixed *arr, string fun, object|string ob, mixed extra... );
133
+ mixed *filter_array( mixed *arr, function f, mixed extra... );
134
+
135
+ /**
136
+ * element_of() - 从数组中随机返回一个元素
137
+ *
138
+ * 返回数组中的随机元素。
139
+ *
140
+ */
141
+ mixed element_of(mixed *arr);
142
+
143
+ /**
144
+ * arrayp() - 确定给定变量是否为数组
145
+ *
146
+ * 如果'arg'是数组,则返回1,否则返回0。
147
+ *
148
+ * @param {mixed} arg 要检查的参数
149
+ * @returns {arg is mixed*} 如果'arg'是数组,则返回1,否则返回0。
150
+ * @example
151
+ * int is_array = arrayp( ({ 1, 2, 3, 4 }) ); // 1
152
+ * int is_array = arrayp( "Foo" ); // 0
153
+ */
154
+ int arrayp( mixed arg );
155
+
156
+ /**
157
+ * allocate() - 分配数组
158
+ *
159
+ * 分配一个大小为<size>的数组。元素数量必须 >= 0,并且不大于系统最大值
160
+ * (通常为 ~10000)。所有元素默认初始化为 0。
161
+ *
162
+ * 如果提供了可选的第二个参数,则会将值初始化为该参数,除非
163
+ * 第二个参数是一个函数。在这种情况下,函数将在每个数组元素
164
+ * 上进行评估,第一个参数传递给函数为数组元素的编号。
165
+ *
166
+ */
167
+ varargs mixed *allocate( int size, void | mixed value );
@@ -0,0 +1,81 @@
1
+ // async.h
2
+
3
+ /**
4
+ * async_write() - 将字符串追加到文件中,然后执行回调
5
+ *
6
+ * 将字符串 'str' 追加到文件 'file' 中。如果标志为 1,write_file
7
+ * 将覆盖而不是追加。
8
+ *
9
+ * 与 write_file 不同,它返回 0 表示失败或 1 表示成功,此 efun
10
+ * 将返回 -1 表示失败,0 表示成功给回调函数。
11
+ *
12
+ * 回调函数应该遵循以下格式:
13
+ *
14
+ * function (int res) {
15
+ * // -1 表示失败
16
+ * // 0 表示成功
17
+ * }
18
+ *
19
+ */
20
+ void async_write( string file, string str, int flag, function callback );
21
+
22
+ /**
23
+ * async_read() - 将文件读入字符串中,然后执行回调
24
+ *
25
+ * 从文件中读取一行文本到字符串中。通常,read_file
26
+ * 需要第二个和第三个参数指定起始行和要读取的行数,但 async_read 将返回
27
+ * 整个文件内容给回调函数。
28
+ *
29
+ * 回调函数应该遵循以下格式:
30
+ *
31
+ * function(mixed res) {
32
+ * // -1 表示文件未读
33
+ * // 其他情况返回字符串的文件内容
34
+ * }
35
+ *
36
+ */
37
+ void async_read( string file, function callback );
38
+
39
+ /**
40
+ * async_getdir() - 返回与文件系统目录相关的信息
41
+ *
42
+ * 如果 'dir' 是文件名(支持 '*' 和 '?' 通配符),返回一个字符串数组
43
+ * 到回调函数,其中包含所有匹配的文件名。如果 'dir' 是目录名(以斜杠结尾--即:
44
+ * "/u/", "/adm/", 等),将返回该目录中的所有文件名。
45
+ *
46
+ * 与 get_dir 例程不同,此 efun 不需要一个整数第二个
47
+ * 参数来指定更多信息(文件名、文件大小、最后修改时间)。
48
+ *
49
+ * 回调函数应该遵循以下格式:
50
+ *
51
+ * function(mixed res) {
52
+ * // 0 表示目录不存在
53
+ * // 空数组表示没有匹配的文件存在
54
+ * // 匹配文件名的数组
55
+ * }
56
+ *
57
+ */
58
+ void async_getdir( string dir, function callback );
59
+
60
+ /**
61
+ * async_db_exec() - 执行 SQL 语句然后执行回调
62
+ *
63
+ * 此函数将针对给定的数据‐库句柄执行传递的 SQL 语句。
64
+ *
65
+ * 返回数据库句柄给提供的回调函数。
66
+ *
67
+ * 回调函数应该遵循以下格式:
68
+ *
69
+ * ```c
70
+ * async_db_exec(
71
+ * handle,
72
+ * sql_query,
73
+ * function (int rows) { // 匹配的行数
74
+ * mixed *results = db_fetch(handle, 1);
75
+ * db_close(handle);
76
+ * }
77
+ * );
78
+ * ```
79
+ *
80
+ */
81
+ void async_db_exec( int handle, string sql_query, function callback );