blob: 2e023ba819563613b9432ae674ae7dd677628ec3 [file] [log] [blame]
Zesstra9ef23d02020-09-03 19:48:47 +02001OPTIONAL
2SYNOPSIS
3 string process_string(string str)
4
Zesstra715ec202025-07-09 22:18:31 +02005DESCRIPTION
6 Searches string str for occurrences of a "value by function
7 call", which is an implicit function call surrounded by @@. See
8 "value_by_function_call" in the principles section.
Zesstra9ef23d02020-09-03 19:48:47 +02009
Zesstra715ec202025-07-09 22:18:31 +020010 The value should contain a string like this:
Zesstra9ef23d02020-09-03 19:48:47 +020011 @@function[:filename][|arg|arg]@@
12
Zesstra715ec202025-07-09 22:18:31 +020013 <function> must return a string or else the string which should be
14 processed will be returned unchanged.
Zesstra9ef23d02020-09-03 19:48:47 +020015
Zesstra715ec202025-07-09 22:18:31 +020016 process_string() does not recurse over returned
17 replacement values. If a function returns another function
18 description, that description will not be replaced.
Zesstra9ef23d02020-09-03 19:48:47 +020019
Zesstra715ec202025-07-09 22:18:31 +020020 Both the filename and the args are optional.
Zesstra9ef23d02020-09-03 19:48:47 +020021
Zesstra715ec202025-07-09 22:18:31 +020022 Consecutive function calls can be written adjacent:
23
24 @@function1@@function2@@
25
26EXAMPLES
Zesstra9ef23d02020-09-03 19:48:47 +020027 string foo(string str) {
Zesstra715ec202025-07-09 22:18:31 +020028 return "ab"+str+"ef";
Zesstra9ef23d02020-09-03 19:48:47 +020029 }
Zesstra9ef23d02020-09-03 19:48:47 +020030 void func() {
Zesstra715ec202025-07-09 22:18:31 +020031 write(process_string("@@foo|cd@@")+"\n");
Zesstra9ef23d02020-09-03 19:48:47 +020032 }
33
Zesstra715ec202025-07-09 22:18:31 +020034 The function func() will print out the string "abcdef".
Zesstra9ef23d02020-09-03 19:48:47 +020035
Zesstra715ec202025-07-09 22:18:31 +020036BUGS
37 Using process_string() can lead to severe security problems.
Zesstra9ef23d02020-09-03 19:48:47 +020038
Zesstra715ec202025-07-09 22:18:31 +020039HISTORY
40 Because of the security problems, process_string() is an
41 optional efun since 3.2.1@34
42 LDMud 3.3.160 removed the undocumented 'feature' that a function call
43 declaration could be terminated by a space. In turn this now allows
44 the use of arguments with spaces.
Zesstra9ef23d02020-09-03 19:48:47 +020045
Zesstra715ec202025-07-09 22:18:31 +020046SEE ALSO
Zesstra9ef23d02020-09-03 19:48:47 +020047 notify_fail(E), closures(LPC), get_bb_uid(M)