version 1.11, 2000/12/05 01:24:50 |
version 1.13, 2001/03/21 23:49:34 |
|
|
* 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.10 2000/11/13 01:48:12 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/file.c,v 1.12 2000/12/06 00:54:09 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(); |
|
|
extern int des_encryption; |
extern int des_encryption; |
Line 79 extern char *asir_libdir; |
|
Line 79 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}, |
|
|
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; |
|
|
HKEY hOpenKey; |
HKEY hOpenKey; |
DWORD Type; |
DWORD Type; |
char *slash; |
char *slash; |
|
|
if ( rootdir.body ) { |
if ( rootdir.body ) { |
strcpy(name,rootdir.body); |
strcpy(name,rootdir.body); |
|
return; |
|
} |
|
|
|
if ( access("UseCurrentDir",0) >= 0 ) { |
|
GetCurrentDirectory(BUFSIZ,name); |
|
slash = strrchr(name,'\\'); |
|
if ( slash ) |
|
*slash = 0; |
return; |
return; |
} |
} |
name[0] = 0; |
name[0] = 0; |