use the new flexcat's source description file
[AROS.git] / tools / flexcat / src / sd / AutoC_c.sd
blobb957f8490be34c18185a8c98a61004638bd84311
1 ##rem $Id: AutoC_c.sd 253 2014-02-18 11:15:58Z damato $
2 ##stringtype C
3 ##shortstrings
5 /****************************************************************
7    This file was created automatically by `%fv'
8    from "%f0".
10    Do NOT edit by hand!
12 ****************************************************************/
14 /****************************************************************
15     This file uses the auto initialization features of
16     Dice, gcc and SAS/C, respectively.
18     Dice does this by using the __autoinit and __autoexit
19     keywords, whereas SAS/C uses names beginning with _STI
20     or _STD, respectively. gcc uses the asm() instruction
21     to emulate C++ constructors and destructors.
23     Using this file you don't have *all* the benefits of
24     locale.library (no Locale or Language arguments are
25     supported when opening the catalog). However, these are
26     *very* rarely used, so this should be sufficient for most
27     applications.
29     If you really need all the bells and whistles or you
30     are using another compiler, you should use the source
31     description C_c_V21.sd instead.
32 ****************************************************************/
35     Include files and compiler specific stuff
38 #include <libraries/locale.h>
40 #if defined(__SASC)  ||  defined(_DCC)
41 #include <proto/exec.h>
42 #include <proto/locale.h>
43 typedef struct Library LocaleBase_t;
44 #elif defined(__GNUC__)
45 #include <inline/exec.h>
46 #include <inline/locale.h>
47 typedef struct LocaleBase LocaleBase_t;
48 #else
49 #error "I don't know how to handle your compiler."
50 #endif
52 #if defined(__SASC)
53 #define __autoinit
54 #define __autoexit
55 #endif
57 #if defined(__GNUC__)
58 #define __autoinit __attribute__ ((constructor))
59 #define __autoexit __attribute__ ((destructor))
60 #endif
64     Variables
66 struct FC_Type
67 {   LONG   ID;
68     STRPTR Str;
70 const struct FC_Type _%i = { %d, (STRPTR) %s };
72 static struct Catalog *%b_Catalog = NULL;
74 LocaleBase_t *LocaleBase;
80 STATIC __autoinit VOID _STIOpenCatalog(VOID)
82   {
83     STATIC const struct TagItem tags[] =
84       {
85         { OC_BuiltInLanguage, (ULONG) %l },
86         { OC_Version, %v },
87         { TAG_DONE, 0 }
88       };
89     if ((LocaleBase = (LocaleBase_t *)
90                       OpenLibrary((STRPTR) "locale.library", 38)))
91     {
92       %b_Catalog = OpenCatalogA(NULL, (STRPTR) "%b.catalog",
93                                 (struct TagItem *) tags);
94     }
95   }
99 STATIC __autoexit VOID _STDCloseCatalog(VOID)
101   {
102     if (LocaleBase)
103       {
104         CloseCatalog(%b_Catalog);
105         %b_Catalog = NULL;
106         CloseLibrary((struct Library *) LocaleBase);
107       }
108   }
112 STRPTR GetString(struct FC_Type *fcstr)
114   {
115     STRPTR defaultstr;
116     LONG strnum;
118     strnum = fcstr->ID;
119     defaultstr = fcstr->Str;
121     return(%b_Catalog ? GetCatalogStr(%b_Catalog, strnum, defaultstr) :
122                         defaultstr);
123   }