Subversion Repositories SvarDOS

Compare Revisions

Ignore whitespace Rev 1305 → Rev 1306

/svarlang.lib/trunk/auto_nls.c
22,35 → 22,27
* DEALINGS IN THE SOFTWARE.
*/
 
#include <stdlib.h> /* getenv(), NULL */
#include "svarlang.h"
 
 
int svarlang_autoload_nlspath(const char *progname) {
const char *lang;
const char *nlspath;
int svarlang_autoload_pathlist(const char *progname, const char *pathlist, const char *lang) {
char buff[128];
unsigned short i, ii;
 
/* read and validate LANG */
lang = getenv("LANG");
if ((lang == NULL) || (lang[0] == 0)) return(-1);
/* read and validate LANG and pathlist */
if ((!lang) || (lang[0] == 0) || (!pathlist)) return(-1);
 
/* read and validate NLSPATH */
nlspath = getenv("NLSPATH");
if (nlspath == NULL) return(-2);
 
/* look into every path in NLSPATH */
while (*nlspath != 0) {
while (*pathlist != 0) {
 
/* skip any leading ';' separators */
while (*nlspath == ';') nlspath++;
while (*pathlist == ';') pathlist++;
 
if (*nlspath == 0) return(-3);
if (*pathlist == 0) return(-3);
 
/* copy nlspath to buff and remember len */
for (i = 0; (nlspath[i] != 0) && (nlspath[i] != ';'); i++) buff[i] = nlspath[i];
nlspath += i;
for (i = 0; (pathlist[i] != 0) && (pathlist[i] != ';'); i++) buff[i] = pathlist[i];
pathlist += i;
 
/* add a trailing backslash if there is none (non-empty paths empty) */
if ((i > 0) && (buff[i - 1] != '\\')) buff[i++] = '\\';
/svarlang.lib/trunk/svarlang.h
26,7 → 26,7
#define SVARLANG_H
 
/* library version */
#define SVARLANGVER "20230713"
#define SVARLANGVER "20230717"
 
/* returns a pointer to a string with the SvarLANG's library version,
* independently of the SVARLANGVER string above. */
51,10 → 51,13
* or absolute). You may want to pass argv[0] or __argv[0] there. */
int svarlang_autoload_exepath(const char *selfexe, const char *lang);
 
/* this relies on getenv() to pull LANG and NLSPATH variables and looks
* for a translation file named "%NLSPATH%\progname.lng".
* this call should be used only by "CORE" SvarDOS / FreeDOS programs. */
int svarlang_autoload_nlspath(const char *progname);
/* this looks in a list of paths separated by ';' to locate a translation file
* for progname. this is usually called only by "CORE" SvarDOS / FreeDOS
* programs. typical example:
*
* svarlang_autoload_pathlist("myprog", getenv("NLSPATH"), getenv("LANG"));
*/
int svarlang_autoload_pathlist(const char *progname, const char *pathlist, const char *lang);
 
/* Returns a pointer to the string "id". Does not require svalang_load() to be
* executed, but then it will only return the reference language strings.