home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / apps.to.go / DTS.Lib / PPC.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-04  |  2.2 KB  |  93 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** Program:        DTS.Lib
  5. ** File:        PPC.c
  6. ** Written by:  Eric Soldan
  7. **
  8. ** Copyright © 1992 Apple Computer, Inc.
  9. ** All rights reserved.
  10. **
  11. ** This is the only PPC code we have so far for this file.  Who knows if we'll do more...
  12. */
  13.  
  14. /* You may incorporate this sample code into your applications without
  15. ** restriction, though the sample code has been provided "AS IS" and the
  16. ** responsibility for its operation is 100% yours.  However, what you are
  17. ** not permitted to do is to redistribute the source as "DSC Sample Code"
  18. ** after having made changes. If you're going to re-distribute the source,
  19. ** we require that you make it clear in the source that the code was
  20. ** descended from Apple Sample Code, but that you've made changes. */
  21.  
  22.  
  23.  
  24. /*****************************************************************************/
  25.  
  26.  
  27.  
  28. #include "PPC.h"
  29. #include "Utilities.h"
  30.  
  31.  
  32.  
  33. /*****************************************************************************/
  34.  
  35.  
  36.  
  37. OSErr    DoIPCListPorts(short *sindx, short *reqCount, short *actCount,
  38.                        LocationNamePtr  loc,
  39.                        PortInfoArrayPtr retInfo,
  40.                        PPCFilterProcPtr filter)
  41. {
  42.     OSErr                err;
  43.     IPCListPortsPBRec    lpPBRec;
  44.     PPCPortRec            portRec;
  45.     PortInfoRec            info;
  46.     Boolean                keeper;
  47.     char                *cptr;
  48.     short                i;
  49.  
  50.     *actCount = 0;
  51.  
  52.     cptr = (char *)&lpPBRec;
  53.     for (i = 0; i < sizeof(IPCListPortsPBRec); ++i) cptr[i] = 0;
  54.  
  55.     portRec.nameScript = 0;
  56.     pcpy(portRec.name, "\p=");                    /* Match all names. */
  57.  
  58.     portRec.portKindSelector = ppcByString;
  59.     pcpy(portRec.u.portTypeStr, "\p=");            /* Match all names. */
  60.  
  61.     lpPBRec.requestCount = 1;
  62.     lpPBRec.portName     = &portRec;
  63.     lpPBRec.locationName = loc;
  64.     lpPBRec.bufferPtr    = &info;
  65.  
  66.     for (; *actCount < *reqCount;) {
  67.  
  68.         lpPBRec.startIndex = *sindx;
  69.         err = IPCListPortsSync(&lpPBRec);
  70.         if (err) return(err);            /* Call IPCListPorts synchronously. */
  71.  
  72.         ++*sindx;    /* We read it once.  Make sure we don't read it again. */
  73.  
  74.         if (!lpPBRec.actualCount) {        /* If this happens, we hit end of list. */
  75.             *reqCount = 0;                /* This is a flag stating that all are read. */
  76.             return(noErr);
  77.         }
  78.  
  79.         keeper = true;
  80.         if (filter)
  81.             keeper = (*filter)(loc, &info);
  82.         if (keeper) {
  83.             retInfo[*actCount] = info;
  84.             ++*actCount;
  85.         }
  86.     }
  87.  
  88.     return(noErr);
  89. }
  90.  
  91.  
  92.  
  93.