The MinGW.org Installation Manager Tool
Revision | 8252c763c9c961cf4fd02437396950538424ead9 (tree) |
---|---|
Time | 2013-10-18 13:11:30 |
Author | Keith Marshall <keithmarshall@user...> |
Commiter | Keith Marshall |
Implement foundation for future NLS enabled diagnostics.
@@ -1,3 +1,17 @@ | ||
1 | +2013-10-18 Keith Marshall <keithmarshall@users.sourceforge.net> | |
2 | + | |
3 | + Implement foundation for future NLS enabled diagnostics. | |
4 | + | |
5 | + * src/dmhmsgs.h: New file; it declares the NLS capable DMH interface. | |
6 | + * src/dmhmsgs.c: New file; it implements rudimentary NLS hooks, (but | |
7 | + currently does not direct them to any NLS provider), together with an | |
8 | + initial subset of a default (compiled in) message catalogue. | |
9 | + | |
10 | + * Makefile.in (CORE_DLL_OBJECTS): Add dmhmsgs.$OBJEXT | |
11 | + | |
12 | + * src/pkgname.cpp (pkgArchiveName): Modify diagnostics, to use... | |
13 | + (PKGMSG_SPECIFICATION_ERROR): ...this dmhmsgs.h declared message. | |
14 | + | |
1 | 15 | 2013-10-15 Keith Marshall <keithmarshall@users.sourceforge.net> |
2 | 16 | |
3 | 17 | Add automated build time configuration management. |
@@ -160,7 +160,8 @@ LIBS = -Wl,-Bstatic -llua -lz -lbz2 -llzma -Wl,-Bdynamic -lwininet | ||
160 | 160 | |
161 | 161 | # Define the content of package deliverables. |
162 | 162 | # |
163 | -CORE_DLL_OBJECTS = climain.$(OBJEXT) pkgshow.$(OBJEXT) dmhcore.$(OBJEXT) \ | |
163 | +CORE_DLL_OBJECTS = \ | |
164 | + climain.$(OBJEXT) pkgshow.$(OBJEXT) dmhcore.$(OBJEXT) dmhmsgs.$(OBJEXT) \ | |
164 | 165 | pkgbind.$(OBJEXT) pkginet.$(OBJEXT) pkgstrm.$(OBJEXT) pkgname.$(OBJEXT) \ |
165 | 166 | pkgexec.$(OBJEXT) pkgfind.$(OBJEXT) pkginfo.$(OBJEXT) pkgspec.$(OBJEXT) \ |
166 | 167 | pkgopts.$(OBJEXT) sysroot.$(OBJEXT) pkghash.$(OBJEXT) pkgkeys.$(OBJEXT) \ |
@@ -0,0 +1,44 @@ | ||
1 | +/* | |
2 | + * dmhmsgs.c | |
3 | + * | |
4 | + * $Id$ | |
5 | + * | |
6 | + * Written by Keith Marshall <keithmarshall@users.sourceforge.net> | |
7 | + * Copyright (C) 2013, MinGW.org Project | |
8 | + * | |
9 | + * | |
10 | + * Implementation module for predefined diagnostic messages. | |
11 | + * | |
12 | + * | |
13 | + * This is free software. Permission is granted to copy, modify and | |
14 | + * redistribute this software, under the provisions of the GNU General | |
15 | + * Public License, Version 3, (or, at your option, any later version), | |
16 | + * as published by the Free Software Foundation; see the file COPYING | |
17 | + * for licensing details. | |
18 | + * | |
19 | + * Note, in particular, that this software is provided "as is", in the | |
20 | + * hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not | |
21 | + * even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY | |
22 | + * PARTICULAR PURPOSE. Under no circumstances will the author, or the | |
23 | + * MinGW Project, accept liability for any damages, however caused, | |
24 | + * arising from the use of this software. | |
25 | + * | |
26 | + */ | |
27 | +#include "dmhmsgs.h" | |
28 | + | |
29 | +/* FIXME: although we've provided supporting infrastructure, we are not | |
30 | + * yet ready to provide an NLS enabled implementation; ensure that we do | |
31 | + * not accidentally attempt to do this. | |
32 | + */ | |
33 | +#undef DMH_NLS_ENABLED | |
34 | + | |
35 | +/* To provide the message catalogue implementation, we must parse the | |
36 | + * header file again, with its multiple include guard disabled, and with | |
37 | + * DMHMSGS_IMPLEMENTATION defined, (with a non-zero value). | |
38 | + */ | |
39 | +#undef DMHMSGS_H | |
40 | +#define DMHMSGS_IMPLEMENTATION 1 | |
41 | + | |
42 | +#include "dmhmsgs.h" | |
43 | + | |
44 | +/* $RCSfile$: end of file */ |
@@ -0,0 +1,113 @@ | ||
1 | +#ifndef DMHMSGS_H | |
2 | +/* | |
3 | + * dmhmsgs.h | |
4 | + * | |
5 | + * $Id$ | |
6 | + * | |
7 | + * Written by Keith Marshall <keithmarshall@users.sourceforge.net> | |
8 | + * Copyright (C) 2013, MinGW.org Project | |
9 | + * | |
10 | + * | |
11 | + * Public declarations for predefined diagnostic messages. | |
12 | + * | |
13 | + * | |
14 | + * This is free software. Permission is granted to copy, modify and | |
15 | + * redistribute this software, under the provisions of the GNU General | |
16 | + * Public License, Version 3, (or, at your option, any later version), | |
17 | + * as published by the Free Software Foundation; see the file COPYING | |
18 | + * for licensing details. | |
19 | + * | |
20 | + * Note, in particular, that this software is provided "as is", in the | |
21 | + * hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not | |
22 | + * even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY | |
23 | + * PARTICULAR PURPOSE. Under no circumstances will the author, or the | |
24 | + * MinGW Project, accept liability for any damages, however caused, | |
25 | + * arising from the use of this software. | |
26 | + * | |
27 | + */ | |
28 | +#define DMHMSGS_H 1 | |
29 | + | |
30 | +/* Ensure that we can identify extern "C" interfaces, | |
31 | + * when compiling C++ code... | |
32 | + */ | |
33 | +#ifdef __cplusplus | |
34 | +/* ...defining the following in the C++ case... | |
35 | + */ | |
36 | +# define EXTERN_C extern "C" | |
37 | +# define BEGIN_C_DECLS extern "C" { | |
38 | +# define END_C_DECLS } | |
39 | +#else | |
40 | +/* ...whilst ensuring that they have no effect in C. | |
41 | + */ | |
42 | +# define EXTERN_C | |
43 | +# define BEGIN_C_DECLS | |
44 | +# define END_C_DECLS | |
45 | +#endif | |
46 | + | |
47 | +/* Within the interface definition, and its implementation, we need | |
48 | + * a mechanism to represent the "void" data type, which will become | |
49 | + * invisible at point of use. | |
50 | + */ | |
51 | +#undef DMH_VOID | |
52 | +#define DMH_VOID void | |
53 | + | |
54 | +/* Generic macros for defining both the message catalogue interface, | |
55 | + * and its default (embedded code level) implementation. | |
56 | + */ | |
57 | +#define DMHMSG( SET, MSG ) dmhmsg_##SET##_##MSG( DMH_VOID ) | |
58 | +#define MSGDEF( DEF, TXT ) const char *DMHMSG( DEF )GETMSG( DEF, TXT ) | |
59 | + | |
60 | +/* The following macro provides a convenience mechanism for referring | |
61 | + * to any message implementation via its symbolic ID. | |
62 | + */ | |
63 | +#define DMHTXT( DEF ) DMHMSG( DEF ) | |
64 | + | |
65 | +/* Discriminate between interface (header file) and implementation... | |
66 | + */ | |
67 | +#if DMHMSGS_IMPLEMENTATION | |
68 | + /* We are compiling the implementation; we need to set up _GETMSG, | |
69 | + * so that it generates a function body for each message reference... | |
70 | + */ | |
71 | +# undef GETMSG | |
72 | +# if DMH_NLS_ENABLED | |
73 | + /* ...directing the request to catgets(), to possibly retrieve the | |
74 | + * message text from an external catalogue, when NLS is enabled... | |
75 | + */ | |
76 | +# define GETMSG( SET, MSG, TXT ) { return catgets( MSGCAT, SET, MSG, TXT ); } | |
77 | + | |
78 | +# else | |
79 | + /* ...otherwise, simply returning the default (compiled in) text. | |
80 | + */ | |
81 | +# define GETMSG( SET, MSG, TXT ) { return TXT; } | |
82 | +# endif | |
83 | + | |
84 | +#else | |
85 | + /* ...this isn't implementation: we adjust the definition of _GETMSG, | |
86 | + * so that MSGDEF compiles as a function prototype. | |
87 | + */ | |
88 | +# define GETMSG( SET, MSG, TXT ) ; | |
89 | +#endif | |
90 | + | |
91 | +/* Each of the message definitions must be compiled with an extern "C" | |
92 | + * interface. | |
93 | + */ | |
94 | +BEGIN_C_DECLS | |
95 | + | |
96 | +/* Each individual message requires a definition for its catgets() ID tuple, | |
97 | + * (which identifies both set ID and message ID, as a comma separated pair), | |
98 | + * and an invocation of MSGDEF, to define the interface and implementation; | |
99 | + * this may also be accompanied by a further symbolic name definition, to | |
100 | + * facilitate references to the text provided by the implementation. | |
101 | + */ | |
102 | +#define MSG_SPECIFICATION_ERROR 1, 1 | |
103 | +MSGDEF( MSG_SPECIFICATION_ERROR, "internal package specification error\n" ) | |
104 | +#define PKGMSG_SPECIFICATION_ERROR DMHTXT( MSG_SPECIFICATION_ERROR ) | |
105 | + | |
106 | +END_C_DECLS | |
107 | + | |
108 | +/* At point of use, we need DMH_VOID to represent nothing. | |
109 | + */ | |
110 | +#undef DMH_VOID | |
111 | +#define DMH_VOID | |
112 | + | |
113 | +#endif /* DMHMSGS_H: $RCSfile$: end of file */ |
@@ -31,6 +31,7 @@ | ||
31 | 31 | #include <string.h> |
32 | 32 | |
33 | 33 | #include "dmh.h" |
34 | +#include "dmhmsgs.h" | |
34 | 35 | #include "pkgbase.h" |
35 | 36 | #include "pkgkeys.h" |
36 | 37 | #include "pkginfo.h" |
@@ -56,7 +57,7 @@ const char *pkgArchiveName( pkgXmlNode *rel, const char *tag, unsigned opt ) | ||
56 | 57 | /* Complain that this XML element type is invalid, in this context... |
57 | 58 | */ |
58 | 59 | dmh_control( DMH_BEGIN_DIGEST ); |
59 | - dmh_notify( DMH_ERROR, "internal package specification error\n" ); | |
60 | + dmh_notify( DMH_ERROR, PKGMSG_SPECIFICATION_ERROR ); | |
60 | 61 | dmh_notify( DMH_ERROR, "can't get 'tarname' for non-release element %s\n", reftype ); |
61 | 62 | dmh_notify( DMH_ERROR, "please report this to the package maintainer\n" ); |
62 | 63 | dmh_control( DMH_END_DIGEST ); |