@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.
- package/README.md +255 -0
- package/bin/lpc +4 -0
- package/bin/lpcserver +4 -0
- package/cancellationToken/cancellationToken.d.ts +8 -0
- package/cancellationToken/cancellationToken.d.ts.map +1 -0
- package/cancellationToken/serverCancellationToken.d.ts +21 -0
- package/cancellationToken/serverCancellationToken.d.ts.map +1 -0
- package/cli/_namespaces/lpc.d.ts +2 -0
- package/cli/_namespaces/lpc.d.ts.map +1 -0
- package/cli/lpc.d.ts +2 -0
- package/cli/lpc.d.ts.map +1 -0
- package/compiler/LpcConfig.d.ts +17 -0
- package/compiler/LpcConfig.d.ts.map +1 -0
- package/compiler/_namespaces/lpc.d.ts +49 -0
- package/compiler/_namespaces/lpc.d.ts.map +1 -0
- package/compiler/_namespaces/lpc.moduleSpecifiers.d.ts +2 -0
- package/compiler/_namespaces/lpc.moduleSpecifiers.d.ts.map +1 -0
- package/compiler/_namespaces/lpc.performance.d.ts +2 -0
- package/compiler/_namespaces/lpc.performance.d.ts.map +1 -0
- package/compiler/binder.d.ts +2 -0
- package/compiler/binder.d.ts.map +1 -0
- package/compiler/builderPublic.d.ts +76 -0
- package/compiler/builderPublic.d.ts.map +1 -0
- package/compiler/checker.d.ts +2 -0
- package/compiler/checker.d.ts.map +1 -0
- package/compiler/commandLineParser.d.ts +47 -0
- package/compiler/commandLineParser.d.ts.map +1 -0
- package/compiler/core.d.ts +3 -0
- package/compiler/core.d.ts.map +1 -0
- package/compiler/corePublic.d.ts +19 -0
- package/compiler/corePublic.d.ts.map +1 -0
- package/compiler/debug.d.ts +71 -0
- package/compiler/debug.d.ts.map +1 -0
- package/compiler/diagnosticInformation.d.ts +518 -0
- package/compiler/diagnosticInformation.d.ts.map +1 -0
- package/compiler/emitter.d.ts +11 -0
- package/compiler/emitter.d.ts.map +1 -0
- package/compiler/executeCommandLine.d.ts +15 -0
- package/compiler/executeCommandLine.d.ts.map +1 -0
- package/compiler/expressionToTypeNode.d.ts +2 -0
- package/compiler/expressionToTypeNode.d.ts.map +1 -0
- package/compiler/factory/baseNodeFactory.d.ts +2 -0
- package/compiler/factory/baseNodeFactory.d.ts.map +1 -0
- package/compiler/factory/emitHelper.d.ts +2 -0
- package/compiler/factory/emitHelper.d.ts.map +1 -0
- package/compiler/factory/emitNode.d.ts +22 -0
- package/compiler/factory/emitNode.d.ts.map +1 -0
- package/compiler/factory/nodeChildren.d.ts +2 -0
- package/compiler/factory/nodeChildren.d.ts.map +1 -0
- package/compiler/factory/nodeConverters.d.ts +2 -0
- package/compiler/factory/nodeConverters.d.ts.map +1 -0
- package/compiler/factory/nodeFactory.d.ts +4 -0
- package/compiler/factory/nodeFactory.d.ts.map +1 -0
- package/compiler/factory/parenthesizerRules.d.ts +2 -0
- package/compiler/factory/parenthesizerRules.d.ts.map +1 -0
- package/compiler/factory/utilities.d.ts +2 -0
- package/compiler/factory/utilities.d.ts.map +1 -0
- package/compiler/factory/utilitiesPublic.d.ts +4 -0
- package/compiler/factory/utilitiesPublic.d.ts.map +1 -0
- package/compiler/lpcFileHandler.d.ts +10 -0
- package/compiler/lpcFileHandler.d.ts.map +1 -0
- package/compiler/lpcJsHelpers.d.ts +17 -0
- package/compiler/lpcJsHelpers.d.ts.map +1 -0
- package/compiler/lpcbuild.d.ts +2 -0
- package/compiler/lpcbuild.d.ts.map +1 -0
- package/compiler/lpcbuildPublic.d.ts +26 -0
- package/compiler/lpcbuildPublic.d.ts.map +1 -0
- package/compiler/moduleNameResolver.d.ts +55 -0
- package/compiler/moduleNameResolver.d.ts.map +1 -0
- package/compiler/moduleSpecifiers.d.ts +2 -0
- package/compiler/moduleSpecifiers.d.ts.map +1 -0
- package/compiler/nodeTests.d.ts +115 -0
- package/compiler/nodeTests.d.ts.map +1 -0
- package/compiler/parser.d.ts +65 -0
- package/compiler/parser.d.ts.map +1 -0
- package/compiler/path.d.ts +2 -0
- package/compiler/path.d.ts.map +1 -0
- package/compiler/perfLoger.d.ts +2 -0
- package/compiler/perfLoger.d.ts.map +1 -0
- package/compiler/performance.d.ts +2 -0
- package/compiler/performance.d.ts.map +1 -0
- package/compiler/performanceCore.d.ts +2 -0
- package/compiler/performanceCore.d.ts.map +1 -0
- package/compiler/program.d.ts +72 -0
- package/compiler/program.d.ts.map +1 -0
- package/compiler/resolutionCache.d.ts +6 -0
- package/compiler/resolutionCache.d.ts.map +1 -0
- package/compiler/resolver.d.ts +1 -0
- package/compiler/resolver.d.ts.map +1 -0
- package/compiler/scanner.d.ts +85 -0
- package/compiler/scanner.d.ts.map +1 -0
- package/compiler/sourcemap.d.ts +2 -0
- package/compiler/sourcemap.d.ts.map +1 -0
- package/compiler/sys.d.ts +56 -0
- package/compiler/sys.d.ts.map +1 -0
- package/compiler/tracing.d.ts +31 -0
- package/compiler/tracing.d.ts.map +1 -0
- package/compiler/transformers/declarations.d.ts +2 -0
- package/compiler/transformers/declarations.d.ts.map +1 -0
- package/compiler/transformers.d.ts +2 -0
- package/compiler/transformers.d.ts.map +1 -0
- package/compiler/types.d.ts +3284 -0
- package/compiler/types.d.ts.map +1 -0
- package/compiler/utilities.d.ts +57 -0
- package/compiler/utilities.d.ts.map +1 -0
- package/compiler/utilitiesPublic.d.ts +213 -0
- package/compiler/utilitiesPublic.d.ts.map +1 -0
- package/compiler/visitorPublic.d.ts +72 -0
- package/compiler/visitorPublic.d.ts.map +1 -0
- package/compiler/watch.d.ts +2 -0
- package/compiler/watch.d.ts.map +1 -0
- package/compiler/watchPublic.d.ts +44 -0
- package/compiler/watchPublic.d.ts.map +1 -0
- package/compiler/watchUtilities.d.ts +14 -0
- package/compiler/watchUtilities.d.ts.map +1 -0
- package/config-types.d.ts +33 -0
- package/config-types.d.ts.map +1 -0
- package/harness/harnessIO.d.ts +4 -0
- package/harness/harnessIO.d.ts.map +1 -0
- package/lpc/_namespaces/lpc.d.ts +6 -0
- package/lpc/_namespaces/lpc.d.ts.map +1 -0
- package/lpc/_namespaces/lpc.server.d.ts +2 -0
- package/lpc/_namespaces/lpc.server.d.ts.map +1 -0
- package/lpc/lpc.d.ts +2 -0
- package/lpc/lpc.d.ts.map +1 -0
- package/lpcserver/document.d.ts +1 -0
- package/lpcserver/document.d.ts.map +1 -0
- package/lpcserver/nodeServer.d.ts +25 -0
- package/lpcserver/nodeServer.d.ts.map +1 -0
- package/lpcserver/protocol.const.d.ts +46 -0
- package/lpcserver/protocol.const.d.ts.map +1 -0
- package/lpcserver/server.d.ts +3 -0
- package/lpcserver/server.d.ts.map +1 -0
- package/lpcserver/textRendering.d.ts +14 -0
- package/lpcserver/textRendering.d.ts.map +1 -0
- package/lpcserver/typeConverters.d.ts +44 -0
- package/lpcserver/typeConverters.d.ts.map +1 -0
- package/lpcserver/utils.d.ts +14 -0
- package/lpcserver/utils.d.ts.map +1 -0
- package/package.json +48 -0
- package/parse-fluff-docs.d.ts +2 -0
- package/parse-fluff-docs.d.ts.map +1 -0
- package/parse-ld-docs.d.ts +2 -0
- package/parse-ld-docs.d.ts.map +1 -0
- package/server/_namespaces/lpc.d.ts +5 -0
- package/server/_namespaces/lpc.d.ts.map +1 -0
- package/server/_namespaces/lpc.server.d.ts +11 -0
- package/server/_namespaces/lpc.server.d.ts.map +1 -0
- package/server/_namespaces/lpc.server.protocol.d.ts +2 -0
- package/server/_namespaces/lpc.server.protocol.d.ts.map +1 -0
- package/server/editorServices.d.ts +261 -0
- package/server/editorServices.d.ts.map +1 -0
- package/server/project.d.ts +143 -0
- package/server/project.d.ts.map +1 -0
- package/server/protocol.d.ts +962 -0
- package/server/protocol.d.ts.map +1 -0
- package/server/scriptInfo.d.ts +53 -0
- package/server/scriptInfo.d.ts.map +1 -0
- package/server/scriptVersionCache.d.ts +2 -0
- package/server/scriptVersionCache.d.ts.map +1 -0
- package/server/session.d.ts +150 -0
- package/server/session.d.ts.map +1 -0
- package/server/types.d.ts +24 -0
- package/server/types.d.ts.map +1 -0
- package/server/utilities.d.ts +2 -0
- package/server/utilities.d.ts.map +1 -0
- package/server/utilitiesPublic.d.ts +37 -0
- package/server/utilitiesPublic.d.ts.map +1 -0
- package/server.d.ts +2 -0
- package/server.d.ts.map +1 -0
- package/services/_namespaces/lpc.Completions.StringCompletions.d.ts +2 -0
- package/services/_namespaces/lpc.Completions.StringCompletions.d.ts.map +1 -0
- package/services/_namespaces/lpc.Completions.d.ts +4 -0
- package/services/_namespaces/lpc.Completions.d.ts.map +1 -0
- package/services/_namespaces/lpc.FindAllReferences.d.ts +3 -0
- package/services/_namespaces/lpc.FindAllReferences.d.ts.map +1 -0
- package/services/_namespaces/lpc.GoToDefinition.d.ts +2 -0
- package/services/_namespaces/lpc.GoToDefinition.d.ts.map +1 -0
- package/services/_namespaces/lpc.JsDoc.d.ts +2 -0
- package/services/_namespaces/lpc.JsDoc.d.ts.map +1 -0
- package/services/_namespaces/lpc.NavigationBar.d.ts +2 -0
- package/services/_namespaces/lpc.NavigationBar.d.ts.map +1 -0
- package/services/_namespaces/lpc.Rename.d.ts +2 -0
- package/services/_namespaces/lpc.Rename.d.ts.map +1 -0
- package/services/_namespaces/lpc.SignatureHelp.d.ts +2 -0
- package/services/_namespaces/lpc.SignatureHelp.d.ts.map +1 -0
- package/services/_namespaces/lpc.SymbolDisplay.d.ts +2 -0
- package/services/_namespaces/lpc.SymbolDisplay.d.ts.map +1 -0
- package/services/_namespaces/lpc.codefix.d.ts +3 -0
- package/services/_namespaces/lpc.codefix.d.ts.map +1 -0
- package/services/_namespaces/lpc.d.ts +30 -0
- package/services/_namespaces/lpc.d.ts.map +1 -0
- package/services/_namespaces/lpc.formatting.d.ts +7 -0
- package/services/_namespaces/lpc.formatting.d.ts.map +1 -0
- package/services/_namespaces/lpc.textChanges.d.ts +2 -0
- package/services/_namespaces/lpc.textChanges.d.ts.map +1 -0
- package/services/classifier2020.d.ts +2 -0
- package/services/classifier2020.d.ts.map +1 -0
- package/services/codefixes/helpers.d.ts +2 -0
- package/services/codefixes/helpers.d.ts.map +1 -0
- package/services/codefixes/importFixes.d.ts +2 -0
- package/services/codefixes/importFixes.d.ts.map +1 -0
- package/services/completions.d.ts +2 -0
- package/services/completions.d.ts.map +1 -0
- package/services/documentRegistry.d.ts +90 -0
- package/services/documentRegistry.d.ts.map +1 -0
- package/services/exportInfoMap.d.ts +5 -0
- package/services/exportInfoMap.d.ts.map +1 -0
- package/services/findAllReferences.d.ts +2 -0
- package/services/findAllReferences.d.ts.map +1 -0
- package/services/formatting/formatting.d.ts +2 -0
- package/services/formatting/formatting.d.ts.map +1 -0
- package/services/formatting/formattingContext.d.ts +2 -0
- package/services/formatting/formattingContext.d.ts.map +1 -0
- package/services/formatting/rule.d.ts +2 -0
- package/services/formatting/rule.d.ts.map +1 -0
- package/services/formatting/rules.d.ts +2 -0
- package/services/formatting/rules.d.ts.map +1 -0
- package/services/formatting/rulesMap.d.ts +2 -0
- package/services/formatting/rulesMap.d.ts.map +1 -0
- package/services/formatting/smartIndenter.d.ts +2 -0
- package/services/formatting/smartIndenter.d.ts.map +1 -0
- package/services/goToDefinition.d.ts +2 -0
- package/services/goToDefinition.d.ts.map +1 -0
- package/services/importTracker.d.ts +2 -0
- package/services/importTracker.d.ts.map +1 -0
- package/services/jsDoc.d.ts +2 -0
- package/services/jsDoc.d.ts.map +1 -0
- package/services/navigationBar.d.ts +2 -0
- package/services/navigationBar.d.ts.map +1 -0
- package/services/rename.d.ts +2 -0
- package/services/rename.d.ts.map +1 -0
- package/services/services.d.ts +54 -0
- package/services/services.d.ts.map +1 -0
- package/services/signatureHelp.d.ts +2 -0
- package/services/signatureHelp.d.ts.map +1 -0
- package/services/sourcemaps.d.ts +2 -0
- package/services/sourcemaps.d.ts.map +1 -0
- package/services/stringCompletions.d.ts +2 -0
- package/services/stringCompletions.d.ts.map +1 -0
- package/services/suggestionDiagnostics.d.ts +2 -0
- package/services/suggestionDiagnostics.d.ts.map +1 -0
- package/services/symbolDisplay.d.ts +2 -0
- package/services/symbolDisplay.d.ts.map +1 -0
- package/services/textChanges.d.ts +2 -0
- package/services/textChanges.d.ts.map +1 -0
- package/services/types.d.ts +901 -0
- package/services/types.d.ts.map +1 -0
- package/services/utilities.d.ts +3 -0
- package/services/utilities.d.ts.map +1 -0
- package/src/cli.js +58 -0
- package/src/cli.js.map +7 -0
- package/src/efuns/fluffos/arrays.h +205 -0
- package/src/efuns/fluffos/async.h +84 -0
- package/src/efuns/fluffos/buffers.h +80 -0
- package/src/efuns/fluffos/calls.h +275 -0
- package/src/efuns/fluffos/contrib.h +805 -0
- package/src/efuns/fluffos/db.h +125 -0
- package/src/efuns/fluffos/driver.h +107 -0
- package/src/efuns/fluffos/ed.h +48 -0
- package/src/efuns/fluffos/efuns.fluffos.h +75 -0
- package/src/efuns/fluffos/external.h +30 -0
- package/src/efuns/fluffos/filesystem.h +154 -0
- package/src/efuns/fluffos/floats.h +136 -0
- package/src/efuns/fluffos/functions.h +104 -0
- package/src/efuns/fluffos/general.h +548 -0
- package/src/efuns/fluffos/interactive.h +777 -0
- package/src/efuns/fluffos/internals.h +455 -0
- package/src/efuns/fluffos/lpc-config.json +10 -0
- package/src/efuns/fluffos/mappings.h +205 -0
- package/src/efuns/fluffos/misc.h +43 -0
- package/src/efuns/fluffos/mudlib.h +228 -0
- package/src/efuns/fluffos/numbers.h +41 -0
- package/src/efuns/fluffos/objects.h +365 -0
- package/src/efuns/fluffos/parsing.h +220 -0
- package/src/efuns/fluffos/pcre.h +75 -0
- package/src/efuns/fluffos/sockets.h +276 -0
- package/src/efuns/fluffos/strings.h +542 -0
- package/src/efuns/fluffos/system.h +408 -0
- package/src/efuns/fluffos/zh-cn/arrays.zh-cn.h +167 -0
- package/src/efuns/fluffos/zh-cn/async.zh-cn.h +81 -0
- package/src/efuns/fluffos/zh-cn/buffers.zh-cn.h +69 -0
- package/src/efuns/fluffos/zh-cn/calls.zh-cn.h +242 -0
- package/src/efuns/fluffos/zh-cn/contrib.zh-cn.h +767 -0
- package/src/efuns/fluffos/zh-cn/db.zh-cn.h +113 -0
- package/src/efuns/fluffos/zh-cn/ed.zh-cn.h +42 -0
- package/src/efuns/fluffos/zh-cn/efuns.fluffos.h +76 -0
- package/src/efuns/fluffos/zh-cn/external.zh-cn.h +25 -0
- package/src/efuns/fluffos/zh-cn/filesystem.zh-cn.h +140 -0
- package/src/efuns/fluffos/zh-cn/floats.zh-cn.h +129 -0
- package/src/efuns/fluffos/zh-cn/functions.zh-cn.h +87 -0
- package/src/efuns/fluffos/zh-cn/general.zh-cn.h +506 -0
- package/src/efuns/fluffos/zh-cn/interactive.zh-cn.h +659 -0
- package/src/efuns/fluffos/zh-cn/internals.zh-cn.h +356 -0
- package/src/efuns/fluffos/zh-cn/mappings.zh-cn.h +188 -0
- package/src/efuns/fluffos/zh-cn/misc.zh-cn.h +43 -0
- package/src/efuns/fluffos/zh-cn/mudlib.zh-cn.h +190 -0
- package/src/efuns/fluffos/zh-cn/numbers.zh-cn.h +36 -0
- package/src/efuns/fluffos/zh-cn/objects.zh-cn.h +280 -0
- package/src/efuns/fluffos/zh-cn/parsing.zh-cn.h +212 -0
- package/src/efuns/fluffos/zh-cn/pcre.zh-cn.h +67 -0
- package/src/efuns/fluffos/zh-cn/sockets.zh-cn.h +230 -0
- package/src/efuns/fluffos/zh-cn/strings.zh-cn.h +484 -0
- package/src/efuns/fluffos/zh-cn/system.zh-cn.h +366 -0
- package/src/efuns/ldmud/defines.h +69 -0
- package/src/efuns/ldmud/efun.h +10449 -0
- package/src/efuns/ldmud/efuns.ldmud.h +87 -0
- package/src/efuns/ldmud/lpc-config.json +9 -0
- package/src/efuns/ldmud/obsolete.h +2168 -0
- package/src/lpc.js +82486 -0
- package/src/lpc.js.map +6 -0
- package/src/server.js +129 -0
- package/src/server.js.map +7 -0
- package/types.d.ts +23 -0
- package/types.d.ts.map +1 -0
- package/utils.d.ts +21 -0
- package/utils.d.ts.map +1 -0
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
// strings.h
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* trim() - Remove leading and trailing whitespaces
|
|
5
|
+
*
|
|
6
|
+
* Remove all leading and trailing whitespace (or other characters 'ch')
|
|
7
|
+
* from the string 'str' and return a new string.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
string trim( string str );
|
|
11
|
+
string trim( string str, string ch);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* set_bit() - set a bit in a bitstring
|
|
15
|
+
*
|
|
16
|
+
* Return 0 or 1 of bit 'n' was set in string 'str'.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
int test_bit( string str, int n );
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* strwidth() - returns the display width of a string
|
|
23
|
+
*
|
|
24
|
+
* strwidth() returns the number of columns to display string 'str'.
|
|
25
|
+
*
|
|
26
|
+
* The driver uses rules defined in https://www.unicode.org/reports/tr11/tr11-36.html
|
|
27
|
+
* to calcuate character width.
|
|
28
|
+
*
|
|
29
|
+
* Control characters have no width. Wide characters, including emojis are two
|
|
30
|
+
* columns wide. This rule is also used by sprintf() to layout strings.
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
int strwidth( string str );
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Search for substrings in a string
|
|
37
|
+
*
|
|
38
|
+
* `strsrch()` searches for the first occurance of the string 'substr' in
|
|
39
|
+
* the string 'str'. The last occurance of 'substr' can be found by passing '-1' as the 3rd argument (which is optional).
|
|
40
|
+
* If the second argument
|
|
41
|
+
* is an integer, that character is found (a la C's strchr()/strrchr().)
|
|
42
|
+
* The empty string or null value cannot be searched for.
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
45
|
+
varargs int strsrch( string str, string substr, int flag );
|
|
46
|
+
varargs int strsrch( string str, int char, int flag );
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Return the number of UTF-8 characters in a supplied string
|
|
50
|
+
*
|
|
51
|
+
* strlen() returns the number of characters in the string 'str'.
|
|
52
|
+
*
|
|
53
|
+
* LPC strings are UTF-8 encoded. Driver calcuate numbers of characters
|
|
54
|
+
* according to the Unicode concept "Extended Grapheme Cluster", as defined in
|
|
55
|
+
* "https://www.unicode.org/reports/tr29/".
|
|
56
|
+
*
|
|
57
|
+
* ```lpc
|
|
58
|
+
* strlen("abc") == 3
|
|
59
|
+
* strlen("你好") == 2
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
int strlen( string str );
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* stringp() - determine whether or not a given variable is a string
|
|
66
|
+
*
|
|
67
|
+
* @returns {arg is string} 1 if 'arg' is a string.
|
|
68
|
+
*/
|
|
69
|
+
int stringp( mixed arg );
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
*
|
|
74
|
+
* Encode the given string str(in UTF-8) using given encoding, return an
|
|
75
|
+
* buffer of bytes.
|
|
76
|
+
*
|
|
77
|
+
*/
|
|
78
|
+
buffer string_encode(string str, string encoding);
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
*
|
|
82
|
+
*
|
|
83
|
+
* Decode the given buffer with given encoding into an UTF-8 string.
|
|
84
|
+
*
|
|
85
|
+
*/
|
|
86
|
+
string string_decode(buffer buf, string encoding);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* strcmp() - determines the lexical relationship between two strings.
|
|
90
|
+
*
|
|
91
|
+
* This implementation of strcmp() is identical to the one found in C
|
|
92
|
+
* libraries. If string one lexically precedes string two, then strcmp()
|
|
93
|
+
* returns a number less than 0. If the two strings have the same value,
|
|
94
|
+
* strcmp() returns 0. If string two lexically precedes string one, then
|
|
95
|
+
* strcmp() returns a number greater than 0. This efunction is particu‐
|
|
96
|
+
* larly useful in the compare functions needed by sort_array(3).
|
|
97
|
+
*
|
|
98
|
+
*/
|
|
99
|
+
int strcmp( string one, string two );
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* sscanf() - match substrings in a string.
|
|
103
|
+
*
|
|
104
|
+
* Parse a string 'input' using the string format 'fmt', which can contain
|
|
105
|
+
* words separated by specifiers. Every specifier corresponds to a match-
|
|
106
|
+
* ing function argument passed into sscanf() after the string 'fmt', in
|
|
107
|
+
* order of appearance and assigning the matched values By Reference. The
|
|
108
|
+
* number of specifiers included in 'fmt' should match the number of func-
|
|
109
|
+
* tion arguments included after string 'fmt'.
|
|
110
|
+
*
|
|
111
|
+
* Specifiers:
|
|
112
|
+
* %s - match a string
|
|
113
|
+
* %d - match an integer
|
|
114
|
+
* %f - match a float
|
|
115
|
+
* %x - match a base 16 number and convert to base 10
|
|
116
|
+
* %(regexp) - match a regexp pattern
|
|
117
|
+
*
|
|
118
|
+
* The "*" may be used in a specifier (e.g. "%*s") to skip over a match in
|
|
119
|
+
* the input string and not assign it to a function argument. A "%%" may
|
|
120
|
+
* be used to match the "%" character, which will also be skipped over in
|
|
121
|
+
* the function arguments.
|
|
122
|
+
*
|
|
123
|
+
* The LPC sscanf() is similar to its C counterpart however it does behave
|
|
124
|
+
* somewhat differently. It is not necessary or possible to pass the add-
|
|
125
|
+
* ress of variables into sscanf (simply pass the name of the variable).
|
|
126
|
+
*
|
|
127
|
+
* Another difference is that in the LPC sscanf(), sscanf(str, "%s %s",
|
|
128
|
+
* str1, str2) will parse the first word in str into str1 and the rem-
|
|
129
|
+
* ainder of str into str2.
|
|
130
|
+
*
|
|
131
|
+
* The "%s" specifier can match an empty string, which can be an undesired
|
|
132
|
+
* result. sscanf(" ", "%s %s", str1, str2) will return 2, with str1 and
|
|
133
|
+
* str2 being assigned an "" empty string.
|
|
134
|
+
*
|
|
135
|
+
* Basic Usage:
|
|
136
|
+
* ```lpc
|
|
137
|
+
* string what, who;
|
|
138
|
+
*
|
|
139
|
+
* if (sscanf(input, "give %s to %s", what, who) == 2)
|
|
140
|
+
* write("You give " + what + " to " + who + ".");
|
|
141
|
+
* else
|
|
142
|
+
* write("Give what to who?");
|
|
143
|
+
*
|
|
144
|
+
* sscanf("give", "give %s to %s", what, who) == 0
|
|
145
|
+
* what == UNDEFINED && who == UNDEFINED
|
|
146
|
+
*
|
|
147
|
+
* sscanf("give item", "give %s to %s", what, who) == 1
|
|
148
|
+
* what == "item" && who == UNDEFINED
|
|
149
|
+
*
|
|
150
|
+
* sscanf("give item to name", "give %s to %s", what, who) == 2
|
|
151
|
+
* what == "item" && who == "name"
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* Numeric:
|
|
155
|
+
* int i;
|
|
156
|
+
* sscanf("123", "%d", i) == 1
|
|
157
|
+
* i == 123
|
|
158
|
+
*
|
|
159
|
+
* float f;
|
|
160
|
+
* sscanf("1.23", "%f", f) == 1
|
|
161
|
+
* f == 1.230000
|
|
162
|
+
*
|
|
163
|
+
* int b10;
|
|
164
|
+
* sscanf("ABC", "%x", b10) == 1
|
|
165
|
+
* b10 == 2748
|
|
166
|
+
*
|
|
167
|
+
* Regexp:
|
|
168
|
+
* string str1, str2;
|
|
169
|
+
* sscanf("one two", "%([a-z]+) %([a-z]+)", str1, str2) == 2
|
|
170
|
+
* str1 == "one" && str2 == "two"
|
|
171
|
+
*
|
|
172
|
+
*/
|
|
173
|
+
int sscanf(string input, string fmt, mixed outvars... );
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* printf, sprintf - formatted output conversion
|
|
177
|
+
*
|
|
178
|
+
* An implementation of (s)printf() for LPC, with quite a few extensions
|
|
179
|
+
* Implemented by Lynscar (Sean A Reith).
|
|
180
|
+
*
|
|
181
|
+
* This version supports the following as modifiers:
|
|
182
|
+
*
|
|
183
|
+
* " " pad positive integers with a space.
|
|
184
|
+
*
|
|
185
|
+
* "+" pad positive integers with a plus sign.
|
|
186
|
+
*
|
|
187
|
+
* "-" left adjusted within field size.
|
|
188
|
+
* NB: std (s)printf() defaults to right justification, which is
|
|
189
|
+
* unnatural in the context of a mainly string based language but
|
|
190
|
+
* has been retained for "compatability".
|
|
191
|
+
*
|
|
192
|
+
* "|" centered within field size.
|
|
193
|
+
*
|
|
194
|
+
* "=" column mode if strings are greater than field size. This is
|
|
195
|
+
* only meaningful with strings, all other types ignore this. Col‐
|
|
196
|
+
* umns are auto-magically word wrapped.
|
|
197
|
+
*
|
|
198
|
+
* "#" table mode, print a list of '\n' separated 'words' in a table
|
|
199
|
+
* within the field size. only meaningful with strings.
|
|
200
|
+
*
|
|
201
|
+
* n specifies the field size, a '*' specifies to use the corre‐
|
|
202
|
+
* sponding arg as the field size. If n is prepended with a zero,
|
|
203
|
+
* then is padded zeros, else it is padded with spaces (or speci‐
|
|
204
|
+
* fied pad string).
|
|
205
|
+
*
|
|
206
|
+
* "."n precision of n, simple strings truncate after this (if preci‐
|
|
207
|
+
* sion is greater than field size, then field size = precision),
|
|
208
|
+
* tables use precision to specify the number of columns (if pre‐
|
|
209
|
+
* cision not specified then tables calculate a best fit), all
|
|
210
|
+
* other types ignore this.
|
|
211
|
+
*
|
|
212
|
+
* ":"n n specifies the fs _and_ the precision, if n is prepended by a
|
|
213
|
+
* zero then it is padded with zeros instead of spaces.
|
|
214
|
+
*
|
|
215
|
+
* "@" the argument is an array. the corresponding format_info (minus
|
|
216
|
+
* the "@") is applyed to each element of the array.
|
|
217
|
+
*
|
|
218
|
+
* "'X'" The char(s) between the single-quotes are used to pad to field
|
|
219
|
+
* size (defaults to space) (if both a zero (in front of field
|
|
220
|
+
* size) and a pad string are specified, the one specified second
|
|
221
|
+
* overrules). NOTE: to include "'" in the pad string, you must
|
|
222
|
+
* use "\'" (as the backslash has to be escaped past the inter‐
|
|
223
|
+
* preter), similarly, to include "\" requires "\\".
|
|
224
|
+
*
|
|
225
|
+
* The following are the possible type specifiers.
|
|
226
|
+
*
|
|
227
|
+
* % in which case no arguments are interpreted, and a "%" is
|
|
228
|
+
* inserted, and all modifiers are ignored.
|
|
229
|
+
*
|
|
230
|
+
* O the argument is an LPC datatype.
|
|
231
|
+
*
|
|
232
|
+
* s the argument is a string.
|
|
233
|
+
*
|
|
234
|
+
* d, i the integer arg is printed in decimal.
|
|
235
|
+
*
|
|
236
|
+
* c the integer arg is to be printed as a character.
|
|
237
|
+
*
|
|
238
|
+
* o the integer arg is printed in octal.
|
|
239
|
+
*
|
|
240
|
+
* x the integer arg is printed in hex.
|
|
241
|
+
*
|
|
242
|
+
* X the integer arg is printed in hex (with A-F in capitals).
|
|
243
|
+
*
|
|
244
|
+
* f floating point number
|
|
245
|
+
*
|
|
246
|
+
* Basic Usage:
|
|
247
|
+
* ```lpc
|
|
248
|
+
* sprintf("%s is %i", "X", 1) = "X is 1"
|
|
249
|
+
* ```
|
|
250
|
+
*
|
|
251
|
+
* Alignment:
|
|
252
|
+
* ```lpc
|
|
253
|
+
* sprintf("%-20s", "left") = "left "
|
|
254
|
+
* sprintf("%20|s", "center") = " center "
|
|
255
|
+
* sprintf("%20s", "right") = " right"
|
|
256
|
+
* sprintf("%-20'-'s", "left") = "left----------------"
|
|
257
|
+
* sprintf("%20'-'|s", "center") = "-------center-------"
|
|
258
|
+
* sprintf("%20'-'s", "right") = "---------------right"
|
|
259
|
+
* ```
|
|
260
|
+
*
|
|
261
|
+
* Numeric:
|
|
262
|
+
* sprintf("%.2f", 1.2345) = "1.23"
|
|
263
|
+
* sprintf("%10.2f", 1.2345) = " 1.23"
|
|
264
|
+
* sprintf("%10.6f", 0.123) = " 0.123000"
|
|
265
|
+
*
|
|
266
|
+
* Dynamic Field Size:
|
|
267
|
+
* sprintf("%-*s", 10, "ten") = "ten "
|
|
268
|
+
* sprintf("%|*s", 20, "twenty") = " twenty "
|
|
269
|
+
* sprintf("%*s", 30, "thirty") = " thirty"
|
|
270
|
+
*
|
|
271
|
+
*/
|
|
272
|
+
varargs void printf(string format, mixed args...);
|
|
273
|
+
varargs string sprintf(string format, mixed args...);
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* sha1() - hash a string using SHA-1
|
|
277
|
+
*
|
|
278
|
+
* Returns the SHA-1 hash of string `str` or buffer `bf` using SHA-1.
|
|
279
|
+
*
|
|
280
|
+
* This requires PACKAGE_CRYPTO to be enabled when compiling the driver.
|
|
281
|
+
*
|
|
282
|
+
* Note:
|
|
283
|
+
* The `hash(algo, str)` external function can handle SHA-1 and more.
|
|
284
|
+
*
|
|
285
|
+
* sha1("something") = "1af17e73721dbe0c40011b82ed4bb1a7dbe3ce29"
|
|
286
|
+
*
|
|
287
|
+
*/
|
|
288
|
+
string sha1(buffer|string str);
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* set_bit() - set a bit in a bitstring
|
|
292
|
+
*
|
|
293
|
+
* Return the new string where bit 'n' is set in string 'str'. Note that
|
|
294
|
+
* the old string 'str' is not modified.
|
|
295
|
+
*
|
|
296
|
+
* The max value of 'n' is limited. Ask the administrator if you want to
|
|
297
|
+
* now the maximum value.
|
|
298
|
+
*
|
|
299
|
+
* The new string will automatically be extended if needed.
|
|
300
|
+
*
|
|
301
|
+
* Bits are packed 6 per byte in printable strings.
|
|
302
|
+
*
|
|
303
|
+
*/
|
|
304
|
+
string set_bit( string str, int n );
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* rtrim() - Remove trailing whitespaces (and others)
|
|
308
|
+
*
|
|
309
|
+
* Remove all trailing whitespace (or other characters 'ch') from the
|
|
310
|
+
* string 'str' and return a new string.
|
|
311
|
+
*
|
|
312
|
+
*/
|
|
313
|
+
string rtrim( string str );
|
|
314
|
+
string rtrim( string str, string ch);
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* replace_string() - replace all instances of a string within a string
|
|
318
|
+
*
|
|
319
|
+
* replace_string() returns str with all instances of pattern replaced
|
|
320
|
+
* with replace. If pattern has zero length then str is returned unmodi‐
|
|
321
|
+
* fied. If the resultant string would exceed the maximum string length
|
|
322
|
+
* then replace_string() returns an undefinedp(), non-stringp() value.
|
|
323
|
+
*
|
|
324
|
+
* replace_string() can be used to remove characters from a string by
|
|
325
|
+
* specifying a pattern and a zero-length replace parameter. For example,
|
|
326
|
+
* replace_string(" 1 2 3 ", " ", "") would return "123".
|
|
327
|
+
* replace_string() executes faster this way then explode()/implode().
|
|
328
|
+
*
|
|
329
|
+
* The 4th and 5th arguments are optional (to retain backward compatibil‐
|
|
330
|
+
* ity.) The extra arguments have the following effect:
|
|
331
|
+
*
|
|
332
|
+
* 4 args
|
|
333
|
+
* The 4th argument specifies the maximum number of replacements to
|
|
334
|
+
* make (the count starts at 1). A value of 0 implies 'replace all',
|
|
335
|
+
* and thus, acts as replace_string() with 3 arguments would. E.g.,
|
|
336
|
+
* replace_string("xyxx", "x", "z", 2) would return "zyzx".
|
|
337
|
+
*
|
|
338
|
+
* 5 args
|
|
339
|
+
* The 4th and 5th arguments specify the range of matches to replace
|
|
340
|
+
* between, with the following constraints:
|
|
341
|
+
* - first < 1 : change all from the start.
|
|
342
|
+
* - last == 0, or last > max_matches : change all to end
|
|
343
|
+
* - first > last : return the unmodified array.
|
|
344
|
+
* E.g., replace_string("xyxxy", "x", "z", 2, 3) returns "xyzzy".
|
|
345
|
+
*
|
|
346
|
+
*/
|
|
347
|
+
string replace_string( str, pattern, replace );
|
|
348
|
+
string replace_string( str, pattern, replace, max );
|
|
349
|
+
string replace_string( str, pattern, replace, first, last );
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* regexp() - regular expression handler
|
|
353
|
+
*
|
|
354
|
+
* Typically when presented with an array of lines of text and a regular
|
|
355
|
+
* expression, regexp(3) returns an array containing those lines which
|
|
356
|
+
* match the pattern specified by the regular expression. If the flag
|
|
357
|
+
* (default 0) has bit 2 set, then non-matches will be returned instead of
|
|
358
|
+
* matches. If the flag has bit 1 set, the array returned will be of the
|
|
359
|
+
* form ({ index1 + 1, match1, ..., indexn + 1, matchn }) where index1 is
|
|
360
|
+
* the index of 1st match/non match in the array lines.
|
|
361
|
+
*
|
|
362
|
+
*/
|
|
363
|
+
int regexp(string str, string pattern, void | int flag);
|
|
364
|
+
string *regexp(string *lines, string pattern, void | int flag);
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* reg_assoc() - A regular pattern substring extractor
|
|
368
|
+
*
|
|
369
|
+
* reg_assoc takes a string and explodes it into substrings matching the
|
|
370
|
+
* regular expression pattern-strings given in pat_arr and associates them
|
|
371
|
+
* with tokens given in tok_arr. If def (default 0) is given, it is asso‐
|
|
372
|
+
* ciated with a non-match. The return value is an array of two arrays,
|
|
373
|
+
* the 1st being an array of the form
|
|
374
|
+
*
|
|
375
|
+
* ({ non-match1, match1, non-match2, match2, ...,
|
|
376
|
+
* non-match n, match n, non-match n+1 })
|
|
377
|
+
*
|
|
378
|
+
* and the 2nd holds the tokens corresponding to the matches in order
|
|
379
|
+
*
|
|
380
|
+
* ({ def, token corresponding to match1, ...., def, token
|
|
381
|
+
* corresponding to match n, def }).
|
|
382
|
+
*
|
|
383
|
+
* pat_arr and tok_arr must be of the same sizes, the ith element in
|
|
384
|
+
* tok_arr being the corresponding token to the ith element of pat_arr.
|
|
385
|
+
* pat_arr can only hold strings.
|
|
386
|
+
*
|
|
387
|
+
* If pat_arr (and hence tok_arr) has size 0 then the return value is sim‐
|
|
388
|
+
* ply ({ ({ str }), ({ def }) }).
|
|
389
|
+
*
|
|
390
|
+
* #define STRING_PAT "\"(\\\\.|[^\\\"])*\""
|
|
391
|
+
* #define NUM_PAT "[0-9]+"
|
|
392
|
+
*
|
|
393
|
+
* #define F_STRING 1
|
|
394
|
+
* #define F_NUM 2
|
|
395
|
+
*
|
|
396
|
+
* reg_assoc("Blah \"blah\" test 203 hhh j 308 \"bacdcd\b\"acb",
|
|
397
|
+
* ({ STRING_PAT, NUM_PAT }), ({ F_STRING, F_NUM }), "no-match")
|
|
398
|
+
*
|
|
399
|
+
* will return
|
|
400
|
+
* ({ ({ "Blah ", "\"blah\"", " test ", "203", " hhh j ", "308", " ",
|
|
401
|
+
* "\"bacdcd\b\"", "acb" }),
|
|
402
|
+
* ({ "no-match", F_STRING, "no-match", F_NUM, "no-match", F_NUM,
|
|
403
|
+
* "no-match", F_STRING, "no-match" }) })
|
|
404
|
+
*
|
|
405
|
+
*/
|
|
406
|
+
mixed *reg_assoc(string str, string *pat_arr, mixed *tok_arr, void | mixed def);
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* oldcrypt() - encrypt a string
|
|
410
|
+
*
|
|
411
|
+
* Encrypt the string `str` using the first two characters from string
|
|
412
|
+
* `seed`. If `seed` is zero, then a random seed will be used.
|
|
413
|
+
*
|
|
414
|
+
* The encrypted result can be used as the `seed` of a second encrypt,
|
|
415
|
+
* which will return the original encrypted result if both `str` inputs
|
|
416
|
+
* were identical.
|
|
417
|
+
*
|
|
418
|
+
* Example of verifying a password using oldcrypt():
|
|
419
|
+
*
|
|
420
|
+
* // turn user input into crypted password
|
|
421
|
+
* string cryptPasswd = oldcrypt(input, 0);
|
|
422
|
+
*
|
|
423
|
+
* // store crypted password in user save somewhere
|
|
424
|
+
*
|
|
425
|
+
* // compare login input to stored crypted password
|
|
426
|
+
* if (oldcrypt(input, cryptPasswd) == cryptPasswd) {
|
|
427
|
+
* // valid password
|
|
428
|
+
* } else {
|
|
429
|
+
* // invalid password attempt
|
|
430
|
+
* }
|
|
431
|
+
*
|
|
432
|
+
*/
|
|
433
|
+
string oldcrypt( string str, string seed );
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* ltrim() - Remove leading whitespaces (and others)
|
|
437
|
+
*
|
|
438
|
+
* Remove all leading whitespace (or other characters 'ch') from the
|
|
439
|
+
* string 'str' and return a new string.
|
|
440
|
+
*
|
|
441
|
+
*/
|
|
442
|
+
string ltrim( string str );
|
|
443
|
+
string ltrim( string str, string ch);
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* lower_case() - return the lowercase version of a given string
|
|
447
|
+
*
|
|
448
|
+
* Return the lowercase version of a given string (original string remains
|
|
449
|
+
* unchanged).
|
|
450
|
+
*
|
|
451
|
+
*/
|
|
452
|
+
string lower_case( string str );
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* implode() - concatenate strings
|
|
456
|
+
*
|
|
457
|
+
* Concatenate all strings found in array 'arr', with the string 'del'
|
|
458
|
+
* between each element. Only strings are used from the array. elements
|
|
459
|
+
* that are not strings are ignored.
|
|
460
|
+
*
|
|
461
|
+
*/
|
|
462
|
+
string implode( mixed *arr, string del );
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* hash() - hash a string with the specified algorithm
|
|
466
|
+
*
|
|
467
|
+
* Returns the hash of string `str` by the `algo` algorithm.
|
|
468
|
+
*
|
|
469
|
+
* Aglorithm `algo` can be one of:
|
|
470
|
+
* md4 md5 sha1 sha224 sha256 sha384 sha512 ripemd160
|
|
471
|
+
*
|
|
472
|
+
* This requires PACKAGE_CRYPTO to be enabled when compiling the driver.
|
|
473
|
+
*
|
|
474
|
+
* hash("md4", "Something") = "abc554cae9acd8f168101954383335df"
|
|
475
|
+
* hash("md5", "Something") = "73f9977556584a369800e775b48f3dbe"
|
|
476
|
+
* hash("ripemd160", "Something") = ...40 characters...
|
|
477
|
+
* hash("sha1", "Something") = ...40 characters...
|
|
478
|
+
* hash("sha224", "Something") = ...56 characters...
|
|
479
|
+
* hash("sha256", "Something") = ...64 characters...
|
|
480
|
+
* hash("sha384", "Something") = ...96 characters...
|
|
481
|
+
* hash("sha512", "Something") = ...128 characters...
|
|
482
|
+
*
|
|
483
|
+
*/
|
|
484
|
+
string hash( string algo, string str );
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* explode() - break up a string
|
|
488
|
+
*
|
|
489
|
+
* explode() returns an array of strings, created when the string <str> is
|
|
490
|
+
* split into pieces as divided by the delimiter <del>.
|
|
491
|
+
*
|
|
492
|
+
* explode(str," ") will return as an array all of the words (separated by
|
|
493
|
+
* spaces) in the string <str>.
|
|
494
|
+
*
|
|
495
|
+
*/
|
|
496
|
+
string *explode( string str, string del );
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* crypt() - encrypt a string
|
|
500
|
+
*
|
|
501
|
+
* Encrypt the string `str` using string `seed`. If `seed` is zero, then
|
|
502
|
+
* a random seed will be used.
|
|
503
|
+
*
|
|
504
|
+
* The encrypted result can be used as the `seed` of a second encrypt,
|
|
505
|
+
* which will return the original encrypted result if both `str` inputs
|
|
506
|
+
* were identical.
|
|
507
|
+
*
|
|
508
|
+
* Example of verifying a password using crypt():
|
|
509
|
+
*
|
|
510
|
+
* // turn user input into crypted password
|
|
511
|
+
* string cryptPasswd = crypt(input, 0);
|
|
512
|
+
*
|
|
513
|
+
* // store crypted password in user save somewhere
|
|
514
|
+
*
|
|
515
|
+
* // compare login input to stored crypted password
|
|
516
|
+
* if (crypt(input, cryptPasswd) == cryptPasswd) {
|
|
517
|
+
* // valid password
|
|
518
|
+
* } else {
|
|
519
|
+
* // invalid password attempt
|
|
520
|
+
* }
|
|
521
|
+
*
|
|
522
|
+
*/
|
|
523
|
+
string crypt( string str, string seed );
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* clear_bit() - zero a bit in a bit string
|
|
527
|
+
*
|
|
528
|
+
* Return the new string where bit <n> is cleared in string <str>. Note
|
|
529
|
+
* that the old string <str> is not modified.
|
|
530
|
+
*
|
|
531
|
+
*/
|
|
532
|
+
string clear_bit( string str, int n );
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* capitalize() - capitalize a string
|
|
536
|
+
*
|
|
537
|
+
* Convert the first character in <str> to upper case, and return the new
|
|
538
|
+
* string.
|
|
539
|
+
*
|
|
540
|
+
*/
|
|
541
|
+
string capitalize( string str );
|
|
542
|
+
|