gCAD3D 2.35
xa_msg.c File Reference

functions for output of messages in different languages More...

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "../ut/ut_geo.h"
#include "../ut/ut_txt.h"
#include "../ut/ut_txTab.h"
#include "../ut/ut_os.h"
#include "../xa/xa_msg.h"
#include "../xa/xa.h"
#include "../xa/xa_mem.h"

Macros

#define MSG_bSiz   256
 

Functions

int APP_MSG_close ()
 
char * APP_MSG_read (char *sbuf, int bufSiz, char *key)
 
char * MSG_fread (char *sbuf, int bufSiz, char *key, FILE *fpIn)
 
char * APP_MSG_get_0 (char *key)
 
int APP_MSG_pri_0 (char *key)
 
char * APP_MSG_get_1 (char *key, char *fmt,...)
 
int APP_MSG_pri_1 (char *key, char *fmt,...)
 
int APP_MSG_err_0 (char *key,...)
 
int APP_MSG_err_1 (char *key, char *fmt,...)
 
int APP_MSG_Tip (char *key)
 
int MSG_Init (char *lang)
 
int MSG_Tip (char *key)
 
int MSG_pri_0 (char *key)
 
char * MSG_get_0 (char *key)
 
int MSG_get_1 (char *msg, int msgSiz, char *key, char *fmt,...)
 
int MSG_get__ (char *msg, int msgSiz, char *key, FILE *fpIn, char *fmt, va_list *va)
 
int MSG_err_1 (char *key, char *fmt,...)
 
int MSG_pri_1 (char *key, char *fmt,...)
 
int MSG_err_0 (char *key,...)
 
char * MSG_read (char *sbuf, int bufSiz, char *key)
 
int MSG_const_init (char *sLang)
 
char * MSG_const__ (int iMsg)
 
char * MSG_get_str (char *keyStr)
 
int MSG_get_wTab (TxtTab *txTab, int tabSiz)
 
int MSG_lng_init (int *lngNr, char lngCode[][4], char lngName[][40])
 
int MSG_STD__ (int msgTyp, const char *fnc, int ikey, char *txt,...)
 

Variables

static char * MSG_tab =NULL
 
static FILE * APP_MSG_fp =NULL
 
static FILE * MSG_fp =NULL
 
static char MSG_buf [MSG_bSiz]
 
char * MSG_STD_code []
 
char * MSG_STD_tab []
 messages for MSG_STD__ MSG_STD_ERR More...
 

Detailed Description

functions for output of messages in different languages

=====================================================
List_functions_start:
MSG_STD_ERR errormessage (key, additional_text)
MSG_STD__ error/warning/info
APP_MSG_pri_0 print message with 0 parameter (TX_Print)
APP_MSG_pri_1 print formatted message with 1 parameter (TX_Print)
APP_MSG_err_1 print errormessage with 1 parameter, formatted ..
APP_MSG_Tip add tooltip to last created GUI-widget
APP_MSG_get_0 get application-message with 0 parameters
APP_MSG_get_1 get msg with parameter from messagefile for ctive application
APP_MSG_read read msg from active application-messagefile
MSG_const__ get const-message from nr
MSG_const_init load file xa/msg_const_de.txt -> MSG_tab
MSG_Tip add tooltip to last created GUI-widget
MSG_pri_0 print message with 0 parameter (TX_Print)
MSG_pri_1 print formatted message with 1 parameter (TX_Print)
MSG_get_0 return message
MSG_get_1 get formatted message with 1 parameter
MSG_err_1 print errormessage with 1 parameter, formatted ..
MSG_get_wTab get a table of words from integers
MSG_get_str get message from string (get key from string; 0 parameters)
MSG_Init open / reopen
MSG_lng_init find supported languages ..
MSG_fread read message <key> in (open) file <fpIn>
List_functions_end:
=====================================================
Defaultlanguage is "_en" english
_de german
_es spanish
_fr french
_it italian
//================================================================
Application-Messages:
//================================================================
Each application (plugin) can have its own messagefile:
{docDir}/msg/{appnam}_{language}.txt
File ~/gCAD3D/xa/app1_en.txt would be used by plugin
~/gCAD3D/binLinux32/plugins/app1.so
Opening & closing this files is done automatic.
Fileformat of the messagefile:
{keyCode} {message}
Messagelinelength may not exceed 255 chars
message can have a parameter (" %% " will be replaced by the parameter).
can have continuation-lines (last char \, first char of next line \)
Functions APP_MSG_*
#include "../xa/xa_msg.h" // Messages
//================================================================
Standard-Messages
//================================================================
Get messages, identified by a integer; ../xa/xa_msg.h eg func_not_impl
Examples:
MSG_STD_ERR (func_not_impl, "E001 - %d",4);
//================================================================
Messages for the menu's:
//================================================================
Get messages, identified by a keyword;
Files keyword=message: msg_<language>.txt
../../doc/msg/msg_en.txt
// message without parameters:
MSG_pri_0("PEDmod1"); // TX_Print message
MSG_Tip ("MMclear"); // add Tooltip to GTK-widget
GUI_Label_1(box0, MSG_get_0("MD_On"), 0); // get message for label
// message with 1 parameter:
MSG_err_1 ("FileOp",fnam); // FileOpenError
MSG_get_1 (s2, 256, "SEL_sDir", "%s", s1); // s1 replaces %% in message
//================================================================
Constant-Messages
//================================================================
Often used, short messages; identified by integers (../xa/xa_msg.h)
Messagecodes:
../xa/xa_msg.h
Messagefiles:
{baseDir}/gCAD3D/xa/msg_const_{language}.txt
eg msg_const_de.txt msg_const_en.txt
../../doc/msg/msg_const_de.txt
Messagecodes: enum in file
{baseDir}/gCAD3D/xa/xa_msg.h
Constant-Messages cannot have parameters.
Examples:
GUI_Tip (MSG_const__(MSG_upd));
strcpy(s1, MSG_const__(MSG_open)); // "Öffnen");

Macro Definition Documentation

#define MSG_bSiz   256

Function Documentation

int APP_MSG_close ( )
char* APP_MSG_read ( char *  sbuf,
int  bufSiz,
char *  key 
)
char* MSG_fread ( char *  sbuf,
int  bufSiz,
char *  key,
FILE *  fpIn 
)
read message "<key> in (open) file <fpIn>
Output:
sbuf
retCod NULL key not found
else position of text without key in sbuf
Howto create new message: see INF_MSG_new
char* APP_MSG_get_0 ( char *  key)

get application-message with 0 parameters.

int APP_MSG_pri_0 ( char *  key)

print message with 0 parameters.

char* APP_MSG_get_1 ( char *  key,
char *  fmt,
  ... 
)
get message with 1 parameter, formatted ..
get msg from messagefile for the active application
int APP_MSG_pri_1 ( char *  key,
char *  fmt,
  ... 
)
print message with 1 parameter, formatted ..
get msg from messagefile for the active application
int APP_MSG_err_0 ( char *  key,
  ... 
)
int APP_MSG_err_1 ( char *  key,
char *  fmt,
  ... 
)
int APP_MSG_Tip ( char *  key)

APP_MSG_Tip add tooltip to last created GUI-widget

int MSG_Init ( char *  lang)
int MSG_Tip ( char *  key)
MSG_Tip add tooltip to last created GUI-widget
msg out of files msg_de.txt msg_en.txt ..
int MSG_pri_0 ( char *  key)

print message (TX_Write) with 0 parameters.

char* MSG_get_0 ( char *  key)
int MSG_get_1 ( char *  msg,
int  msgSiz,
char *  key,
char *  fmt,
  ... 
)
int MSG_get__ ( char *  msg,
int  msgSiz,
char *  key,
FILE *  fpIn,
char *  fmt,
va_list *  va 
)
int MSG_err_1 ( char *  key,
char *  fmt,
  ... 
)
int MSG_pri_1 ( char *  key,
char *  fmt,
  ... 
)
int MSG_err_0 ( char *  key,
  ... 
)
char* MSG_read ( char *  sbuf,
int  bufSiz,
char *  key 
)
int MSG_const_init ( char *  sLang)
char* MSG_const__ ( int  iMsg)
MSG_const__ get const-message from nr
message-constants: see file msg_const_de.txt
p1 = MSG_const__ (MSG_ok); // 0=first message = yes
iMsg - eg MSG_ok - see xa_msg.h
Add new constants:
add ID in xa_msg.h;
add msg in msg_const_de.txt (and all others, msg_const_en.txt ..)
char* MSG_get_str ( char *  keyStr)
MSG_get_str get message from string (get key from string; 0 parameters)
max returned size = 256 chars
see also MSG_get_0
int MSG_get_wTab ( TxtTab txTab,
int  tabSiz 
)

get a table of words from integers

int MSG_lng_init ( int *  lngNr,
char  lngCode[][4],
char  lngName[][40] 
)
int MSG_STD__ ( int  msgTyp,
const char *  fnc,
int  ikey,
char *  txt,
  ... 
)
MSG_STD__ error/warning/info
output: TX_Error|TX_Print;
retCod -1
see also MSG_STD_ERR

Variable Documentation

char* MSG_tab =NULL
static
FILE* APP_MSG_fp =NULL
static
FILE* MSG_fp =NULL
static
char MSG_buf[MSG_bSiz]
static
char* MSG_STD_code[]
Initial value:
={
"-",
"***",
"*** ERROR:"
}
char* MSG_STD_tab[]
Initial value:
={
"function not implemented",
"subModel undefined",
"DB-object undefined",
"file open",
"uu"
}

messages for MSG_STD__ MSG_STD_ERR