static PyObject *Res_GetIndResource(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Handle _rv; ResType theType; short index; #ifndef GetIndResource PyMac_PRECHECK(GetIndResource); #endif if (!PyArg_ParseTuple(_args, "O&h", PyMac_GetOSType, &theType, &index)) return NULL; _rv = GetIndResource(theType, index); { OSErr _err = ResError(); if (_err != noErr) return PyMac_Error(_err); } _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; }
long iniMacros(void) { #ifndef MACINTOSH int i; for (i = 0; macros[i].name; i++) { if (!installMacro(macros[i].text, macros[i].name, strlen(macros[i].text))) { goto errorExit; } } #else /*MACINTOSH*/ Integer id = IDBASE, id1; Integer i, count = CountResources(MACROTYPE); char *prefix = NAMEPREFIX; Integer prefixLength = strlen(prefix); Str255 resName; char *name = (char *) resName; ResType type; unsigned char **text; /* examine all resources of the wanted type If the name starts with prefix, install it as long as it is not the name of the dummy last macro */ for(i=1; i<= count; i++) { text = (unsigned char **) GetIndResource(MACROTYPE, i); if (ResError() != noErr) { break; } GetResInfo((Handle) text, &id1, &type, resName); if (ResError() != noErr) { goto errorExit; } PtoCstr((unsigned char *) name); if (strncmp(prefix, name, prefixLength) == 0 && strcmp(name + prefixLength, ENDNAME) != 0) { HLock((Handle) text); /* first two characters of *text give number of characters */ if (!installMacro((char *) (*text) + 2, name + prefixLength, (*text)[0] * 256 + (*text)[1])) { goto errorExit; } HUnlock((Handle) text); } ReleaseResource((Handle) text); } /*while(1)*/ #endif /*MACINTOSH*/ return (1); errorExit: return (0); } /*iniMacros()*/