blob: 19b8f81f88b3cba533246e125dd616929d5c99e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/** @addtogroup library
* The library tapset is a collection of standard functions.
* @{
*/
/** @addtogroup library
* @code function strlen:long(s:string) @endcode
* @param s string
* @return Returns the length of the string.
*/
function strlen:long(s:string) %{ /* pure */
THIS->__retvalue=strlen(THIS->s);
%}
/** @addtogroup library
* @code function substr:string(str:string,start:long,stop:long) @endcode
* @param str string
* @return Returns the length of the string.
*/
function substr:string(str:string,start:long,stop:long) %{ /* pure */
int len=strlen(THIS->str);
if(THIS->start<0 || THIS->stop<0 ||
THIS->start>len || THIS->stop>len ||
THIS->start>=THIS->stop)
{
return;
}
else {
char *s=THIS->str;
strncpy(THIS->__retvalue,s+THIS->start,THIS->stop);
THIS->__retvalue[THIS->stop]='\0';
}
%}
/** @addtogroup library
* @code isinstr:long(s1:string,s2:string) @endcode
* @param s1 string
* @param s2 string
* @return Returns 1 if s2 is in s1.
*/
function isinstr:long(s1:string,s2:string) %{ /* pure */
if(strstr(THIS->s1,THIS->s2)!=NULL)
THIS->__retvalue = 1;
else
THIS->__retvalue = 0;
%}
/** @} */
|