home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OS9000
/
APPS
/
rcs.lzh
/
rcs1
/
osk.c
< prev
next >
Wrap
Text File
|
1996-04-20
|
2KB
|
135 lines
/*
** $Id: osk.c_v 1.3 96/04/07 00:07:30 hiro Exp $
*/
/*
* $Log: osk.c_v $
* Revision 1.3 96/04/07 00:07:30 hiro
* Ported to OS-9000.
*
* Revision 1.2 95/10/23 00:45:38 hiro
* Reverted rename for _UCC because the current rename library is not
* compatible with NFS.
*
* Revision 1.1 93/04/02 01:26:33 hiro
* Initial revision
*
* Revision 1.1 90/07/23 10:26:24 momo
* Initial revision
*
*/
#include <stdio.h>
#include <sgstat.h>
#include <sg_codes.h>
#include <modes.h>
#ifndef DT_SCF
#include <io.h>
#endif
#if defined(_UCC) || defined(_OS9000)
#define environ _environ
#endif
#define STDIN 0
#define STDOUT 1
#define STDERR 2
#define ERR (-1)
#define TRUE (-1)
#define FALSE 0
extern char **environ;
extern int errno;
#ifndef _UCC
void perror(buf)
char *buf;
{
fputs(buf,stderr);
fflush(stderr);
}
int remove(file)
{
return unlink(file);
}
#endif
#ifdef _UCC
int _rename(from,to)
#else
int rename(from,to)
#endif
char *from,*to;
{
register char *p , *pp;
char *argv[4];
int pid , stat , os9fork();
if (access(to , 0) == 0)
{
if (unlink(to) == -1)
{
if (chmod(to, S_IREAD|S_IWRITE) == -1) return -1;
if (unlink(to) == -1) return -1;
}
}
argv[0]="rename";
argv[1]=from;
for ( p=pp=to ; *p; p++ ) {
if ( *p=='/' ) pp=p+1;
}
argv[2] = pp;
argv[3] = (char *)NULL;
if ((pid =os9exec(os9fork, argv[0], argv, environ, 0, 128, 3)) == (-1))
return (-1);
while (wait(&stat)!=pid) tsleep(10);
if (stat) { errno=stat; return (-1); }
return (0);
}
/*
** char pwd( char *buf )
** return current working directory to buf
*/
char *pwd( buf )
char *buf;
{
int stdinp,stdoutp
,pipe,pid,status
,os9fork();
char *argv[2];
if ( (pipe=open("/pipe",3))==ERR ) return NULL;
stdinp=dup(STDIN); stdoutp=dup(STDOUT);
close(STDIN); close(STDOUT);
dup(pipe); dup(pipe);
argv[0]="pd"; argv[1]=0;
pid=os9exec(os9fork,"pd",argv,environ,0,128,3);
close(STDIN); close(STDOUT);
dup(stdinp); dup(stdoutp);
close(stdinp); close(stdoutp);
if ( pid!=ERR ) {
while ( wait(&status)!=pid ) tsleep(10);
if ( status==0 ) readln(pipe,buf,256);
}
close(pipe);
if ( pid==ERR || status!=0 ) return NULL;
return buf;
}
/*
** isatty
** returned value <>0 : SCF Device
** 0 : Non SCF Device
*/
isatty( path )
int path;
{
struct sgbuf sg;
_gs_opt( path , & sg );
if ( sg.sg_class==DT_SCF ) return TRUE;
return FALSE;
}