2 ** OpenURL - MUI preferences for openurl.library
4 ** Written by Troels Walsted Hansen <troels@thule.no>
5 ** Placed in the public domain.
8 ** - Alfonso Ranieri <alforan@tin.it>
9 ** - Stefan Kost <ensonic@sonicpulse.de>
11 ** Ported to OS4 by Alexandre Balaban <alexandre@balaban.name>
21 #include <proto/exec.h>
23 /***********************************************************************/
25 #define CATNAME "OpenURL.catalog"
27 struct CatCompArrayType
* privateCatCompArray
= NULL
;
29 /***********************************************************************/
31 static struct Catalog
*
32 openCatalog(STRPTR name
,ULONG minVer
,ULONG minRev
)
36 if (cat
= OpenCatalogA(NULL
,name
,NULL
))
38 ULONG ver
= cat
->cat_Version
;
40 if ((ver
<minVer
) ? TRUE
: ((ver
==minVer
) ? (cat
->cat_Revision
<minRev
) : FALSE
))
50 /***********************************************************************/
55 if (LocaleBase
= (struct LocaleBase
*)OpenLibrary("locale.library",36))
57 #if defined(__amigaos4__)
58 if ( NULL
== (ILocale
= (struct LocaleIFace
*)GetInterface((struct Library
*)LocaleBase
, "main", 1L, NULL
)) ) return;
61 // to be on the safe side, we initialize our CatCompArray to point on the CatComp's one
62 privateCatCompArray
= (struct CatCompArrayType
*)CatCompArray
;
64 if (g_cat
= openCatalog(CATNAME
,7,0))
66 struct CatCompArrayType
*cca
;
69 // OK we managed to open the catalog, now go to initialize our own CatComArray
70 privateCatCompArray
= (struct CatCompArrayType
*) AllocVec( sizeof(CatCompArray
), MEMF_ANY
);
71 if( privateCatCompArray
)
73 // ok we have allocated our memory, go for initialization : we copy the whole memory into it
74 CopyMem(CatCompArray
,privateCatCompArray
,sizeof(CatCompArray
));
76 for (cnt
= (sizeof(CatCompArray
)/sizeof(struct CatCompArrayType
))-1, cca
= (struct CatCompArrayType
*)privateCatCompArray
+cnt
;
82 if (s
= GetCatalogStr(g_cat
,cca
->cca_ID
,cca
->cca_Str
)) cca
->cca_Str
= (STRPTR
)s
;
90 /***********************************************************************/
95 if( privateCatCompArray
!= CatCompArray
)
97 FreeVec( privateCatCompArray
);
99 privateCatCompArray
= NULL
;
102 /***********************************************************************/
107 struct CatCompArrayType
*cca
;
110 for (cnt
= (sizeof(CatCompArray
)/sizeof(struct CatCompArrayType
))-1, cca
= (struct CatCompArrayType
*)privateCatCompArray
+cnt
;
112 cnt
--, cca
--) if (cca
->cca_ID
==id
) return cca
->cca_Str
;
117 /***********************************************************************/
120 localizeStrings(STRPTR
*s
)
122 for (; *s
; s
++) *s
= getString((ULONG
)*s
);
125 /***********************************************************************/
128 localizeNewMenu(struct NewMenu
*nm
)
130 for ( ; nm
->nm_Type
!=NM_END
; nm
++)
131 if (nm
->nm_Label
!=NM_BARLABEL
)
132 nm
->nm_Label
= (STRPTR
)getString((ULONG
)nm
->nm_Label
);
135 /***********************************************************************/
138 getKeyChar(UBYTE
*string
,ULONG id
)
142 if (!string
) string
= (UBYTE
*)getString(id
);
144 for (; *string
&& *string
!='_'; string
++);
145 if (*string
++) res
= ToLower(*string
);
150 /***********************************************************************/