2 * ARexx functions for regina
3 * Copyright © 2002, Staf Verhaegen
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /* This files contains functions that are implemented in ARexx
21 * but that are not standard REXX functions. This file contains
22 * the functions that can be used on all platforms. amifuncs.c
23 * contains the ARexx functions that are only usable on the
24 * amiga platform or compatibles. (not implemented yet)
32 #if !defined(HAVE_DRAND48)
36 static const streng _fname
= {1, 1, "F"}, _fstem
= {4, 4, {'F', 'I', '.', 'F'}};
38 typedef struct _arexx_tsd_t
{
44 /* Init thread data for arexx functions
46 int init_arexxf ( tsd_t
*TSD
)
48 arexx_tsd_t
*atsd
= (arexx_tsd_t
*)malloc( sizeof(arexx_tsd_t
) );
50 if (atsd
==NULL
) return 0;
52 TSD
->arx_tsd
= (void *)atsd
;
54 /* Allocate later because systeminfo is not initialized at the moment */
55 atsd
->amilevel
= NULL
;
62 * Support functions for the ARexx IO functions
64 /* setamilevel will change the environment to the variables used for open files */
65 static proclevel
setamilevel( tsd_t
*TSD
)
67 arexx_tsd_t
*atsd
= (arexx_tsd_t
*)TSD
->arx_tsd
;
68 proclevel oldlevel
= TSD
->currlevel
;
70 if (atsd
->amilevel
!=NULL
)
71 TSD
->currlevel
= atsd
->amilevel
;
76 atsd
->amilevel
= newlevel( TSD
, NULL
);
78 TSD
->currlevel
= atsd
->amilevel
;
80 setvalue( TSD
, &_fname
, Str_cre_TSD( TSD
, "STDIN" ) );
81 sprintf( txt
, "%p", stdin
);
82 setvalue( TSD
, &_fstem
, Str_cre_TSD( TSD
, txt
) );
84 setvalue( TSD
, &_fname
, Str_cre_TSD( TSD
, "STDOUT" ) );
85 sprintf( txt
, "%p", stdout
);
86 setvalue( TSD
, &_fstem
, Str_cre_TSD( TSD
, txt
) );
88 setvalue( TSD
, &_fname
, Str_cre_TSD( TSD
, "STDERR" ) );
89 sprintf( txt
, "%p", stderr
);
90 setvalue( TSD
, &_fstem
, Str_cre_TSD( TSD
, txt
) );
97 /* getfile will return the FILE pointer of given name */
98 static FILE *getfile( tsd_t
*TSD
, const streng
*name
)
100 proclevel oldlevel
= setamilevel( TSD
);
105 setvalue( TSD
, &_fname
, Str_dup_TSD( TSD
, name
) );
106 if ( isvariable( TSD
, &_fstem
) )
108 s
= getvalue( TSD
, &_fstem
, 0 );
109 txt
= str_of( TSD
, s
);
110 sscanf( txt
, "%p", &file
);
114 TSD
->currlevel
= oldlevel
;
120 /* getfilenames will return a list of all opened files */
121 static streng
*getfilenames( tsd_t
*TSD
, const streng
*sep
)
123 proclevel oldlevel
= setamilevel( TSD
);
124 streng
*retval
, *tmpstr
;
128 get_next_variable( TSD
, 1 );
129 for ( var
= get_next_variable( TSD
, 0);
131 var
= get_next_variable( TSD
, 0) )
133 while ( var
!= NULL
&& var
->realbox
!= NULL
)
136 if ( var
!= NULL
&& ( (var
->flag
& (VFLAG_STR
| VFLAG_NUM
)) || var
->stem
) )
140 retval
= Str_dup_TSD( TSD
, var
->name
);
145 tmpstr
= Str_cat_TSD( TSD
, retval
, sep
);
146 if ( tmpstr
!= retval
)
148 Free_string_TSD( TSD
, retval
);
151 tmpstr
= Str_cat_TSD( TSD
, retval
, var
->name
);
152 if ( tmpstr
!= retval
)
154 Free_string_TSD( TSD
, retval
);
161 TSD
->currlevel
= oldlevel
;
163 /* If no variable present return NULL string */
165 retval
= nullstringptr();
170 /* addfile: store the FILE pointer in a given name */
171 static void addfile( tsd_t
*TSD
, const streng
*name
, FILE *file
)
173 proclevel oldlevel
= setamilevel( TSD
);
177 sprintf( txt
, "%p", (void *)file
);
178 s
= Str_cre_TSD( TSD
, txt
);
179 setvalue( TSD
, &_fname
, Str_dup_TSD( TSD
, name
) );
180 setvalue( TSD
, &_fstem
, s
);
182 TSD
->currlevel
= oldlevel
;
186 /* rmfile: remove a given of open files list */
187 static void rmfile( tsd_t
*TSD
, const streng
*name
)
189 arexx_tsd_t
*atsd
= (arexx_tsd_t
*)TSD
->arx_tsd
;
190 proclevel oldlevel
= setamilevel( TSD
);
192 TSD
->currlevel
= atsd
->amilevel
;
194 drop_var( TSD
, name
);
196 TSD
->currlevel
= oldlevel
;
202 * Implementation of the ARexx IO functions
203 * See general documentation for more information
204 * Functions implemented: OPEN, CLOSE, READCH, READLN, WRITECH, WRITELN, EOF, SEEK
206 streng
*arexx_open( tsd_t
*TSD
, cparamboxptr parm1
)
208 cparamboxptr parm2
, parm3
;
212 static const char* modestrings
[] = {
218 checkparam( parm1
, 2, 3, "OPEN" );
222 file
= getfile( TSD
, parm1
->value
);
225 return int_to_streng( TSD
, 0 );
228 filename
= str_of( TSD
, parm2
->value
);
231 || parm3
->value
==NULL
232 || parm3
->value
->len
==0 )
234 else switch( getoptionchar( TSD
, parm3
->value
, "OPEN", 3, "", "WRA" ) )
254 file
= fopen( filename
, modestrings
[mode
] );
259 return int_to_streng( TSD
, 0 );
262 addfile( TSD
, parm1
->value
, file
);
263 return int_to_streng( TSD
, 1);
267 streng
*arexx_close( tsd_t
*TSD
, cparamboxptr parm1
)
271 checkparam( parm1
, 1, 1, "CLOSE" );
273 file
= getfile( TSD
, parm1
->value
);
275 return int_to_streng( TSD
, 0 );
278 rmfile( TSD
, parm1
->value
);
280 return int_to_streng( TSD
, 1 );
284 streng
*arexx_writech( tsd_t
*TSD
, cparamboxptr parm1
)
291 checkparam( parm1
, 2, 2, "WRITECH" );
294 file
= getfile( TSD
, parm1
->value
);
296 exiterror( ERR_INCORRECT_CALL
, 27, "WRITECH", tmpstr_of( TSD
, parm1
->value
));
298 txt
= str_of( TSD
, parm2
->value
);
299 count
= fprintf( file
, "%s", txt
);
302 return int_to_streng( TSD
, count
);
306 streng
*arexx_writeln( tsd_t
*TSD
, cparamboxptr parm1
)
313 checkparam( parm1
, 2, 2, "WRITELN" );
316 file
= getfile( TSD
, parm1
->value
);
318 exiterror( ERR_INCORRECT_CALL
, 27, "WRITELN", tmpstr_of( TSD
, parm1
->value
) );
320 txt
= str_of( TSD
, parm2
->value
);
321 count
= fprintf(file
, "%s\n", txt
);
324 return int_to_streng( TSD
, count
);
328 streng
*arexx_seek( tsd_t
*TSD
, cparamboxptr parm1
)
330 cparamboxptr parm2
, parm3
;
332 int pos
, error
, wench
;
335 checkparam( parm1
, 2, 3, "SEEK" );
339 file
= getfile( TSD
, parm1
->value
);
341 exiterror( ERR_INCORRECT_CALL
, 27, "SEEK", tmpstr_of( TSD
, parm1
->value
) );
343 offset
= streng_to_int( TSD
, parm2
->value
, &error
);
345 exiterror( ERR_INCORRECT_CALL
, 11, "SEEK", 2, tmpstr_of( TSD
, parm2
->value
) );
348 || parm3
->value
==NULL
349 || parm3
->value
->len
== 0 )
351 else switch( getoptionchar( TSD
, parm3
->value
, "SEEK", 3, "", "CBE" ) )
371 pos
= fseek( file
, offset
, wench
);
372 return int_to_streng( TSD
, pos
);
376 streng
*arexx_readch( tsd_t
*TSD
, cparamboxptr parm1
)
381 checkparam( parm1
, 1, 2, "READCH");
384 file
= getfile( TSD
, parm1
->value
);
386 exiterror( ERR_INCORRECT_CALL
, 27, "READCH", tmpstr_of( TSD
, parm1
->value
) );
390 char buffer
[2] = { 0, 0 };
392 buffer
[0] = (char)getc( file
);
394 return Str_cre_TSD( TSD
, buffer
);
402 count
= streng_to_int( TSD
, parm2
->value
, &error
);
405 exiterror( ERR_INCORRECT_CALL
, 11, "READCH", 2, tmpstr_of( TSD
, parm2
->value
) );
407 exiterror( ERR_INCORRECT_CALL
, 14, "READCH", 2, tmpstr_of( TSD
, parm2
->value
) );
409 buffer
= malloc( count
+ 1 );
411 count
= fread( buffer
, 1, count
, file
);
412 buffer
[count
+ 1] = 0;
414 ret
= Str_cre_TSD( TSD
, buffer
);
421 streng
*arexx_readln( tsd_t
*TSD
, cparamboxptr parm
)
426 checkparam( parm
, 1, 1, "READLN");
428 file
= getfile( TSD
, parm
->value
);
430 exiterror( ERR_INCORRECT_CALL
, 27, "READLN", tmpstr_of( TSD
, parm
->value
) );
432 fgets( buffer
, 1001, file
);
433 if ( buffer
[strlen(buffer
)-1]=='\n' )
434 buffer
[strlen(buffer
)-1]=0;
436 return Str_cre_TSD( TSD
, buffer
);
440 streng
*arexx_eof( tsd_t
*TSD
, cparamboxptr parm
)
444 checkparam( parm
, 1, 1, "EOF" );
446 file
= getfile( TSD
, parm
->value
);
448 exiterror( ERR_INCORRECT_CALL
, 27, "EOF", tmpstr_of( TSD
, parm
->value
) );
450 return int_to_streng( TSD
, feof( file
)!=0 );
455 * Implementation of the additional conversion functions from ARexx
456 * Functions: B2C, C2B
458 streng
*arexx_b2c( tsd_t
*TSD
, cparamboxptr parm
)
463 checkparam( parm
, 1, 1, "B2C" );
466 parm2
.value
= std_b2x( TSD
, parm
);
468 ret
= std_x2c( TSD
, &parm2
);
469 Free_string_TSD( TSD
, parm2
.value
);
475 streng
*arexx_c2b( tsd_t
*TSD
, cparamboxptr parm
)
480 checkparam( parm
, 1, 1, "B2C" );
483 parm2
.value
= std_c2x( TSD
, parm
);
485 ret
= std_x2b( TSD
, &parm2
);
486 Free_string_TSD( TSD
, parm2
.value
);
493 * Implementation of the bitwise function from ARexx
494 * Functions: BITCHG, BITCLR, BITSET, BITTST, BITCOMP
496 streng
*arexx_bitchg( tsd_t
*TSD
, cparamboxptr parm1
)
500 int bit
, error
, byte
;
503 checkparam( parm1
, 2, 2, "BITCHG" );
506 bit
= streng_to_int( TSD
, parm2
->value
, &error
);
508 exiterror( ERR_INCORRECT_CALL
, 11, "BITCHG", 2, tmpstr_of( TSD
, parm2
->value
) );
510 exiterror( ERR_INCORRECT_CALL
, 13, "BITCHG", 2, tmpstr_of( TSD
, parm2
->value
) );
514 byte
= parm1
->value
->len
-dt
.quot
-1;
516 exiterror( ERR_INCORRECT_CALL
, 0 );
518 ret
= Str_dup_TSD( TSD
, parm1
->value
);
519 ret
->value
[byte
]^=(char)(1<<dt
.rem
);
524 streng
*arexx_bitclr( tsd_t
*TSD
, cparamboxptr parm1
)
528 int bit
, error
, byte
;
531 checkparam( parm1
, 2, 2, "BITCLR" );
534 bit
= streng_to_int( TSD
, parm2
->value
, &error
);
536 exiterror( ERR_INCORRECT_CALL
, 11, "BITCLR", 2, tmpstr_of( TSD
, parm2
->value
) );
538 exiterror( ERR_INCORRECT_CALL
, 13, "BITCLR", 2, tmpstr_of( TSD
, parm2
->value
) );
542 byte
= parm1
->value
->len
-dt
.quot
-1;
544 exiterror( ERR_INCORRECT_CALL
, 0 );
546 ret
= Str_dup_TSD( TSD
, parm1
->value
);
547 ret
->value
[byte
]&=~(char)(1<<dt
.rem
);
552 streng
*arexx_bitset( tsd_t
*TSD
, cparamboxptr parm1
)
556 int bit
, error
, byte
;
559 checkparam( parm1
, 2, 2, "BITSET" );
562 bit
= streng_to_int( TSD
, parm2
->value
, &error
);
564 exiterror( ERR_INCORRECT_CALL
, 11, "BITSET", 2, tmpstr_of( TSD
, parm2
->value
) );
566 exiterror( ERR_INCORRECT_CALL
, 13, "BITSET", 2, tmpstr_of( TSD
, parm2
->value
) );
570 byte
= parm1
->value
->len
-dt
.quot
-1;
572 exiterror( ERR_INCORRECT_CALL
, 0 );
574 ret
= Str_dup_TSD( TSD
, parm1
->value
);
575 ret
->value
[byte
]|=(char)(1<<dt
.rem
);
580 streng
*arexx_bittst( tsd_t
*TSD
, cparamboxptr parm1
)
584 int bit
, error
, byte
;
587 checkparam( parm1
, 2, 2, "BITTST" );
590 bit
= streng_to_int( TSD
, parm2
->value
, &error
);
592 exiterror( ERR_INCORRECT_CALL
, 11, "BITTST", 2, tmpstr_of( TSD
, parm2
->value
) );
594 exiterror( ERR_INCORRECT_CALL
, 13, "BITTST", 2, tmpstr_of( TSD
, parm2
->value
) );
598 byte
= parm1
->value
->len
-dt
.quot
-1;
600 exiterror( ERR_INCORRECT_CALL
, 0 );
602 ret
= int_to_streng( TSD
, (parm1
->value
->value
[byte
] & (char)(1<<dt
.rem
))!=0 );
607 /* Help function for arexx_bitcomp */
608 static int firstbit(char c
)
624 /* This ARexx function has very weird usage of the pad byte,
625 * the shortest string is padded on the left with this byte
627 streng
*arexx_bitcomp( tsd_t
*TSD
, cparamboxptr parm1
)
629 cparamboxptr parm2
, parm3
;
630 const streng
*s1
, *s2
;
631 const char *cp1
, *cp2
;
635 checkparam( parm1
, 2, 3, "BITCOMP" );
638 /* Make s2 always shorter or equal to s1 */
639 if ( parm1
->value
->len
< parm2
->value
->len
)
648 for ( cp1
=s1
->value
+s1
->len
-1, cp2
=s2
->value
+s2
->len
-1, i
=0;
653 return int_to_streng( TSD
, i
*8 + firstbit( *cp1
^ *cp2
) );
657 if ( parm3
==NULL
|| parm3
->value
==NULL
|| parm3
->value
->len
==0 )
660 pad
= parm3
->value
->value
[0];
667 return int_to_streng( TSD
, i
*8 + firstbit( *cp1
^ pad
) );
670 return int_to_streng( TSD
, -1 );
675 * Some more misc. ARexx functions
676 * Functions: COMPRESS, HASH, RANDU, TRIM, UPPER
678 streng
*arexx_hash( tsd_t
*TSD
, cparamboxptr parm1
)
683 checkparam( parm1
, 1, 1, "HASH" );
685 uc
= (unsigned char *)parm1
->value
->value
;
686 for ( i
=0; i
<parm1
->value
->len
; i
++)
688 sum
= (sum
+ uc
[i
]) & 255;
691 return int_to_streng( TSD
, sum
);
695 streng
*arexx_compress( tsd_t
*TSD
, cparamboxptr parm1
)
701 checkparam( parm1
, 1, 2, "COMPRESS" );
703 match
= ( parm1
->next
!=NULL
) ? str_of( TSD
, parm1
->next
->value
) : " ";
705 ret
= Str_dup_TSD( TSD
, parm1
->value
);
706 for ( i
=start
=0; i
<ret
->len
; i
++ )
708 /* Copy char if not found */
709 if ( strchr( match
, ret
->value
[i
] )==NULL
)
711 ret
->value
[start
] = ret
->value
[i
];
717 if ( parm1
->next
!=NULL
)
718 FreeTSD( (char *)match
);
724 static const streng T_str
= { 1, 1, "T" };
725 static const parambox T_parm
= { NULL
, 0, (streng
*)&T_str
};
727 streng
*arexx_trim( tsd_t
*TSD
, cparamboxptr parm1
)
731 checkparam( parm1
, 1, 1, "TRIM" );
734 parm
.next
= (paramboxptr
)&T_parm
;
736 return std_strip( TSD
, parm1
);
740 streng
*arexx_upper( tsd_t
*TSD
, cparamboxptr parm1
)
744 checkparam( parm1
, 1, 1, "UPPER" );
746 ret
= Str_dup_TSD( TSD
, parm1
->value
);
748 return Str_upper( ret
);
752 streng
*arexx_randu( tsd_t
*TSD
, cparamboxptr parm1
)
758 checkparam( parm1
, 0, 1, "RANDU" );
760 if ( parm1
!=NULL
&& parm1
->value
!=NULL
)
762 seed
= streng_to_int( TSD
, parm1
->value
, &error
);
764 exiterror( ERR_INCORRECT_CALL
, 11, "RANDU", 1, tmpstr_of( TSD
, parm1
->value
) );
766 srand48( (long int)seed
);
769 sprintf( text
, "%.20f", drand48() );
770 s
= Str_cre_TSD( TSD
, text
);
771 retval
= str_format( TSD
, s
, -1, -1, -1, -1);
780 * Two memory allocation/deallocation functions: getspace and freespace
782 streng
*arexx_getspace( tsd_t
*TSD
, cparamboxptr parm1
)
787 checkparam( parm1
, 1, 1, "GETSPACE" );
789 length
= streng_to_int( TSD
, parm1
->value
, &error
);
791 exiterror( ERR_INCORRECT_CALL
, 11, "GETSPACE", 1, tmpstr_of( TSD
, parm1
->value
) );
793 exiterror( ERR_INCORRECT_CALL
, 14, "GETSPACE", 1, tmpstr_of( TSD
, parm1
->value
) );
795 ptr
= Malloc_TSD( TSD
, length
);
796 memset( ptr
, 0, length
);
798 exiterror( ERR_STORAGE_EXHAUSTED
, 0 );
800 return Str_ncre_TSD( TSD
, (char *)&ptr
, sizeof(void *) );
804 #if defined(_AMIGA) || defined(__AROS__)
805 #include <exec/memory.h>
806 #include <proto/exec.h>
809 streng
*arexx_freespace( tsd_t
*TSD
, cparamboxptr parm1
)
811 /* For backwards compatibility there may be two arguments
812 But the second argument is ignored in regina */
813 checkparam( parm1
, 0, 2, "FREESPACE" );
815 if ( parm1
== NULL
|| parm1
->value
== NULL
|| parm1
->value
->len
== 0 )
816 #if defined(_AMIGA) || defined(__AROS__)
817 return int_to_streng( TSD
, AvailMem( MEMF_ANY
) );
819 return int_to_streng( TSD
, -1 );
822 if ( parm1
->value
->len
!= sizeof(void *) )
823 exiterror( ERR_INCORRECT_CALL
, 0 );
825 Free_TSD( TSD
, *((void **)parm1
->value
->value
) );
827 return nullstringptr();
834 * ARexx memory <-> string conversion routines: IMPORT, EXPORT, STORAGE
836 streng
*arexx_import( tsd_t
*TSD
, cparamboxptr parm1
)
842 checkparam( parm1
, 1, 2, "IMPORT" );
844 if ( parm1
->value
->len
!= sizeof(void *) )
845 exiterror( ERR_INCORRECT_CALL
, 0 );
847 memptr
= *((void **)parm1
->value
->value
);
850 if ( parm2
== NULL
|| parm2
->value
== NULL
|| parm2
->value
->len
== 0 )
851 len
= strlen((char *)memptr
);
854 len
= streng_to_int( TSD
, parm2
->value
, &error
);
856 exiterror( ERR_INCORRECT_CALL
, 11, "IMPORT", 2, tmpstr_of( TSD
, parm2
->value
) );
858 exiterror( ERR_INCORRECT_CALL
, 14, "IMPORT", 2, tmpstr_of( TSD
, parm2
->value
) );
861 return Str_ncre_TSD( TSD
, memptr
, len
);
865 streng
*arexx_export( tsd_t
*TSD
, cparamboxptr parm1
)
868 cparamboxptr parm2
= NULL
, parm3
= NULL
, parm4
= NULL
;
873 checkparam( parm1
, 1, 4, "EXPORT" );
875 if ( parm1
->value
== NULL
|| parm1
->value
->len
== 0 )
876 exiterror( ERR_INCORRECT_CALL
, 21, "EXPORT", 1 );
877 memptr
= *((void **)parm1
->value
->value
);
885 if ( parm2
== NULL
|| parm2
->value
== NULL
|| parm2
->value
->len
== 0 )
886 src
= nullstringptr();
888 src
= Str_dup_TSD( TSD
, parm2
->value
);
890 if ( parm3
== NULL
|| parm3
->value
== NULL
|| parm3
->value
->len
== 0 )
894 len
= streng_to_int( TSD
, parm3
->value
, &error
);
896 exiterror( ERR_INCORRECT_CALL
, 11, "EXPORT", 3, tmpstr_of( TSD
, parm3
->value
) );
898 exiterror( ERR_INCORRECT_CALL
, 13, "EXPORT", 3, tmpstr_of( TSD
, parm3
->value
) );
901 if ( parm4
== NULL
|| parm4
->value
== NULL
|| parm4
->value
->len
== 0 )
904 fill
= parm4
->value
->value
[0];
908 memcpy( memptr
, src
->value
, src
->len
);
909 memset( ((char *)memptr
)+src
->len
, fill
, len
- src
->len
);
912 memcpy( memptr
, src
->value
, len
);
914 Free_string_TSD( TSD
, src
);
916 return int_to_streng( TSD
, len
);
920 streng
*arexx_storage( tsd_t
*TSD
, cparamboxptr parm1
)
923 cparamboxptr parm2
= NULL
, parm3
= NULL
, parm4
= NULL
;
926 streng
*src
, *retval
;
928 checkparam( parm1
, 0, 4, "STORAGE" );
931 return arexx_getspace( TSD
, NULL
);
933 if ( parm1
->value
== NULL
|| parm1
->value
->len
== 0 )
934 exiterror( ERR_INCORRECT_CALL
, 21, "STORAGE", 1 );
935 memptr
= *((void **)parm1
->value
->value
);
943 if ( parm2
== NULL
|| parm2
->value
== NULL
|| parm2
->value
->len
== 0 )
944 src
= nullstringptr();
946 src
= Str_dup_TSD( TSD
, parm2
->value
);
948 if ( parm3
== NULL
|| parm3
->value
== NULL
|| parm3
->value
->len
== 0 )
952 len
= streng_to_int( TSD
, parm3
->value
, &error
);
954 exiterror( ERR_INCORRECT_CALL
, 11, "STORAGE", 3, tmpstr_of( TSD
, parm3
->value
) );
956 exiterror( ERR_INCORRECT_CALL
, 13, "STORAGE", 3, tmpstr_of( TSD
, parm3
->value
) );
959 if ( parm4
== NULL
|| parm4
->value
== NULL
|| parm4
->value
->len
== 0 )
962 fill
= parm4
->value
->value
[0];
964 retval
= Str_ncre_TSD( TSD
, memptr
, len
);
968 memcpy( memptr
, src
->value
, src
->len
);
969 memset( ((char *)memptr
)+src
->len
, fill
, len
- src
->len
);
972 memcpy( memptr
, src
->value
, len
);
974 Free_string_TSD( TSD
, src
);
982 * SHOW a function the names available in different resource lists
984 streng
*arexx_show( tsd_t
*TSD
, cparamboxptr parm1
)
986 cparamboxptr parm2
= NULL
, parm3
= NULL
;
987 streng
*name
= NULL
, *sep
, *retval
;
989 checkparam( parm1
, 1, 3, "SHOW" );
994 if ( parm2
!= NULL
&& parm2
->value
!= NULL
&& parm2
->value
->len
!= 0 )
997 if ( parm3
== NULL
|| parm3
->value
== NULL
|| parm3
->value
->len
== 0 )
998 sep
= Str_cre_TSD( TSD
, " " );
1000 sep
= Str_dup_TSD( TSD
, parm3
->value
);
1002 switch( getoptionchar( TSD
, parm1
->value
, "SHOW", 1, "", "F" ) )
1006 retval
= getfilenames( TSD
, sep
);
1009 FILE *f
= getfile( TSD
, name
);
1010 retval
= int_to_streng( TSD
, f
!= NULL
);
1014 Free_string_TSD( TSD
, sep
);