version 1.12, 2000/12/06 00:54:09 |
version 1.14, 2001/08/20 09:03:24 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/file.c,v 1.11 2000/12/05 01:24:50 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/file.c,v 1.13 2001/03/21 23:49:34 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 71 void Pload(), Pwhich(), Ploadfiles(), Poutput(); |
|
Line 71 void Pload(), Pwhich(), Ploadfiles(), Poutput(); |
|
void Pbsave(), Pbload(), Pbload27(); |
void Pbsave(), Pbload(), Pbload27(); |
void Pbsave_compat(), Pbload_compat(); |
void Pbsave_compat(), Pbload_compat(); |
void Pbsave_cmo(), Pbload_cmo(); |
void Pbsave_cmo(), Pbload_cmo(); |
void Popen_file(), Pclose_file(), Pget_line(), Pget_byte(); |
void Popen_file(), Pclose_file(), Pget_line(), Pget_byte(), Pput_byte(); |
void Ppurge_stdin(); |
void Ppurge_stdin(); |
|
void Pload_exec(); |
|
|
extern int des_encryption; |
extern int des_encryption; |
extern char *asir_libdir; |
extern char *asir_libdir; |
|
|
struct ftab file_tab[] = { |
struct ftab file_tab[] = { |
{"purge_stdin",Ppurge_stdin,0}, |
{"purge_stdin",Ppurge_stdin,0}, |
{"open_file",Popen_file,1}, |
{"open_file",Popen_file,-2}, |
{"close_file",Pclose_file,1}, |
{"close_file",Pclose_file,1}, |
{"get_byte",Pget_byte,1}, |
{"get_byte",Pget_byte,1}, |
|
{"put_byte",Pput_byte,2}, |
{"get_line",Pget_line,-1}, |
{"get_line",Pget_line,-1}, |
{"remove_file",Premove_file,1}, |
{"remove_file",Premove_file,1}, |
{"access",Paccess,1}, |
{"access",Paccess,1}, |
{"load",Pload,-1}, |
{"load",Pload,-1}, |
|
{"load_exec",Pload_exec,1}, |
{"which",Pwhich,1}, |
{"which",Pwhich,1}, |
{"loadfiles",Ploadfiles,1}, |
{"loadfiles",Ploadfiles,1}, |
{"output",Poutput,-1}, |
{"output",Poutput,-1}, |
|
|
if ( i == BUFSIZ ) |
if ( i == BUFSIZ ) |
error("open_file : too many open files"); |
error("open_file : too many open files"); |
name = BDY((STRING)ARG0(arg)); |
name = BDY((STRING)ARG0(arg)); |
fp = fopen(name,"r"); |
if ( argc(arg) == 2 ) { |
|
asir_assert(ARG1(arg),O_STR,"open_file"); |
|
fp = fopen(name,BDY((STRING)ARG1(arg))); |
|
} else |
|
fp = fopen(name,"r"); |
if ( !fp ) { |
if ( !fp ) { |
sprintf(errbuf,"open_file : \"%s\" not found",name); |
sprintf(errbuf,"open_file : cannot open \"%s\"",name); |
error(errbuf); |
error(errbuf); |
} |
} |
file_ptrs[i] = fp; |
file_ptrs[i] = fp; |
|
|
error("get_byte : invalid argument"); |
error("get_byte : invalid argument"); |
} |
} |
|
|
|
void Pput_byte(arg,rp) |
|
NODE arg; |
|
Q *rp; |
|
{ |
|
int i,c; |
|
FILE *fp; |
|
|
|
asir_assert(ARG0(arg),O_N,"put_byte"); |
|
asir_assert(ARG1(arg),O_N,"put_byte"); |
|
i = QTOS((Q)ARG0(arg)); |
|
c = QTOS((Q)ARG1(arg)); |
|
if ( fp = file_ptrs[i] ) { |
|
putc(c,fp); |
|
STOQ(c,*rp); |
|
} else |
|
error("put_byte : invalid argument"); |
|
} |
|
|
void Pload(arg,rp) |
void Pload(arg,rp) |
NODE arg; |
NODE arg; |
Q *rp; |
Q *rp; |
|
|
break; |
break; |
} |
} |
} |
} |
|
STOQ(ret,*rp); |
|
} |
|
|
|
void Pload_exec(arg,rp) |
|
NODE arg; |
|
Q *rp; |
|
{ |
|
int ret = 0; |
|
char *name0,*name; |
|
|
|
name0 = BDY((STRING)ARG0(arg)); |
|
searchasirpath(name0,&name); |
|
if ( !name ) |
|
ret = -1; |
|
else |
|
ret = load_and_execfile(name); |
STOQ(ret,*rp); |
STOQ(ret,*rp); |
} |
} |
|
|