35 #include <sys/types.h> 39 #include <netinet/in.h> 77 #define NLS_MAGIC 0xff88ff89 103 #define ENCODING_LEN 40 106 #define CUB_NL_SETD 0 107 #define CUB_NL_CAT_LOCALE 1 125 #define DEFAULT_NLS_PATH "/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L:/usr/local/share/nls/%L/%N.cat:/usr/local/share/nls/%N/%L" 134 char *nlspath, *lang, *base, *cptr, *pathP, *tmpptr;
135 char *cptr1, *plang, *pter, *pcode;
138 if (name ==
NULL || *name ==
'\0')
145 if (strchr (name,
'/') !=
NULL)
152 lang = setlocale (LC_MESSAGES,
NULL);
156 lang = getenv (
"CHARSET");
160 || (lang[0] ==
'.' && (lang[1] ==
'\0' || (lang[1] ==
'.' && lang[2] ==
'\0'))) || strchr (lang,
'/') !=
NULL)
165 plang = cptr1 =
strdup (lang);
171 cptr = strchr (cptr1,
'@');
177 pter = pcode = (
char *)
"";
178 cptr = strchr (cptr1,
'_');
185 cptr = strchr (cptr1,
'.');
192 nlspath = getenv (
"NLSPATH");
198 base = cptr =
strdup (nlspath);
207 while ((nlspath = strsep (&cptr,
":")) !=
NULL)
212 for (; *nlspath; ++nlspath)
216 switch (*(nlspath + 1))
231 tmpptr = (
char *) name;
237 if (pathP - path >= PATH_MAX - 1)
241 *(pathP++) = *nlspath;
247 spcleft = PATH_MAX - (
CAST_STRLEN (pathP - path)) - 1;
248 if (
strlcpy (pathP, tmpptr, spcleft) >= (size_t) spcleft)
253 errno = ENAMETOOLONG;
260 if (pathP - path >= PATH_MAX - 1)
264 *(pathP++) = *nlspath;
268 if (stat (path, &sbuf) == 0)
277 tmpptr = (
char *) name;
314 r = set_id -
ntohl ((UINT32) set_hdr[i]._setno);
322 l =
ntohl ((UINT32) set_hdr[i]._index);
323 u = l +
ntohl ((UINT32) set_hdr[i]._nmsgs) - 1;
374 UnmapViewOfFile (catd->
_data);
375 CloseHandle (catd->map_handle);
403 file_handle = CreateFile (path, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
NULL);
404 if (file_handle ==
NULL)
408 if (stat (path, &st) != 0)
410 CloseHandle (file_handle);
414 map_handle = CreateFileMapping ((HANDLE) file_handle,
NULL, PAGE_READONLY, 0, (DWORD) st.st_size,
NULL);
415 if (map_handle !=
NULL)
417 data = MapViewOfFile (map_handle, FILE_MAP_READ, 0, 0, 0);
425 fd = open (path, O_RDONLY);
431 if (fstat (fd, &st) != 0)
437 data = mmap (0, (
size_t) st.st_size, PROT_READ, MAP_SHARED, fd, (off_t) 0);
440 if (data == MAP_FAILED)
449 UnmapViewOfFile (data);
450 CloseHandle (map_handle);
452 munmap (data, (
size_t) st.st_size);
462 UnmapViewOfFile (data);
463 CloseHandle (map_handle);
465 munmap (data, (
size_t) st.st_size);
471 catd->_size = (int) st.st_size;
473 catd->map_handle = map_handle;
491 #define MSGCAT_SYSTEM_DIM \ 492 (sizeof(msgcat_System) / sizeof(struct msgcat_def)) 561 static char *empty = (
char *)
"";
580 fprintf (stderr,
"Cannot find message id %d in set id %d from the file %s(%s).", msg_id, set_id,
581 msgcat_System[cat_id].
name, msgcat_System[cat_id].msg_catd->file);
620 msg_catd = (
MSG_CATD) malloc (
sizeof (*msg_catd));
621 if (msg_catd ==
NULL)
629 msg_catd->
catd = (
void *) catd;
644 return (msgcat_System[cat_id].
msg_catd);
680 free ((
void *) msg_catd->
file);
703 fp = fopen (path,
"r");
708 fp = fopen (path,
"r");
MSG_CATD msgcat_get_descriptor(int cat_id)
const char * lang_get_msg_Loc_name(void)
#define MSGCAT_CATALOG_CSQL
int msgcat_close(MSG_CATD msg_catd)
#define MSGCAT_SYSTEM_DIM
struct msg_catd * MSG_CATD
MSG_CATD msgcat_open(const char *name)
#define LANG_NAME_DEFAULT
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
static char * cub_catgets(cub_nl_catd, int, int, const char *)
#define ER_OUT_OF_VIRTUAL_MEMORY
static cub_nl_catd cub_catopen(const char *, int)
char * msgcat_gets(MSG_CATD msg_catd, int set_id, int msg_id, const char *s)
struct _nl_cat_d * cub_nl_catd
struct msgcat_def msgcat_System[]
#define MSGCAT_CATALOG_CUBRID
size_t strlcpy(char *dst, const char *src, size_t siz)
static cub_nl_catd load_msgcat(const char *)
FILE * msgcat_open_file(const char *name)
char * msgcat_message(int cat_id, int set_id, int msg_id)
static int cub_catclose(cub_nl_catd)
char * strdup(const char *str)
char * envvar_localedir_file(char *path, size_t size, const char *langpath, const char *filename)
unsigned int ntohl(unsigned int from)
#define CUB_NL_CAT_LOCALE
#define MSGCAT_CATALOG_UTILS