home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / osi / isode / vmsisode / vmsisode80_tar.Z / vmsisode80_tar / sockit / source / file.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-23  |  2.6 KB  |  146 lines

  1. #include <stdio.h>
  2. #include <sys/file.h>
  3. #include <sys/time.h>
  4. #include <sys/types.h>
  5. #include <stat.h>
  6. #include <errno.h>
  7.  
  8. static int debug = 0;
  9.  
  10. flock(fd, operation)
  11. int fd, operation;
  12. {
  13.    return(0);
  14. }
  15.  
  16. ftruncate(fd, length)
  17. int fd;
  18. off_t length;
  19. {
  20.    return(0);
  21. }
  22.  
  23. utime(file, tvp)
  24. char *file;
  25. struct timeval tvp[2];
  26. {
  27.    return(0);
  28. }
  29.  
  30. int fchown(fd, owner, group)
  31. int fd, owner, group;
  32. {
  33.    return(-1);
  34. }
  35.  
  36. int rmdir(path)
  37. char *path;
  38. {
  39.    return(-1);
  40. }
  41.  
  42. int truncate(path, length)
  43. char *path;
  44. unsigned long length;
  45. {
  46.    return(0);
  47. }
  48.  
  49. FILE *si_fopen(filename, mode)
  50. char *filename, *mode;
  51. {
  52.    char *p, *unix2vms();
  53.    FILE *f;
  54.    p = unix2vms(filename);
  55. if (debug) fprintf(stderr,"fopen - %s\n",p);
  56.    f = fopen(p, mode);
  57.    return(f);
  58. }
  59.  
  60. FILE *si_freopen(filename, mode, stream)
  61. char *filename, *mode;
  62. FILE *stream;
  63. {
  64.    return(freopen(unix2vms(filename), mode, stream));
  65. }
  66.  
  67. int si_open(filename, mode, x)
  68. char *filename;
  69. int mode, x;
  70. {
  71.    if (strcmp(filename,"/dev/null") == 0) return(open("nl:",mode,x));
  72. if (debug) fprintf(stderr,"open - %s\n",unix2vms(filename));
  73.    return(open(unix2vms(filename), mode));
  74. }
  75.  
  76. int si_remove(filename)
  77. char *filename;
  78. {
  79.    return(remove(unix2vms(filename)));
  80. }
  81.  
  82.  
  83. int si_stat(x,y)
  84. char *x;
  85. struct stat *y;
  86. {
  87.    char pkbuff[128], *si_getenv(), *pk;
  88.    int i;
  89. /*why do we do this!
  90.    chdir(si_getenv("PATH"));
  91. */
  92.    bzero(y,sizeof (struct stat));
  93.    pk = si_getenv("PATH");
  94. if (debug) fprintf(stderr,"stat - current path is %s\n",pk);
  95. if (debug) fprintf(stderr,"stat - file=%s unixfile=%s\n",x,unix2vms(x));
  96.    if (strcmp(x,"/dev/null") == 0) return(stat("nl:",y));
  97.    if (strcmp(x,".") == 0 || strcmp(x,"..") == 0 || strcmp(x,"./") == 0 ||
  98.        strcmp(x,"../") == 0) {
  99.     y->st_mode = S_IFDIR;
  100.     return(0);
  101.    }
  102.    bzero(y, sizeof(struct stat));
  103.    strcpy(pkbuff,unix2vms(x));
  104.    i = stat(pkbuff,y);
  105. if (debug) fprintf(stderr," returns %d\n",i);
  106.    if (i == 0) return(0);
  107.    strcat(pkbuff, ".dir");
  108.    i = stat(pkbuff,y);
  109. if (debug) fprintf(stderr," returns %d\n",i);
  110.    return(i);
  111. }
  112.  
  113. int si_access(file, mode)
  114. char *file;
  115. int mode;
  116. {
  117.    int i, temp_errno;
  118.    char pkbuff[128];
  119. if (debug) fprintf(stderr,"access - %s\n",file);
  120.    if (strcmp(file,".") == 0 || strcmp(file,"..") == 0) return(0);
  121.    i = access(unix2vms(file), mode);
  122.    temp_errno = errno;
  123.    if (i == 0) return(0);
  124.    strcpy(pkbuff, unix2vms(file));
  125.    strcat(pkbuff, ".dir");
  126.    i = access(pkbuff, mode);
  127.    if (i != 0) errno = temp_errno;
  128. if (debug) fprintf(stderr,"returns %d\n",i);
  129.    return(i);
  130. }
  131.  
  132. int si_execv(path,argv)
  133. char *path, *argv[];
  134. {
  135.    char buffer[128];
  136.    strcpy(buffer,path);
  137.    strcat(buffer,".exe");
  138.    return(execv(unix2vms(buffer),argv));
  139. }
  140.  
  141. int setlinebuf(f)
  142. FILE *f;
  143. {
  144.   return(0);
  145. }
  146.