home *** CD-ROM | disk | FTP | other *** search
- /****************************************/
-
- /* IsThereDTPrinter.c */
- /* Author: Shemin Gau, IP */
- /* Revision History: 02/03/94 */
-
- /****************************************/
-
-
- #include <Memory.h>
- #include <String.h>
- #include <Resources.h>
- #include <Types.h>
- #include <OSUtils.h>
- #include <ToolUtils.h>
- #include <Errors.h>
-
-
- OSErr SetContextResult(void* theData, Size theSize, Ptr* outMessage, Size* outSize);
-
-
- pascal OSErr main(Str255 msg, Size inSize, void* outMessage, Size* outSize, Handle ignoreMe)
- {
- Handle my_hndl;
- short old_file = CurResFile();
- char *str_holder = '\0';
- OSErr my_err = noErr;
- // This string is taken out per Susan Torres's request
- //char *s2 = "PDD Maker GX";
- char *s2;
- short i;
- Boolean the_result = true;
- Boolean result = false;
-
-
- UseResFile(0);
-
- //It is not a right way to pass the id directly. But it's a unique number, I did it anyway.
-
- if (my_hndl = (Handle)Get1Resource('STR ', -8188)) {
- BlockMove(*my_hndl, str_holder, (long)(**my_hndl + 1));
- } else {
- my_err = ResError();
- }
- ReleaseResource((Handle)my_hndl);
- UseResFile(old_file);
-
- //This one is really tricky, the handle is actually a pointer to the 'STR ',
- //plus a control character.
-
- s2 = p2cstr(msg);
- //strncpy(s1, str_holder + 1, (size_t)(12)); /* I can't find the strncpy function prototype in Think C */
- for (i = 0; i < 12; i++) {
- if (str_holder[i + 1] != s2[i]) {
- the_result = false;
- break;
- }
- }
-
- if ((the_result) && (my_err == noErr)) {
- result = true;
- my_err = SetContextResult(&result, sizeof(Boolean), outMessage, outSize);
- return(my_err);
- } else {
- //return(1); /* False */
- my_err = SetContextResult(&result, sizeof(Boolean), outMessage, outSize);
- return(my_err);
- }
- }
-
-
- OSErr SetContextResult(void* theData, Size theSize, Ptr* outMessage, Size* outSize)
- {
- Ptr p;
-
- if (p = NewPtr(theSize)) {
- BlockMove(theData, p, theSize);
-
- *outSize = theSize;
- *outMessage = p;
-
- return(noErr);
- } else {
- return(MemError());
- }
- }
-
-