wchar_t *isqlt_wgetpassphrase( const wchar_t * prompt ) { char *nret; char *nprompt = malloc_wide_as_narrow (prompt); nret = getpassphrase (nprompt); free (nprompt); return malloc_narrow_as_wide (nret); }
wchar_t * isqlt_wgetenv(const wchar_t *name) { char *nret; char *nname = malloc_wide_as_narrow (name); nret = getenv (nname); free (nname); return malloc_narrow_as_wide (nret); }
wchar_t * isqlt_fgetws(wchar_t *s, int size, FILE *stream) { char *buffer = malloc (size); wchar_t *wbuffer; if (buffer && fgets (buffer, size, stream)) { wbuffer = malloc_narrow_as_wide (buffer); wcsncpy (s, wbuffer, size); free (wbuffer); return s; } if (wbuffer) free (wbuffer); return NULL; }
int main (int argc, char *argv[]) { wchar_t **wargv = (wchar_t **) malloc (argc * sizeof (wchar_t *)); int inx; char *locale = setlocale (LC_ALL, ""); /* !!!!WARNING!!!! There's a GCC bug : if the *first* output call is not wide (wprintf/fwprintf) then *all* the subsequent wide output functions will *not* work */ if (locale) wprintf (L"Locale=%s\n", setlocale (LC_ALL, "")); else wprintf (L"Can't apply the system locale. " L"Possibly wrong setting for LANG environment variable. " L"Using the C locale instead.\n"); for (inx = 0 ; inx < argc; inx++) { wargv[inx] = malloc_narrow_as_wide (argv[inx]); } return wmain (argc, wargv); }