home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Mac OS / Apple Guide / Engineering / Context Check Modules / PDD Maker CC / IsItPDDMaker.c next >
Encoding:
C/C++ Source or Header  |  1994-06-09  |  2.0 KB  |  88 lines  |  [TEXT/KAHL]

  1. /****************************************/
  2.     
  3. /*    IsThereDTPrinter.c                    */
  4. /*    Author:             Shemin Gau, IP    */
  5. /*    Revision History:    02/03/94        */
  6.  
  7. /****************************************/
  8.  
  9.  
  10. #include <Memory.h>
  11. #include <String.h>
  12. #include <Resources.h>
  13. #include <Types.h>
  14. #include <OSUtils.h>
  15. #include <ToolUtils.h>
  16. #include <Errors.h>
  17.  
  18.  
  19. OSErr SetContextResult(void* theData, Size theSize, Ptr* outMessage, Size* outSize);
  20.  
  21.  
  22. pascal OSErr main(Str255 msg, Size inSize, void* outMessage, Size* outSize, Handle ignoreMe)
  23. {        
  24.     Handle        my_hndl;    
  25.     short        old_file = CurResFile();
  26.     char        *str_holder = '\0';
  27.     OSErr        my_err = noErr;
  28.     // This string is taken out per Susan Torres's request
  29.     //char        *s2 = "PDD Maker GX";
  30.     char        *s2;
  31.     short        i;    
  32.     Boolean     the_result = true;
  33.     Boolean        result = false;
  34.     
  35.         
  36.     UseResFile(0);
  37.     
  38.     //It is not a right way to  pass the id directly. But it's a unique number, I did it anyway.
  39.     
  40.     if (my_hndl = (Handle)Get1Resource('STR ', -8188)) {
  41.         BlockMove(*my_hndl, str_holder, (long)(**my_hndl + 1));
  42.     } else {
  43.         my_err = ResError();
  44.     }
  45.     ReleaseResource((Handle)my_hndl);
  46.     UseResFile(old_file);
  47.     
  48.     //This one is really tricky, the handle is actually a pointer to the 'STR ',
  49.     //plus a control character.
  50.     
  51.     s2 = p2cstr(msg);
  52.     //strncpy(s1, str_holder + 1, (size_t)(12));    /* I can't find the strncpy function prototype in Think C */
  53.     for (i = 0; i < 12; i++) {
  54.         if (str_holder[i + 1] != s2[i]) {
  55.             the_result = false;
  56.             break;
  57.         }
  58.     }
  59.     
  60.     if ((the_result) && (my_err == noErr)) {
  61.         result = true;
  62.         my_err = SetContextResult(&result, sizeof(Boolean), outMessage, outSize);
  63.         return(my_err);
  64.     } else {
  65.         //return(1);        /* False */
  66.         my_err = SetContextResult(&result, sizeof(Boolean), outMessage, outSize);
  67.         return(my_err);
  68.     }
  69. }
  70.  
  71.  
  72. OSErr SetContextResult(void* theData, Size theSize, Ptr* outMessage, Size* outSize)
  73. {
  74.     Ptr    p;
  75.     
  76.     if (p = NewPtr(theSize)) {
  77.         BlockMove(theData, p, theSize);
  78.         
  79.         *outSize = theSize;
  80.         *outMessage    = p;
  81.         
  82.         return(noErr);
  83.     } else {
  84.         return(MemError());
  85.     }
  86. }
  87.  
  88.