@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,484 @@
1
+ // strings.h
2
+
3
+ /**
4
+ * trim() - 移除前导和尾随空格
5
+ *
6
+ * 从字符串 'str' 中移除所有前导和尾随空白(或其他字符 'ch'),并返回一个新字符串。
7
+ *
8
+ */
9
+ string trim( string str );
10
+ string trim( string str, string ch);
11
+
12
+ /**
13
+ * set_bit() - 在位字符串中设置一位
14
+ *
15
+ * 返回0或1,表示字符串 'str' 中的位 'n' 是否被设置。
16
+ *
17
+ */
18
+ int test_bit( string str, int n );
19
+
20
+ /**
21
+ * strwidth() - 返回字符串的显示宽度
22
+ *
23
+ * strwidth() 返回显示字符串 'str' 所需的列数。
24
+ *
25
+ * 驱动程序使用 https://www.unicode.org/reports/tr11/tr11-36.html 中定义的规则来计算字符宽度。
26
+ *
27
+ * 控制字符没有宽度。宽字符,包括表情符号占两个列宽。这个规则也被 sprintf() 用于布局字符串。
28
+ *
29
+ */
30
+ int strwidth( string str );
31
+
32
+ /**
33
+ * 在字符串中搜索子字符串
34
+ *
35
+ * `strsrch()` 在字符串 'str' 中搜索字符串 'substr' 的第一个出现。
36
+ * 最后一次出现 'substr' 可以通过将 '-1' 作为第三个参数(可选)来找到。
37
+ * 如果第二个参数是一个整数,则该字符被找到(类似于 C 的 strchr()/strrchr())。
38
+ * 不能搜索空字符串或空值。
39
+ *
40
+ */
41
+ varargs int strsrch( string str, string substr, int flag );
42
+ varargs int strsrch( string str, int char, int flag );
43
+
44
+ /**
45
+ * 返回提供字符串中的 UTF-8 字符数
46
+ *
47
+ * strlen() 返回字符串 'str' 中的字符数。
48
+ *
49
+ * LPC 字符串是 UTF-8 编码的。驱动程序根据 Unicode 概念 "Extended Grapheme Cluster" 计算字符数,按
50
+ * "https://www.unicode.org/reports/tr29/" 中定义的方式。
51
+ *
52
+ * ```lpc
53
+ * strlen("abc") == 3
54
+ * strlen("你好") == 2
55
+ * ```
56
+ */
57
+ int strlen( string str );
58
+
59
+ /**
60
+ * stringp() - 判断给定变量是否为字符串
61
+ *
62
+ * @returns {arg is string} 如果 'arg' 是字符串则返回1。
63
+ */
64
+ int stringp( mixed arg );
65
+
66
+ /**
67
+ *
68
+ *
69
+ * 使用给定编码对给定字符串 str(以 UTF-8 编码)进行编码,返回一个字节缓冲区。
70
+ *
71
+ */
72
+ buffer string_encode(string str, string encoding);
73
+
74
+ /**
75
+ *
76
+ *
77
+ * 使用给定编码解码给定缓冲区为 UTF-8 字符串。
78
+ *
79
+ */
80
+ string string_decode(buffer buf, string encoding);
81
+
82
+ /**
83
+ * strcmp() - 确定两个字符串之间的词法关系。
84
+ *
85
+ * 此 strcmp() 的实现与 C 库中的实现相同。
86
+ * 如果字符串一在词法上优先于字符串二,则 strcmp() 返回小于0的数字。
87
+ * 如果两个字符串的值相同,则 strcmp() 返回0。
88
+ * 如果字符串二在词法上优先于字符串一,则 strcmp() 返回大于0的数字。
89
+ * 这个函数在 sort_array(3) 中的比较函数中特别有用。
90
+ *
91
+ */
92
+ int strcmp( string one, string two );
93
+
94
+ /**
95
+ * sscanf() - 匹配字符串中的子字符串。
96
+ *
97
+ * 使用字符串格式 'fmt' 解析字符串 'input',格式可以包含用特定符号分隔的单词。
98
+ * 每个符号对应于在 sscanf() 中传入函数参数的匹配值,按出现的顺序并通过引用分配匹配的值。
99
+ * 'fmt' 中包含的符号数量应与字符串 'fmt' 后面的函数参数数量匹配。
100
+ *
101
+ * 符号:
102
+ * %s - 匹配一个字符串
103
+ * %d - 匹配一个整数
104
+ * %f - 匹配一个浮点数
105
+ * %x - 匹配一个基数为16的数字并转换为基数为10
106
+ * %(regexp) - 匹配一个正则表达式模式
107
+ *
108
+ * 在符号中可以使用 "*"(例如 "%*s")来跳过输入字符串中的匹配项,而不将其赋值给函数参数。
109
+ * "%%" 用于匹配 "%" 字符,该字符也将在函数参数中被跳过。
110
+ *
111
+ * LPC 的 sscanf() 类似于其 C 对应物,但在某些方面有些不同。无需或无法将变量的地址传入 sscanf(只需传入变量的名称)。
112
+ *
113
+ * 另一个不同之处在于,在 LPC 的 sscanf() 中,sscanf(str, "%s %s", str1, str2) 将把 str 中的第一个单词解析到 str1,剩余的内容解析到 str2。
114
+ *
115
+ * "%s" 符号可以匹配空字符串,这可能是一个不希望出现的结果。sscanf(" ", "%s %s", str1, str2) 将返回2,str1 和 str2 被赋值为空字符串 ""。
116
+ *
117
+ * 基本用法:
118
+ * ```lpc
119
+ * string what, who;
120
+ *
121
+ * if (sscanf(input, "give %s to %s", what, who) == 2)
122
+ * write("You give " + what + " to " + who + ".");
123
+ * else
124
+ * write("Give what to who?");
125
+ *
126
+ * sscanf("give", "give %s to %s", what, who) == 0
127
+ * what == UNDEFINED && who == UNDEFINED
128
+ *
129
+ * sscanf("give item", "give %s to %s", what, who) == 1
130
+ * what == "item" && who == UNDEFINED
131
+ *
132
+ * sscanf("give item to name", "give %s to %s", what, who) == 2
133
+ * what == "item" && who == "name"
134
+ * ```
135
+ *
136
+ * 数字:
137
+ * int i;
138
+ * sscanf("123", "%d", i) == 1
139
+ * i == 123
140
+ *
141
+ * float f;
142
+ * sscanf("1.23", "%f", f) == 1
143
+ * f == 1.230000
144
+ *
145
+ * int b10;
146
+ * sscanf("ABC", "%x", b10) == 1
147
+ * b10 == 2748
148
+ *
149
+ * 正则表达式:
150
+ * string str1, str2;
151
+ * sscanf("one two", "%([a-z]+) %([a-z]+)", str1, str2) == 2
152
+ * str1 == "one" && str2 == "two"
153
+ *
154
+ */
155
+ int sscanf(string input, string fmt, mixed outvars... );
156
+
157
+ /**
158
+ * printf, sprintf - 格式化输出转换
159
+ *
160
+ * LPC 的 (s)printf() 的实现,包含许多扩展
161
+ * 由 Lynscar(Sean A Reith)实现。
162
+ *
163
+ * 这个版本支持以下修饰符:
164
+ *
165
+ * " " 用空格填充正整数。
166
+ *
167
+ * "+" 用加号填充正整数。
168
+ *
169
+ * "-" 在字段大小内左对齐。
170
+ * 注意:标准 (s)printf() 默认为右对齐,这在主要以字符串为基础的语言中是不自然的,但为了"兼容性"保留了这一点。
171
+ *
172
+ * "|" 在字段大小内居中。
173
+ *
174
+ * "=" 如果字符串大于字段大小,则为列模式。仅对字符串有意义。所有其他类型将忽略此设置。列将自动换行。
175
+ *
176
+ * "#" 表格模式,在字段大小内以 '\n' 分隔的 'words' 列出。
177
+ * 仅对字符串有意义。
178
+ *
179
+ * n 指定字段大小, '*' 指定使用相应的参数作为字段大小。如果 n 之前带有零,则用零填充,否则用空格(或指定的填充字符串)填充。
180
+ *
181
+ * "."n 精度 n,简单字符串在此处截断(如果精度大于字段大小,则字段大小 = 精度),表格使用精度来确定列数(如果未指定精度,则表格将计算最佳匹配),所有其他类型将忽略此设置。
182
+ *
183
+ * ":"n n 同时指定字段大小和精度,n 前面如果带有零,则用零填充,而不是空格。
184
+ *
185
+ * "@" 参数为数组。每个数组元素都应用相应的格式信息(去掉 "@")。
186
+ *
187
+ * "'X'" 单引号之间的字符用于填充字段大小(默认为空格)。如果同时指定零(在字段大小前)和填充字符串,则第二个指定的会覆盖第一个。注意:要在填充字符串中包含 "'",必须使用 "\'"(因为反斜杠在解释器中必须被转义),同样,要包含 "\" 需使用 "\\"。
188
+ *
189
+ * 以下是可能的类型符号。
190
+ *
191
+ * % 在这种情况下不解释任何参数,并插入 "%" 字符,所有修饰符将被忽略。
192
+ *
193
+ * O 参数是 LPC 数据类型。
194
+ *
195
+ * s 参数是字符串。
196
+ *
197
+ * d, i 整数参数以十进制形式打印。
198
+ *
199
+ * c 整数参数以字符形式打印。
200
+ *
201
+ * o 整数参数以八进制形式打印。
202
+ *
203
+ * x 整数参数以十六进制形式打印。
204
+ *
205
+ * X 整数参数以十六进制形式打印(大写A-F)。
206
+ *
207
+ * f 浮点数
208
+ *
209
+ * 基本用法:
210
+ * ```lpc
211
+ * sprintf("%s is %i", "X", 1) = "X is 1"
212
+ * ```
213
+ *
214
+ * 对齐:
215
+ * ```lpc
216
+ * sprintf("%-20s", "left") = "left "
217
+ * sprintf("%20|s", "center") = " center "
218
+ * sprintf("%20s", "right") = " right"
219
+ * sprintf("%-20'-'s", "left") = "left----------------"
220
+ * sprintf("%20'-'|s", "center") = "-------center-------"
221
+ * sprintf("%20'-'s", "right") = "---------------right"
222
+ * ```
223
+ *
224
+ * 数字:
225
+ * sprintf("%.2f", 1.2345) = "1.23"
226
+ * sprintf("%10.2f", 1.2345) = " 1.23"
227
+ * sprintf("%10.6f", 0.123) = " 0.123000"
228
+ *
229
+ * 动态字段大小:
230
+ * sprintf("%-*s", 10, "ten") = "ten "
231
+ * sprintf("%|*s", 20, "twenty") = " twenty "
232
+ * sprintf("%*s", 30, "thirty") = " thirty"
233
+ *
234
+ */
235
+ varargs void printf(string format, mixed args...);
236
+ varargs string sprintf(string format, mixed args...);
237
+ /**
238
+ * sha1() - 使用SHA-1对字符串进行哈希
239
+ *
240
+ * 返回字符串 `str` 或缓冲区 `bf` 的SHA-1哈希值。
241
+ *
242
+ * 这在编译驱动程序时需要启用PACKAGE_CRYPTO。
243
+ *
244
+ * 注意:
245
+ * 外部函数 `hash(algo, str)` 可以处理SHA-1及更多。
246
+ *
247
+ * sha1("something") = "1af17e73721dbe0c40011b82ed4bb1a7dbe3ce29"
248
+ *
249
+ */
250
+ string sha1(buffer|string str);
251
+
252
+ /**
253
+ * set_bit() - 在位字符串中设置某个比特
254
+ *
255
+ * 返回新字符串,其中字符串 'str' 中的比特 'n' 被设置。注意,
256
+ * 旧字符串 'str' 不会被修改。
257
+ *
258
+ * 'n' 的最大值是有限制的。如果您想知道最大值,请询问管理员。
259
+ *
260
+ * 新字符串将在需要时自动扩展。
261
+ *
262
+ * 在可打印字符串中,每字节打包6个比特。
263
+ *
264
+ */
265
+ string set_bit( string str, int n );
266
+
267
+ /**
268
+ * rtrim() - 移除尾部空白(和其他字符)
269
+ *
270
+ * 从字符串 'str' 中移除所有尾部空白(或其他字符 'ch'),并返回新字符串。
271
+ *
272
+ */
273
+ string rtrim( string str );
274
+ string rtrim( string str, string ch);
275
+
276
+ /**
277
+ * replace_string() - 替换字符串中的所有实例
278
+ *
279
+ * replace_string() 返回字符串 str,其中所有实例的模式被替换为 replace。
280
+ * 如果模式的长度为零,则返回未修改的 str。如果结果字符串超出最大字符串长度,
281
+ * 则 replace_string() 返回一个未定义的、非字符串的值。
282
+ *
283
+ * replace_string() 可以通过指定模式和一个零长度的替换参数来移除字符串中的
284
+ * 字符。例如,replace_string(" 1 2 3 ", " ", "") 将返回 "123"。
285
+ * replace_string() 这样执行比 explode()/implode() 快。
286
+ *
287
+ * 第4个和第5个参数是可选的(为了保持向后兼容性)。额外的参数具有以下效果:
288
+ *
289
+ * 4个参数
290
+ * 第4个参数指定要进行的最大替换次数(计数从1开始)。值为0表示“替换所有”,
291
+ * 因此,它的作用与只有3个参数的replace_string()相同。例如,
292
+ * replace_string("xyxx", "x", "z", 2) 将返回 "zyzx"。
293
+ *
294
+ * 5个参数
295
+ * 第4个和第5个参数指定要替换的匹配范围,具有以下约束:
296
+ * - first < 1 : 从开始改变所有内容。
297
+ * - last == 0,或 last > max_matches : 改变到结尾的所有内容。
298
+ * - first > last : 返回未修改的数组。
299
+ * 例如,replace_string("xyxxy", "x", "z", 2, 3) 返回 "xyzzy"。
300
+ *
301
+ */
302
+ string replace_string( str, pattern, replace );
303
+ string replace_string( str, pattern, replace, max );
304
+ string replace_string( str, pattern, replace, first, last );
305
+
306
+ /**
307
+ * regexp() - 正则表达式处理器
308
+ *
309
+ * 通常,当提供一组文本行和一个正则表达式时,regexp(3) 返回一个数组,
310
+ * 包含与正则表达式指定的模式匹配的那些行。如果标志(默认值为0)设置了位2,
311
+ * 则将返回非匹配项而不是匹配项。如果标志设置了位1,则返回的数组将是
312
+ * 形式为 ({ index1 + 1, match1, ..., indexn + 1, matchn }),其中 index1 是
313
+ * 数组行中第1个匹配/非匹配的索引。
314
+ *
315
+ */
316
+ int regexp(string str, string pattern, void | int flag);
317
+ string *regexp(string *lines, string pattern, void | int flag);
318
+
319
+ /**
320
+ * reg_assoc() - 正则模式子字符串提取器
321
+ *
322
+ * reg_assoc 接收一个字符串并将其按给定的正则表达式模式字符串 pat_arr 分解成
323
+ * 子字符串,并将它们与在 tok_arr 中给出的标记关联起来。如果给定 def(默认值为0),
324
+ * 它将与非匹配关联。返回值是一个包含两个数组的数组,第一个是形式为
325
+ *
326
+ * ({ non-match1, match1, non-match2, match2, ...,
327
+ * non-match n, match n, non-match n+1 })
328
+ *
329
+ * 的数组,第二个则包含按顺序对应于匹配项的标记
330
+ *
331
+ * ({ def, 与 match1 相对应的标记, ...., def,
332
+ * 与 match n 相对应的标记, def })。
333
+ *
334
+ * pat_arr 和 tok_arr 必须具有相同的大小,tok_arr 中的第 i 个元素是 pat_arr 中
335
+ * 第 i 个元素的对应标记。pat_arr 只能包含字符串。
336
+ *
337
+ * 如果 pat_arr(以及 tok_arr)的大小为0,则返回值为简单的
338
+ * ({ ({ str }), ({ def }) })。
339
+ *
340
+ * #define STRING_PAT "\"(\\\\.|[^\\\"])*\""
341
+ * #define NUM_PAT "[0-9]+"
342
+ *
343
+ * #define F_STRING 1
344
+ * #define F_NUM 2
345
+ *
346
+ * reg_assoc("Blah \"blah\" test 203 hhh j 308 \"bacdcd\b\"acb",
347
+ * ({ STRING_PAT, NUM_PAT }), ({ F_STRING, F_NUM }), "no-match")
348
+ *
349
+ * 将返回
350
+ * ({ ({ "Blah ", "\"blah\"", " test ", "203", " hhh j ", "308", " ",
351
+ * "\"bacdcd\b\"", "acb" }),
352
+ * ({ "no-match", F_STRING, "no-match", F_NUM, "no-match", F_NUM,
353
+ * "no-match", F_STRING, "no-match" }) })
354
+ *
355
+ */
356
+ mixed *reg_assoc(string str, string *pat_arr, mixed *tok_arr, void | mixed def);
357
+
358
+ /**
359
+ * oldcrypt() - 加密字符串
360
+ *
361
+ * 使用字符串 `seed` 的前两个字符加密字符串 `str`。如果 `seed` 为零,
362
+ * 将使用随机种子。
363
+ *
364
+ * 加密结果可以用作第二次加密的 `seed`,如果两个 `str` 输入相同,
365
+ * 则将返回原始的加密结果。
366
+ *
367
+ * 使用 oldcrypt() 验证密码的示例:
368
+ *
369
+ * // 将用户输入转换为加密密码
370
+ * string cryptPasswd = oldcrypt(input, 0);
371
+ *
372
+ * // 在用户保存的某处存储加密密码
373
+ *
374
+ * // 将登录输入与存储的加密密码进行比较
375
+ * if (oldcrypt(input, cryptPasswd) == cryptPasswd) {
376
+ * // 有效密码
377
+ * } else {
378
+ * // 无效密码尝试
379
+ * }
380
+ *
381
+ */
382
+ string oldcrypt( string str, string seed );
383
+
384
+ /**
385
+ * ltrim() - 移除前导空白(和其他字符)
386
+ *
387
+ * 从字符串 'str' 中移除所有前导空白(或其他字符 'ch'),并返回新字符串。
388
+ *
389
+ */
390
+ string ltrim( string str );
391
+ string ltrim( string str, string ch);
392
+
393
+ /**
394
+ * lower_case() - 返回给定字符串的小写版本
395
+ *
396
+ * 返回给定字符串的小写版本(原始字符串保持不变)。
397
+ *
398
+ */
399
+ string lower_case( string str );
400
+
401
+ /**
402
+ * implode() - 连接字符串
403
+ *
404
+ * 将数组 'arr' 中找到的所有字符串连接起来,在每个元素之间用字符串 'del'。
405
+ * 仅使用数组中的字符串。非字符串的元素被忽略。
406
+ *
407
+ */
408
+ string implode( mixed *arr, string del );
409
+
410
+ /**
411
+ * hash() - 使用指定算法对字符串进行哈希
412
+ *
413
+ * 返回字符串 `str` 的 `algo` 算法的哈希。
414
+ *
415
+ * 算法 `algo` 可以是以下之一:
416
+ * md4 md5 sha1 sha224 sha256 sha384 sha512 ripemd160
417
+ *
418
+ * 这在编译驱动程序时需要启用PACKAGE_CRYPTO。
419
+ *
420
+ * hash("md4", "Something") = "abc554cae9acd8f168101954383335df"
421
+ * hash("md5", "Something") = "73f9977556584a369800e775b48f3dbe"
422
+ * hash("ripemd160", "Something") = ...40个字符...
423
+ * hash("sha1", "Something") = ...40个字符...
424
+ * hash("sha224", "Something") = ...56个字符...
425
+ * hash("sha256", "Something") = ...64个字符...
426
+ * hash("sha384", "Something") = ...96个字符...
427
+ * hash("sha512", "Something") = ...128个字符...
428
+ *
429
+ */
430
+ string hash( string algo, string str );
431
+
432
+ /**
433
+ * explode() - 拆分字符串
434
+ *
435
+ * explode() 返回一个字符串数组,创建于字符串 <str> 根据分隔符 <del> 被分割成多个部分时。
436
+ *
437
+ * explode(str," ") 将返回一个数组,包含字符串 <str> 中所有的词(以空格分隔)。
438
+ *
439
+ */
440
+ string *explode( string str, string del );
441
+
442
+ /**
443
+ * crypt() - 加密字符串
444
+ *
445
+ * 使用字符串 `seed` 加密字符串 `str`。如果 `seed` 为零,
446
+ * 则将使用随机种子。
447
+ *
448
+ * 加密结果可以作为第二次加密的 `seed`,如果两个 `str` 输入相同,
449
+ * 则将返回原始的加密结果。
450
+ *
451
+ * 使用 crypt() 验证密码的示例:
452
+ *
453
+ * // 将用户输入转换为加密密码
454
+ * string cryptPasswd = crypt(input, 0);
455
+ *
456
+ * // 在用户保存的某处存储加密密码
457
+ *
458
+ * // 将登录输入与存储的加密密码进行比较
459
+ * if (crypt(input, cryptPasswd) == cryptPasswd) {
460
+ * // 有效密码
461
+ * } else {
462
+ * // 无效密码尝试
463
+ * }
464
+ *
465
+ */
466
+ string crypt( string str, string seed );
467
+
468
+ /**
469
+ * clear_bit() - 清除位字符串中的某个比特
470
+ *
471
+ * 返回新字符串,其中字符串 <str> 中的比特 <n> 被清除。注意,
472
+ * 旧字符串 <str> 不会被修改。
473
+ *
474
+ */
475
+ string clear_bit( string str, int n );
476
+
477
+ /**
478
+ * capitalize() - 将字符串首字母大写
479
+ *
480
+ * 将 <str> 中的第一个字符转换为大写,并返回新字符串。
481
+ *
482
+ */
483
+ string capitalize( string str );
484
+