Пример #1
0
int
isqlt_wcsicmp (const wchar_t *s1, const wchar_t *s2)
{
#if defined (HAVE_TOWLOWER) || defined (HAVE_TOWUPPER)
  int cmp;

  while (*s1)
    {
#if   defined (HAVE_TOWLOWER)
      if ((cmp = towlower (*s1) - towlower (*s2)) != 0)
	return cmp;
#elif defined (HAVE_TOWUPPER)
      if ((cmp = towupper (*s1) - towupper (*s2)) != 0)
	return cmp;
#endif
      s1++;
      s2++;
    }
  return (*s2) ? -1 : 0;
#else
  char *ns1 = malloc_wide_as_narrow (s1);
  char *ns2 = malloc_wide_as_narrow (s2);
  int ret;

  ret = stricmp (ns1, ns2);
  free (ns1);
  free (ns2);
  return ret;
#endif
}
Пример #2
0
FILE *
isqlt_wfopen(const wchar_t *path, const wchar_t *mode)
{
  FILE *ret;
  char *npath = malloc_wide_as_narrow (path);
  char *nmode = malloc_wide_as_narrow (mode);
  int errno_save;

  ret = fopen (npath, nmode);
  errno_save = errno;

  free (npath);
  free (nmode);
  errno = errno_save;
  return ret;
}
Пример #3
0
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);
}
Пример #4
0
int
isqlt_fputws(const wchar_t *s, FILE *stream)
{
  char *nbuffer = malloc_wide_as_narrow (s);
  int ret;

  ret = fputs (nbuffer, stream);
  free (nbuffer);

  return ret;
}
Пример #5
0
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);
}
Пример #6
0
long
isqlt_wtol(const wchar_t *nptr)
{
  long ret;
  char *nstring = malloc_wide_as_narrow (nptr);

  ret = atol (nstring);
  free (nstring);

  return ret;
}
Пример #7
0
int
isqlt_wtoi(const wchar_t *nptr)
{
  int ret;
  char *nstring = malloc_wide_as_narrow (nptr);

  ret = atoi (nstring);
  free (nstring);

  return ret;
}
Пример #8
0
int
isqlt_wsystem(const wchar_t *string)
{
  int ret;
  char *nstring = malloc_wide_as_narrow (string);

  ret = system (nstring);
  free (nstring);

  return ret;
}
Пример #9
0
void
isqlt_wperror(const wchar_t *s)
{
  char *nstring;
  int errno_save = errno;

  nstring = malloc_wide_as_narrow (s);
  errno = errno_save;

  perror (nstring);
  free (nstring);
}
Пример #10
0
int
isqlt_wexecvp(const wchar_t *file, wchar_t *const argv[])
{
  char *nfile = malloc_wide_as_narrow (file);
  char **nargv;
  int inx, ret, argc = 0;

  for (inx = 0 ; argv[inx]; inx++)
    argc++;

  nargv = (char **) calloc (argc + 1, sizeof (char *));

  for (inx = 0 ; inx < argc; inx++)
    nargv[inx] = malloc_wide_as_narrow (argv[inx]);

  ret = execvp (nfile, nargv);
  for (inx = 0 ; nargv[inx]; inx++)
    free (nargv[inx]);
  free (nargv);
  return ret;
}
Пример #11
0
int
isqlt_putwc(int c, FILE *stream)
{
  int ret;
  wchar_t buffer[2];
  char *nbuffer;

  buffer[0] = c;
  buffer[1] = 0;
  nbuffer = malloc_wide_as_narrow (buffer);
  ret = fputs (nbuffer, stream);
  free (nbuffer);
  return ret;
}
Пример #12
0
int
isqlt_wprintf(const wchar_t *format, ...)
{
  va_list lst;
  int ret;
  wchar_t buffer[10000];
  char *nbuffer;

  va_start (lst, format);
  ret = _vsnwprintf (buffer, sizeof (buffer), format, lst);
  va_end (lst);
  nbuffer = malloc_wide_as_narrow (buffer);
  printf ("%s", nbuffer);
  free (nbuffer);
  return (ret);
}