home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <ssdef.h>
- #include <syscall.h>
-
- struct descriptor{
- int size;
- char *ptr;
- };
-
- static char ptype[1];
- static char pcommand[256];
-
- FILE *popen(command,type)
- char *command,*type;
- {
- strcpy(pcommand,command);
- strncpy(ptype,type,1);
-
- if (*type == 'r') {
- sys(command,0,"tmp:si_12345.dat");
- return(fopen("tmp:si_12345.dat","r"));
- }
- else {
- strcpy(pcommand,command);
- strncpy(ptype,type,1);
- return(fopen("tmp:si_12345.dat","w"));
- }
- }
-
- pclose(stream)
- FILE *stream;
- {
- if (*ptype == 'r') {
- fclose(stream);
- delete("tmp:si_12345.dat");
- }
- else {
- fclose(stream);
- printf("Executing :%s:\n",pcommand);
- sys(pcommand,"tmp:si_12345.dat",0);
- /* delete("tmp:si_12345.dat");*/
- }
- }
-
- int sys(cmd,sysinput,sysoutput)
- char *cmd,*sysinput,*sysoutput;
- {
- struct descriptor d,sysi,syso,*in,*out;
- d.size = strlen(cmd);
- d.ptr = cmd;
- if (sysinput == 0) in = 0;
- else {
- in = &sysi;
- sysi.size = strlen(sysinput);
- sysi.ptr = sysinput;
- }
- if (sysoutput == 0) out = 0;
- else {
- out = &syso;
- syso.size = strlen(sysoutput);
- syso.ptr = sysoutput;
- }
- return(lib$spawn(&d,in,out,0,0,0,0,0,0,0));
- }
-
- syscall(number,arg1,arg2,arg3)
- int number;
- char *arg1, *arg2, *arg3;
- {
- switch(number) {
- case SYS_open:
- return(open(arg1,arg2,arg3));
- case SYS_close:
- return(si_close(arg1));
- case SYS_link:
- return(link(arg1,arg2));
- case SYS_unlink:
- return(unlink(arg1,arg2));
- case SYS_rmdir:
- return(rmdir(arg1));
- case SYS_chown:
- return(chown(arg1,arg2,arg3));
- case SYS_fchown:
- return(fchown(arg1,arg2,arg3));
- case SYS_truncate:
- return(truncate(arg1,arg2));
- case SYS_rename:
- return(rename(arg1,arg2));
- case SYS_flock:
- return(flock(arg1,arg2));
- default:
- printf("syscall called - but not handled yet :%d\n",number);
- return(-1);
- }
- }
-