00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #pragma ident "@(#) libf/pxf/pxffcntl.c 92.1 06/29/99 11:36:06"
00038 #include <fortran.h>
00039 #include <sys/types.h>
00040 #include <fcntl.h>
00041 #include <errno.h>
00042 #include <liberrno.h>
00043 #include <malloc.h>
00044 #include "pxfstruct.h"
00045 #include "table.h"
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 #ifdef _UNICOS
00063 void
00064 PXFFCNTL(
00065 #else
00066 void
00067 _PXFFCNTL(
00068 #endif
00069 _f_int *ifildes,
00070 _f_int *icmd,
00071 _f_int *iargin,
00072 _f_int *iargout,
00073 _f_int *ierror)
00074 {
00075 int ret;
00076 struct pxfhandle pxfhand;
00077
00078 *ierror = 0;
00079
00080 switch(*icmd) {
00081 case F_GETLK:
00082 case F_SETLK:
00083 case F_SETLKW:
00084 pxfhand = _pxfhandle_table_lookup(&_pxfhandle_table,
00085 *iargin);
00086 if (pxfhand.pxfstructptr == NULL ||
00087 pxfhand.pxftype != PXF_FLOCK) {
00088 *ierror = EBADHANDLE;
00089 return;
00090 }
00091
00092 ret = fcntl(*ifildes, *icmd,
00093 (struct flock *)pxfhand.pxfstructptr);
00094 if (ret < 0) {
00095 *ierror = errno;
00096 }
00097 *iargout = (_f_int)ret;
00098 break;
00099 case F_DUPFD:
00100 case F_SETFD:
00101 case F_GETFD:
00102 case F_GETFL:
00103 case F_SETFL:
00104 #ifdef _UNICOS
00105 case F_SETSB:
00106 case F_SETALF:
00107 case F_CLRALF:
00108 #endif
00109 ret = fcntl(*ifildes, *icmd, *iargin);
00110 if (ret < 0) {
00111 *ierror = errno;
00112 }
00113 *iargout = (_f_int)ret;
00114 break;
00115 default:
00116 *ierror = EINVAL;
00117 }
00118 }
00119
00120 #ifndef _UNICOS
00121 void
00122 pxffcntl_(
00123 _f_int *ifildes,
00124 _f_int *icmd,
00125 _f_int *iargin,
00126 _f_int *iargout,
00127 _f_int *ierror)
00128 {
00129 _PXFFCNTL(ifildes,icmd,iargin,iargout,ierror);
00130 }
00131 #endif