86 lines
1.3 KiB
C
86 lines
1.3 KiB
C
|
|
/* --- control mode and internationalization --- */
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <SDL.h>
|
|
#include "CNFGRAPI.h"
|
|
#include "SYSDEPNS.h"
|
|
#include "UTIL/ENDIANAC.h"
|
|
#include "UI/MYOSGLUE.h"
|
|
#include "STRCONST.h"
|
|
#include "LANG/INTLCHAR.h"
|
|
|
|
#ifndef CanGetAppPath
|
|
#define CanGetAppPath 1
|
|
#endif
|
|
|
|
static char *d_arg = NULL;
|
|
static char *n_arg = NULL;
|
|
|
|
#if CanGetAppPath
|
|
static char *app_parent = NULL;
|
|
static char *pref_dir = NULL;
|
|
#endif
|
|
|
|
#ifdef _WIN32
|
|
#define PathSep '\\'
|
|
#else
|
|
#define PathSep '/'
|
|
#endif
|
|
|
|
MacErr_t ChildPath(char *x, char *y, char **r)
|
|
{
|
|
MacErr_t err = mnvm_miscErr;
|
|
int nx = strlen(x);
|
|
int ny = strlen(y);
|
|
{
|
|
if ((nx > 0) && (PathSep == x[nx - 1])) {
|
|
--nx;
|
|
}
|
|
{
|
|
int nr = nx + 1 + ny;
|
|
char *p = malloc(nr + 1);
|
|
if (p != NULL) {
|
|
char *p2 = p;
|
|
(void) memcpy(p2, x, nx);
|
|
p2 += nx;
|
|
*p2++ = PathSep;
|
|
(void) memcpy(p2, y, ny);
|
|
p2 += ny;
|
|
*p2 = 0;
|
|
*r = p;
|
|
err = mnvm_noErr;
|
|
}
|
|
}
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
void MayFree(char *p)
|
|
{
|
|
if (NULL != p) {
|
|
free(p);
|
|
}
|
|
}
|
|
|
|
|
|
/* --- text translation --- */
|
|
|
|
void NativeStrFromCStr(char *r, char *s)
|
|
{
|
|
uint8_t ps[ClStrMaxLength];
|
|
int i;
|
|
int L;
|
|
|
|
ClStrFromSubstCStr(&L, ps, s);
|
|
|
|
for (i = 0; i < L; ++i) {
|
|
r[i] = Cell2PlainAsciiMap[ps[i]];
|
|
}
|
|
|
|
r[L] = 0;
|
|
}
|