home *** CD-ROM | disk | FTP | other *** search
- /*
- * ProIcon: Code resource to open a resource file.
- *
- * This code resource will appear under the resource type 'CODE', ID 1000,
- * name "OpenResFile". Invoke with:
- *
- * resFile := callout("CODE","OpenResFile", s)
- *
- * where s is the pathname of a resource file.
- *
- * resFile is a simple integer. The function fails if the file could
- * not be opened, or returns error 103 if s is not a string.
- */
-
- #include "ProIcon.h"
- pointer memcopy(char *to, char *from, word n);
-
- pascal dptr main(dargv, argc, ip, callback)
- dptr dargv;
- short int argc;
- short int *ip;
- pointer (*callback)();
- {
- char sbuf[MaxCvtLen+1];
- int resFile;
-
- if (argc != 1) /* fail if wrong number of arguments */
- RunErr(Err103, NULL);
-
- switch (cvstr(&Arg1, &sbuf[1])) {
- case Cvt:
- break;
- case NoCvt:
- memcopy(&sbuf[1], StrLoc(Arg1),
- StrLen(Arg1) > MaxCvtLen ? MaxCvtLen : StrLen(Arg1));
- break;
- default:
- RunErr(Err103, &Arg1); /* string expected as third argument */
- }
- sbuf[0] = StrLen(Arg1); /* create Pascal-style string */
-
- if ((resFile = OpenResFile((StringPtr)sbuf)) == -1)
- Fail;
- MakeInt(resFile, &Arg0);
-
- Return;
- }
-
-
- pointer memcopy(to, from, n)
- register char *to, *from;
- register word n;
- {
- register char *p = to;
-
- while (--n >= 0)
- *to++ = *from++;
-
- return (pointer)p;
- }
-
-