/* * PXFCFGETISPEED -- get input baud rate * PXFCFSETISPEED -- set input baud rate * PXFCFGETOSPEED -- get output baud rate * PXFCFSETOSPEED -- set output baud rate * (section 7.1.3 of Posix 1003.9-1992) * * Synopsis: * * SUBROUTINE PXFCFGETISPEED(jtermios, iospeed, ierror) * INTEGER jtermios, iospeed, ierror * * SUBROUTINE PXFCFSETISPEED(jtermios, ispeed, ierror) * INTEGER jtermios, ispeed, ierror * * SUBROUTINE PXFCFGETOSPEED(jtermios, iospeed, ierror) * INTEGER jtermios, iospeed, ierror * * SUBROUTINE PXFCFSETOSPEED(jtermios, ispeed, ierror) * INTEGER jtermios, ispeed, ierror * * Description: * * The PXFCF...SPEED routines use the c functions to get or set the * baud rates in the termios structure. Symbolic names for the baud * rates can be obtained through calls to PXFCONST. * * The arguments are: * * jtermios - default integer input variable containing a handle * created by PXFSTRUCTCREATE('termios',...). * ispeed - default input integer variable for a baud rate. * iospeed - default output integer variable specifying a baud * rate. * ierror - default integer output variable that contains zero * if the operation was successful or nonzero if the * operation was not successful. * * PXFCF...SPEED routines may return one of the following error values: * No errors are returned for bad baud rates. The PXFCFSETISPEED and * PXFCFSETOSPEED return 0 if successful; otherwise, they return -1. * * EBADHANDLE The jtermios argument is invalid. * * EINVAL Problems occurred with the baud rate. * */ #include <fortran.h> #include <liberrno.h> #include <string.h> #include <sys/termios.h> #include <termios.h> #include "pxfstruct.h" #include "table.h" #ifdef _UNICOS void PXFCFGETISPEED( #else /* _UNICOS */ void pxfcfgetispeed_( #endif /* _UNICOS */ _f_int *jtermios, _f_int *iospeed, _f_int *ierror) { speed_t stat; struct pxfhandle pxfhand; struct termios *trmios; *ierror = 0; *iospeed = 0; pxfhand = _pxfhandle_table_lookup(&_pxfhandle_table, *jtermios); if (pxfhand.pxfstructptr == NULL || pxfhand.pxftype != PXF_TERMIOS) { *ierror = EBADHANDLE; return; } trmios = pxfhand.pxfstructptr; if (stat = cfgetispeed(trmios) == -1) *ierror = EINVAL; else *iospeed = stat; return; }
/* * PXFSIGSIGPROCMASK -- Examine and change blocked signals. * (section 3.3.5 of Posix 1003.9-1992) * * Synopsis: * * SUBROUTINE PXFSIGPROCMASK(ihow, jsigset, josigset, ierror) * INTEGER ihow, jsigset, josigset, ierror * * Where: * * ihow - default integer input variable containing * the manner in which the set is changed. The * possible values are: * * SIG_BLOCK - add to current mask set * SIG_UNBLOCK - delete from current mask set * SIG_SETMASK - Replace current mask set * * This argument is ignored if josigset is NULL. * If ihow is zero, the current set is not changed. * * On IRIX systems, the value may also be set to * * SIG_NOP - do not alter current mask set * * This value is equivalent to providing a NULL * handle for josigset. * * jsigset - default integer input variable containing a * handle created by PXFSTRUCTCREATE('sigset',...) * If nonzero, the handle points to a set of signals * that can be used to change the currently blocked * set. * josigset - default integer output variable containing a * handle created by PXFSTRUCTCREATE('sigset',...) * If nonzero, the handle will be set to the * currently blocked signal set. * If zero, the currently blocked signal set * will not be changed and the value of ihow * is ignored. * ierror - default integer output variable containing * status: * * zero - PXFSIGPROCMASK was successful. * * nonzero - PXFSIGPROCMASK was not successful. * * PXFSIGPROCMASK may return one of the following error values: * * EFAULT The jsigset or josigset argument points outside * the allocated space. * * EINVAL The value of ihow is an invalid or unsupported * operation. * * EBADHANDLE The jsigset argument is invalid. * * DESCRIPTION: * * Subroutine procedure PXFSIGPROCMASK uses sigprocmask() function * to examine and change the currently blocked signal set. * */ #include <errno.h> #include <fortran.h> #include <liberrno.h> #include <string.h> #include <sys/signal.h> #include "pxfstruct.h" #include "pxfstructtable.h" #include "table.h" #ifndef _UNICOS #include <stddef.h> #endif #ifdef _UNICOS void PXFSIGPROCMASK( #else /* _UNICOS */ void _PXFSIGPROCMASK( #endif /* _UNICOS */ _f_int *ihow, _f_int *jsigset, _f_int *josigset, _f_int *ierror ) { int stat; sigset_t amask, bmask; sigset_t *amaskp, *bmaskp; struct pxfhandle pxfhand1; struct pxfhandle pxfhand2; *ierror = 0; if (*jsigset != 0) { pxfhand1 = _pxfhandle_table_lookup(&_pxfhandle_table, *jsigset); if (pxfhand1.pxftype != PXF_SIGSET) { *ierror = EBADHANDLE; return; } amask = ((struct sig_set *)(pxfhand1.pxfstructptr))->samask; amaskp = &amask; } else amaskp = NULL; if (*josigset != 0) { pxfhand2 = _pxfhandle_table_lookup(&_pxfhandle_table, *josigset); if (pxfhand2.pxftype != PXF_SIGSET) { *ierror = EBADHANDLE; return; } bmask = ((struct sig_set *)(pxfhand2.pxfstructptr))->samask; bmaskp = &bmask; } else bmaskp = NULL; if ((stat = (_f_int) sigprocmask(*ihow, amaskp, bmaskp)) == -1) *ierror = errno; else { if (bmaskp) ((struct sig_set *)(pxfhand2.pxfstructptr))->samask = bmask; } return; }
void _PXFUNAME( #endif _f_int *JUNAMBUF, /* handle for struct utsname */ _f_int *IERROR) /* error status */ { struct utsname *utn; int errsts = 0; struct pxfhandle pxfhand; pxfhand = _pxfhandle_table_lookup(&_pxfhandle_table, *JUNAMBUF); if (pxfhand.pxfstructptr == NULL || pxfhand.pxftype != PXF_UNAMBUF) { *IERROR = EBADHANDLE; return; } utn = pxfhand.pxfstructptr; if (uname (utn) == -1) errsts = errno; *IERROR = errsts; }
/* * PXFSIGSIGPENDING -- Examine pending signals. * (section 3.3.6 of Posix 1003.9-1992) * * Synopsis: * * SUBROUTINE PXFSIGPENDING(jsigset, ierror) * INTEGER jsigset, ierror * * Where: * * jsigset is a default integer input variable containing a * handle created by PXFSTRUCTCREATE('sigset',...) * ierror is a default integer output variable containing * status: * zero - PXFSIGPENDING was successful. * * nonzero - PXFSIGPENDING was not successful. * * DESCRIPTION: * * Subroutine procedure PXFSIGPENDING uses sigpending() function * to retrieve the signal set in the handle jsigset. * * PXFSIGPENDING may return one of the following error values: * * EFAULT The jsigset argument points outside the * allocated space. * * EBADHANDLE The jsigset argument is invalid. * */ #include <errno.h> #include <fortran.h> #include <liberrno.h> #include <string.h> #include <sys/signal.h> #include "pxfstruct.h" #include "pxfstructtable.h" #include "table.h" #ifndef _UNICOS #include <stddef.h> #endif #ifdef _UNICOS void PXFSIGPENDING( #else /* _UNICOS */ void _PXFSIGPENDING( #endif /* _UNICOS */ _f_int *jsigset, _f_int *ierror ) { int stat; sigset_t mask; struct pxfhandle pxfhand; *ierror = 0; pxfhand = _pxfhandle_table_lookup(&_pxfhandle_table, *jsigset); if (pxfhand.pxfstructptr == NULL || pxfhand.pxftype != PXF_SIGSET) { *ierror = EBADHANDLE; return; } mask = ((struct sig_set *)(pxfhand.pxfstructptr))->samask; if ((stat = (_f_int) sigpending(&mask)) == -1) *ierror = errno; else ((struct sig_set *)(pxfhand.pxfstructptr))->samask = mask; return; }
void _PXFGETPWNAM( #endif _fcd NAME, _f_int *ILEN, _f_int *JPASSWD, _f_int *IERROR ) { int cilen; char *cname; struct passwd *passwdsrc, passwdtemp, *cjpasswd; struct pxfhandle pxfhand; cilen = *ILEN; pxfhand = _pxfhandle_table_lookup(&_pxfhandle_table, *JPASSWD); if (pxfhand.pxfstructptr == NULL || pxfhand.pxftype != PXF_PASSWD) { *IERROR = EBADHANDLE; return; } cjpasswd = pxfhand.pxfstructptr; /* check for invalid range error on ILEN. */ if (cilen < 0 || cilen > _fcdlen(NAME)) { *IERROR = EINVAL; } else { if (cilen == 0) { /* * If length is zero, user wants trailing blanks stripped. * Otherwise, malloc memory and copy the string adding a * NULL terminator. */ cname = _fc_acopy(NAME); } else { cname = (char *) malloc (cilen + 1); if (cname != NULL) { (void)memcpy(cname, _fcdtocp(NAME), cilen); cname[cilen] ='\0'; } else { *IERROR = ENOMEM; return; } } /* make call to getpwnam */ if ((passwdsrc = getpwnam(cname)) != NULL) { free(cname); /* copy the structures components since static storage is used */ /* component: pw_name (login name) */ passwdtemp.pw_name = (char *) malloc((strlen(passwdsrc->pw_name)+1)*sizeof(char)); if (passwdtemp.pw_name == NULL) { *IERROR = ENOMEM; return; } (void)strcpy(passwdtemp.pw_name, passwdsrc->pw_name); /* component: pw_uid (user ID) */ passwdtemp.pw_uid = passwdsrc->pw_uid; /* component: pw_gid (group ID) */ passwdtemp.pw_gid = passwdsrc->pw_gid; /* component: pw_dir (default login directory) */ passwdtemp.pw_dir = (char *) malloc((strlen(passwdsrc->pw_dir)+1)*sizeof(char)); if (passwdtemp.pw_dir == NULL) { *IERROR = ENOMEM; free(passwdtemp.pw_name); return; } (void)strcpy(passwdtemp.pw_dir, passwdsrc->pw_dir); /* component: pw_shell (default login shell) */ passwdtemp.pw_shell = (char *) malloc((strlen(passwdsrc->pw_shell)+1)*sizeof(char)); if (passwdtemp.pw_shell == NULL) { *IERROR = ENOMEM; free(passwdtemp.pw_name); free(passwdtemp.pw_dir); return; } (void)strcpy(passwdtemp.pw_shell, passwdsrc->pw_shell); /* components not supported in Posix 1003.9-1992, but supported in target OSes */ /* component: pw_passwd (encrypted password) */ passwdtemp.pw_passwd = (char *)malloc((strlen(passwdsrc->pw_passwd)+1)*sizeof(char)); if (passwdtemp.pw_passwd == NULL) { *IERROR = ENOMEM; free(passwdtemp.pw_name); free(passwdtemp.pw_dir); free(passwdtemp.pw_shell); return; } (void)strcpy(passwdtemp.pw_passwd, passwdsrc->pw_passwd); #ifndef _LITTLE_ENDIAN /* component: pw_age (password age) */ passwdtemp.pw_age = (char *)malloc((strlen(passwdsrc->pw_age)+1)*sizeof(char)); if (passwdtemp.pw_age == NULL) { *IERROR = ENOMEM; free(passwdtemp.pw_name); free(passwdtemp.pw_dir); free(passwdtemp.pw_shell); free(passwdtemp.pw_passwd); return; } (void)strcpy(passwdtemp.pw_age, passwdsrc->pw_age); /* component: pw_comment (comment) */ passwdtemp.pw_comment = (char *)malloc((strlen(passwdsrc->pw_comment)+1)*sizeof(char)); if (passwdtemp.pw_comment == NULL) { *IERROR = ENOMEM; free(passwdtemp.pw_name); free(passwdtemp.pw_dir); free(passwdtemp.pw_shell); free(passwdtemp.pw_passwd); free(passwdtemp.pw_age); return; } (void)strcpy(passwdtemp.pw_comment, passwdsrc->pw_comment); #endif /* not _LITTLE_ENDIAN */ /* component: pw_gecos */ passwdtemp.pw_gecos = (char *)malloc((strlen(passwdsrc->pw_gecos)+1)*sizeof(char)); if (passwdtemp.pw_gecos == NULL) { *IERROR = ENOMEM; free(passwdtemp.pw_name); free(passwdtemp.pw_dir); free(passwdtemp.pw_shell); free(passwdtemp.pw_passwd); #ifndef _LITTLE_ENDIAN free(passwdtemp.pw_age); #endif /* not _LITTLE_ENDIAN */ free(passwdtemp.pw_gecos); return; } (void)strcpy(passwdtemp.pw_gecos, passwdsrc->pw_gecos); } else { *IERROR = errno; free(cname); return; } } /* free all components for the jpasswd handle. NOTE: free() as defined in ANSI C * checks for a NULL pointer so this extra check does not need to be performed. */ free(cjpasswd->pw_name); free(cjpasswd->pw_passwd); #ifndef _LITTLE_ENDIAN free(cjpasswd->pw_age); free(cjpasswd->pw_comment); #endif /* not _LITTLE_ENDIAN */ free(cjpasswd->pw_gecos); free(cjpasswd->pw_dir); free(cjpasswd->pw_shell); *cjpasswd = passwdtemp; }