version 1.17, 2003/02/14 22:29:07 |
version 1.19, 2003/11/12 07:48:50 |
|
|
* 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.16 2002/10/01 09:58:48 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/file.c,v 1.18 2003/11/01 23:58:43 takayama Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 77 void Pbsave_compat(), Pbload_compat(); |
|
Line 77 void Pbsave_compat(), Pbload_compat(); |
|
void Pbsave_cmo(), Pbload_cmo(); |
void Pbsave_cmo(), Pbload_cmo(); |
void Popen_file(), Pclose_file(), Pget_line(), Pget_byte(), Pput_byte(); |
void Popen_file(), Pclose_file(), Pget_line(), Pget_byte(), Pput_byte(); |
void Ppurge_stdin(); |
void Ppurge_stdin(); |
void Pload_exec(); |
void Pexec(); |
|
|
extern int des_encryption; |
extern int des_encryption; |
extern char *asir_libdir; |
extern char *asir_libdir; |
Line 92 struct ftab file_tab[] = { |
|
Line 92 struct ftab file_tab[] = { |
|
{"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}, |
{"exec",Pexec,1}, |
{"which",Pwhich,1}, |
{"which",Pwhich,1}, |
{"loadfiles",Ploadfiles,1}, |
{"loadfiles",Ploadfiles,1}, |
{"output",Poutput,-1}, |
{"output",Poutput,-1}, |
Line 131 void Popen_file(NODE arg,Q *rp) |
|
Line 131 void Popen_file(NODE arg,Q *rp) |
|
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)); |
if ( argc(arg) == 2 ) { |
if (strcmp(name,"unix://stdin") == 0) { |
|
fp = stdin; |
|
}else if (strcmp(name,"unix://stdout") == 0) { |
|
fp = stdout; |
|
}else if (strcmp(name,"unix://stderr") == 0) { |
|
fp = stderr; |
|
}else{ |
|
if ( argc(arg) == 2 ) { |
asir_assert(ARG1(arg),O_STR,"open_file"); |
asir_assert(ARG1(arg),O_STR,"open_file"); |
fp = fopen(name,BDY((STRING)ARG1(arg))); |
fp = fopen(name,BDY((STRING)ARG1(arg))); |
} else |
} else |
fp = fopen(name,"r"); |
fp = fopen(name,"r"); |
|
} |
if ( !fp ) { |
if ( !fp ) { |
sprintf(errbuf,"open_file : cannot open \"%s\"",name); |
sprintf(errbuf,"open_file : cannot open \"%s\"",name); |
error(errbuf); |
error(errbuf); |
Line 272 void Pload(NODE arg,Q *rp) |
|
Line 280 void Pload(NODE arg,Q *rp) |
|
STOQ(ret,*rp); |
STOQ(ret,*rp); |
} |
} |
|
|
void Pload_exec(NODE arg,Q *rp) |
void Pexec(NODE arg,Q *rp) |
{ |
{ |
int ret; |
int ret; |
char *name0,*name; |
char *name0,*name; |
Line 282 void Pload_exec(NODE arg,Q *rp) |
|
Line 290 void Pload_exec(NODE arg,Q *rp) |
|
if ( !name ) |
if ( !name ) |
ret = -1; |
ret = -1; |
else { |
else { |
load_and_execfile(name); |
execasirfile(name); |
ret = 0; |
ret = 0; |
} |
} |
STOQ(ret,*rp); |
STOQ(ret,*rp); |