| 1 | /* psapselect.c - PPM: map descriptors */ |
| 2 | |
| 3 | #ifndef lint |
| 4 | static char *rcsid = "$Header: /f/osi/psap2/RCS/psapselect.c,v 7.1 91/02/22 09:37:53 mrose Interim $"; |
| 5 | #endif |
| 6 | |
| 7 | /* |
| 8 | * $Header: /f/osi/psap2/RCS/psapselect.c,v 7.1 91/02/22 09:37:53 mrose Interim $ |
| 9 | * |
| 10 | * |
| 11 | * $Log: psapselect.c,v $ |
| 12 | * Revision 7.1 91/02/22 09:37:53 mrose |
| 13 | * Interim 6.8 |
| 14 | * |
| 15 | * Revision 7.0 89/11/23 22:14:36 mrose |
| 16 | * Release 6.0 |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | /* |
| 21 | * NOTICE |
| 22 | * |
| 23 | * Acquisition, use, and distribution of this module and related |
| 24 | * materials are subject to the restrictions of a license agreement. |
| 25 | * Consult the Preface in the User's Manual for the full terms of |
| 26 | * this agreement. |
| 27 | * |
| 28 | */ |
| 29 | |
| 30 | |
| 31 | /* LINTLIBRARY */ |
| 32 | |
| 33 | #include <stdio.h> |
| 34 | #include <signal.h> |
| 35 | #include "ppkt.h" |
| 36 | |
| 37 | /* \f map presentation descriptors for select() */ |
| 38 | |
| 39 | int PSelectMask (sd, mask, nfds, pi) |
| 40 | int sd; |
| 41 | fd_set *mask; |
| 42 | int *nfds; |
| 43 | struct PSAPindication *pi; |
| 44 | { |
| 45 | SBV smask; |
| 46 | register struct psapblk *pb; |
| 47 | struct SSAPindication sis; |
| 48 | register struct SSAPabort *sa = &sis.si_abort; |
| 49 | |
| 50 | missingP (mask); |
| 51 | missingP (nfds); |
| 52 | missingP (pi); |
| 53 | |
| 54 | smask = sigioblock (); |
| 55 | |
| 56 | if ((pb = findpblk (sd)) == NULL) { |
| 57 | (void) sigiomask (smask); |
| 58 | return psaplose (pi, PC_PARAMETER, NULLCP, |
| 59 | "invalid presentation descriptor"); |
| 60 | } |
| 61 | |
| 62 | if (SSelectMask (pb -> pb_fd, mask, nfds, &sis) == NOTOK) |
| 63 | switch (sa -> sa_reason) { |
| 64 | case SC_WAITING: |
| 65 | (void) sigiomask (smask); |
| 66 | return psaplose (pi, PC_WAITING, NULLCP, NULLCP); |
| 67 | |
| 68 | default: |
| 69 | (void) ss2pslose (pb, pi, "SSelectMask", sa); |
| 70 | freepblk (pb); |
| 71 | (void) sigiomask (smask); |
| 72 | return NOTOK; |
| 73 | } |
| 74 | |
| 75 | (void) sigiomask (smask); |
| 76 | |
| 77 | return OK; |
| 78 | } |