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
00038
00039
00040
00041 #pragma ident "@(#) libf/pxf/pxfget.c 92.1 09/15/99 10:40:48"
00042 #include <fortran.h>
00043 #include <malloc.h>
00044 #include <errno.h>
00045 #include <utime.h>
00046 #include <string.h>
00047 #include <liberrno.h>
00048 #include <fcntl.h>
00049 #include <sys/types.h>
00050 #include <sys/stat.h>
00051 #include <sys/times.h>
00052 #include <grp.h>
00053 #include <pwd.h>
00054 #include "pxfstruct.h"
00055 #include "table.h"
00056 #include <sys/signal.h>
00057 #include <sys/termios.h>
00058
00059 #define SETIFMATCH(_A_,_B_,_C_) if (strcmp(_A_,#_C_) == 0) {\
00060 *value = ((struct _B_ *)(pxfhand.pxfstructptr))->_C_;\
00061 }
00062 #define GETIFMATCH(_A_,_B_,_C_) if (strcmp(_A_,#_C_) == 0) {\
00063 ((struct _B_ *)(pxfhand.pxfstructptr))->_C_ = *value;\
00064 }
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 #ifdef _UNICOS
00080 void
00081 PXFINTGET(
00082 #else
00083 void
00084 _PXFINTGET(
00085 #endif
00086 _f_int *jhandle,
00087 _fcd compnam,
00088 _f_int *value,
00089 _f_int *ierror)
00090 {
00091 char *component;
00092 struct pxfhandle pxfhand;
00093 char **gr_mem;
00094 int i;
00095
00096 *ierror = 0;
00097 component = _fc_acopy(compnam);
00098 if (component == NULL) {
00099 *ierror = ENOMEM;
00100 return;
00101 }
00102
00103 pxfhand = _pxfhandle_table_lookup(&_pxfhandle_table, *jhandle);
00104 if (pxfhand.pxfstructptr == NULL) {
00105 *ierror = EBADHANDLE;
00106 return;
00107 }
00108
00109 switch (pxfhand.pxftype){
00110
00111 case PXF_FLOCK:
00112
00113 SETIFMATCH(component,flock,l_type)
00114 else SETIFMATCH(component,flock,l_whence)
00115 else SETIFMATCH(component,flock,l_start)
00116 else SETIFMATCH(component,flock,l_len)
00117 #ifndef _LITTLE_ENDIAN
00118 else SETIFMATCH(component,flock,l_sysid)
00119 #endif
00120 else SETIFMATCH(component,flock,l_pid)
00121 else {
00122 *ierror = ENONAME;
00123 }
00124 break;
00125 case PXF_UTIMBUF:
00126 SETIFMATCH(component,utimbuf,actime)
00127 else SETIFMATCH(component,utimbuf,modtime)
00128 else {
00129 *ierror = ENONAME;
00130 }
00131 break;
00132 case PXF_STATBUF:
00133 SETIFMATCH(component,stat,st_dev)
00134 else SETIFMATCH(component,stat,st_ino)
00135 else SETIFMATCH(component,stat,st_mode)
00136 else SETIFMATCH(component,stat,st_nlink)
00137 else SETIFMATCH(component,stat,st_uid)
00138 else SETIFMATCH(component,stat,st_gid)
00139 else SETIFMATCH(component,stat,st_rdev)
00140 else SETIFMATCH(component,stat,st_size)
00141 else SETIFMATCH(component,stat,st_atime)
00142 else SETIFMATCH(component,stat,st_mtime)
00143 else SETIFMATCH(component,stat,st_ctime)
00144 else SETIFMATCH(component,stat,st_blocks)
00145 else SETIFMATCH(component,stat,st_blksize)
00146 #ifdef _UNICOS
00147 else SETIFMATCH(component,stat,st_acid)
00148 else SETIFMATCH(component,stat,st_count)
00149 else SETIFMATCH(component,stat,st_msize)
00150 else SETIFMATCH(component,stat,st_oblksize)
00151 else SETIFMATCH(component,stat,st_allocf)
00152 else SETIFMATCH(component,stat,st_cblks)
00153 else SETIFMATCH(component,stat,st_cbits)
00154 else SETIFMATCH(component,stat,st_dm_mode)
00155 else SETIFMATCH(component,stat,st_dm_port)
00156 else SETIFMATCH(component,stat,st_dm_state)
00157 else SETIFMATCH(component,stat,st_dm_status)
00158 else SETIFMATCH(component,stat,st_dm_mid)
00159 else SETIFMATCH(component,stat,st_dm_key)
00160 else SETIFMATCH(component,stat,st_hasacl)
00161 else SETIFMATCH(component,stat,st_hascomps)
00162 else SETIFMATCH(component,stat,st_slevel)
00163 else SETIFMATCH(component,stat,st_secflg)
00164 else SETIFMATCH(component,stat,st_intcls)
00165 else SETIFMATCH(component,stat,st_intcat)
00166 else SETIFMATCH(component,stat,st_site)
00167 else SETIFMATCH(component,stat,st_nindir)
00168 #endif
00169 else {
00170 *ierror = ENONAME;
00171 }
00172 break;
00173 case PXF_TMSBUF:
00174 SETIFMATCH(component,tms,tms_utime)
00175 else SETIFMATCH(component,tms,tms_stime)
00176 else SETIFMATCH(component,tms,tms_cutime)
00177 else SETIFMATCH(component,tms,tms_cstime)
00178 else {
00179 *ierror = ENONAME;
00180 }
00181 break;
00182 case PXF_GROUP:
00183 SETIFMATCH(component,group,gr_gid)
00184 else if (strcmp(component,"gr_nmem\0") == 0) {
00185
00186 gr_mem = ((struct group *)(pxfhand.pxfstructptr))->gr_mem;
00187 for(i = 0; gr_mem[i] != NULL; i++);
00188 *value = i;
00189 } else {
00190 *ierror = ENONAME;
00191 }
00192 break;
00193 case PXF_PASSWD:
00194 SETIFMATCH(component,passwd,pw_uid)
00195 else SETIFMATCH(component,passwd,pw_gid)
00196 else {
00197 *ierror = ENONAME;
00198 }
00199 break;
00200 case PXF_SIGACTION:
00201 SETIFMATCH(component,sigaction,sa_flags)
00202 #if 0
00203 else if (strcmp(component,"sa_handler\0") == 0) {
00204 *value =
00205 (_f_int)(((struct sigaction*)(pxfhand.pxfstructptr))->sa_handler);
00206 } else if (strcmp(component,"sa_mask\0") == 0) {
00207 #ifndef __mips
00208 *value = ((struct sigaction*)(pxfhand.pxfstructptr))->sa_mask;
00209 #else
00210 *value = ((struct sigaction*)(pxfhand.pxfstructptr))->sa_mask.__sigbits[0];
00211 #endif
00212 }
00213 #endif
00214 else {
00215 *ierror = ENONAME;
00216 }
00217 break;
00218 case PXF_TERMIOS:
00219 SETIFMATCH(component,termios,c_iflag)
00220 else SETIFMATCH(component,termios,c_oflag)
00221 else SETIFMATCH(component,termios,c_cflag)
00222 else SETIFMATCH(component,termios,c_lflag)
00223 else {
00224 *ierror = ENONAME;
00225 }
00226 break;
00227 default:
00228 *ierror = ENONAME;
00229 break;
00230 }
00231 free(component);
00232 }
00233
00234 #ifndef _UNICOS
00235 void
00236 pxfintget_(
00237 _f_int *jhandle,
00238 char *compnam,
00239 _f_int *value,
00240 _f_int *ierror,
00241 _f_int compnamlen)
00242 {
00243 _PXFINTGET( jhandle, _cptofcd(compnam,compnamlen),
00244 value, ierror);
00245 }
00246 #endif
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261 #ifdef _UNICOS
00262 void
00263 PXFINTSET(
00264 #else
00265 void
00266 _PXFINTSET(
00267 #endif
00268 _f_int *jhandle,
00269 _fcd compnam,
00270 _f_int *value,
00271 _f_int *ierror)
00272 {
00273 char *component;
00274 struct pxfhandle pxfhand;
00275
00276 *ierror = 0;
00277 component = _fc_acopy(compnam);
00278 if (component == NULL) {
00279 *ierror = ENOMEM;
00280 return;
00281 }
00282
00283 pxfhand = _pxfhandle_table_lookup(&_pxfhandle_table, *jhandle);
00284 if (pxfhand.pxfstructptr == NULL) {
00285 *ierror = EBADHANDLE;
00286 return;
00287 }
00288
00289 switch (pxfhand.pxftype) {
00290 case PXF_FLOCK:
00291
00292 GETIFMATCH(component,flock,l_type)
00293 else GETIFMATCH(component,flock,l_whence)
00294 else GETIFMATCH(component,flock,l_start)
00295 else GETIFMATCH(component,flock,l_len)
00296 #ifndef _LITTLE_ENDIAN
00297 else GETIFMATCH(component,flock,l_sysid)
00298 #endif
00299 else GETIFMATCH(component,flock,l_pid)
00300 else {
00301 *ierror = ENONAME;
00302 }
00303 break;
00304 case PXF_UTIMBUF:
00305 GETIFMATCH(component,utimbuf,actime)
00306 else GETIFMATCH(component,utimbuf,modtime)
00307 else {
00308 *ierror = ENONAME;
00309 }
00310 break;
00311 case PXF_SIGACTION:
00312 GETIFMATCH(component,sigaction,sa_flags)
00313 #if 0
00314 else if (strcmp(component,"sa_handler\0") == 0) {
00315 ((struct sigaction*)(pxfhand.pxfstructptr))->sa_handler =
00316 (void (*)()) *value;
00317 } else if (strcmp(component,"sa_mask\0") == 0) {
00318 #ifndef __mips
00319 ((struct sigaction*)(pxfhand.pxfstructptr))->sa_mask = *value;
00320 #else
00321 ((struct sigaction*)(pxfhand.pxfstructptr))->sa_mask.__sigbits[0] = *value;
00322 #endif
00323 }
00324 #endif
00325 else {
00326 *ierror = ENONAME;
00327 }
00328 break;
00329 case PXF_TERMIOS:
00330 GETIFMATCH(component,termios,c_iflag)
00331 else GETIFMATCH(component,termios,c_oflag)
00332 else GETIFMATCH(component,termios,c_cflag)
00333 else GETIFMATCH(component,termios,c_lflag)
00334 else {
00335 *ierror = ENONAME;
00336 }
00337 break;
00338 default:
00339 *ierror = ENONAME;
00340 break;
00341 }
00342 free(component);
00343 }
00344
00345
00346 #ifndef _UNICOS
00347 void
00348 pxfintset_(
00349 _f_int *jhandle,
00350 char *compnam,
00351 _f_int *value,
00352 _f_int *ierror,
00353 _f_int compnamlen)
00354 {
00355 _PXFINTSET( jhandle, _cptofcd(compnam,compnamlen),
00356 value, ierror);
00357 }
00358
00359 void
00360 pxfintset64_(
00361 _f_int8 *jhandle,
00362 char *compnam,
00363 _f_int8 *value,
00364 _f_int8 *ierror,
00365 _f_int compnamlen)
00366 {
00367 _f_int jhandledef;
00368 _f_int valuedef;
00369 _f_int ierrordef;
00370 jhandledef = *jhandle;
00371 valuedef = *value;
00372 ierrordef = *ierror;
00373 _PXFINTSET( &jhandledef, _cptofcd(compnam,compnamlen),
00374 &valuedef, &ierrordef);
00375 }
00376
00377 void
00378 pxfintset32_(
00379 _f_int4 *jhandle,
00380 char *compnam,
00381 _f_int4 *value,
00382 _f_int4 *ierror,
00383 _f_int compnamlen)
00384 {
00385 _PXFINTSET( jhandle, _cptofcd(compnam,compnamlen),
00386 value, ierror);
00387 }
00388 #endif
00389
00390 #ifdef _CRAYMPP
00391 void
00392 _PXFINTSET32(
00393 _f_int4 *jhandle,
00394 _fcd compnam,
00395 _f_int4 *value,
00396 _f_int4 *ierror)
00397 {
00398 _f_int jhandle8;
00399 _f_int value8;
00400 _f_int ierror8;
00401 jhandle8 = *jhandle;
00402 value8 = *value;
00403 ierror8 = *ierror;
00404 _PXFINTSET( &jhandle8, compnam, &value8, &ierror8);
00405 }
00406 #endif