Files
2ine-tms34010/native/nls.c
T
Ryan C. Gordon 6821de5ed7 Automate handling of support code for OS/2 binaries.
Now a perl script parses our headers and generates glue code, export tables,
etc. This automates all the macro nonsense and bridge code, and separates
out all the stuff you need for binary compat with OS/2, so you can remove it
all from the build if you want to just build native libraries that supply
the OS/2 API to native apps (like Winelib vs Wine).

This makes upkeep details less nasty, and easier to build native binaries
when implementing and improving APIs, so you can debug directly without
a lot of drama.
2018-02-27 03:25:21 -05:00

81 lines
2.5 KiB
C

/**
* 2ine; an OS/2 emulator for Linux.
*
* Please see the file LICENSE.txt in the source's root directory.
*
* This file written by Ryan C. Gordon.
*/
#include "os2native.h"
#include "nls.h"
#include "nls-lx.h"
APIRET DosQueryDBCSEnv(ULONG buflen, PCOUNTRYCODE pcc, PCHAR buf)
{
// !!! FIXME: implement this for real.
TRACE_NATIVE("DosQueryDBCSEnv(%u, %p, %p)", (uint) buflen, pcc, buf);
if ((pcc->country != 0) || (pcc->codepage != 0))
return ERROR_CODE_PAGE_NOT_FOUND;
memset(buf, '\0', buflen);
return NO_ERROR;
} // DosQueryDBCSEnv
APIRET DosMapCase(ULONG cb, PCOUNTRYCODE pcc, PCHAR pch)
{
// !!! FIXME: implement this for real.
TRACE_NATIVE("DosMapCase(%u, %p, %p)", (uint) cb, pcc, pch);
if ((pcc->country != 0) || (pcc->codepage != 0))
return ERROR_CODE_PAGE_NOT_FOUND;
for (ULONG i = 0; i < cb; i++) {
const CHAR ch = *pch;
*(pch++) = ((ch >= 'A') && (ch <= 'Z')) ? ch - ('A' - 'a') : ch;
} // for
return NO_ERROR;
} // DosMapCase
APIRET DosQueryCtryInfo(ULONG cb, PCOUNTRYCODE pcc, PCOUNTRYINFO pci, PULONG pcbActual)
{
// From the 4.5 toolkit docs: "If this area is too small to hold all of
// the available information, then as much information as possible is
// provided in the available space (in the order in which the data would
// appear)." ...so we fill in a local struct and memcpy it at the end.
COUNTRYINFO ci;
memset(&ci, '\0', sizeof (ci));
// From the 4.5 toolkit docs: "If the amount of data returned is not
// enough to fill the memory area provided by the caller, then the memory
// that is unaltered by the available data is zeroed out." ...so blank
// it all out now.
memset(pci, '\0', cb);
if ((pcc->country != 0) || (pcc->codepage != 0))
return ERROR_CODE_PAGE_NOT_FOUND;
// !!! FIXME: this is just what OS/2 Warp 4.52 returns by default for my USA system.
ci.country = 1;
ci.codepage = 437;
ci.fsDateFmt = 0;
ci.szCurrency[0] = '$';
ci.szThousandsSeparator[0] = ',';
ci.szDecimal[0] = '.';
ci.szDateSeparator[0] = '-';
ci.szTimeSeparator[0] = ':';
ci.fsCurrencyFmt = 0;;
ci.cDecimalPlace = 2;
ci.fsTimeFmt = 0;
//USHORT abReserved1[2];
ci.szDataSeparator[0] = ',';
//USHORT abReserved2[5];
if (pcbActual)
*pcbActual = 38; // OS/2 Warp 4.52 doesn't count the abReserved[5] at the end.
return NO_ERROR;
} // DosQueryCtryInfo
// end of nls.c ...