Ejemplo n.º 1
0
int dos_PutUniCode(char *dst,const char *src, ssize_t len, BOOL null_terminate)
{
    int ret = 0;
    while (*src && (len > 2)) {
        size_t skip = get_character_len(*src);
        smb_ucs2_t val = (*src & 0xff);

        /*
         * If this is a multibyte character (and all DOS/Windows
         * codepages have at maximum 2 byte multibyte characters)
         * then work out the index value for the unicode conversion.
         */

        if (skip == 2)
            val = ((val << 8) | (src[1] & 0xff));

        SSVAL(dst,ret,doscp_to_ucs2[val]);
        ret += 2;
        len -= 2;
        if (skip)
            src += skip;
        else
            src++;
    }
    if (null_terminate) {
        SSVAL(dst,ret,0);
        ret += 2;
    }
    return(ret);
}
Ejemplo n.º 2
0
/****************************************************************************
(Un)mangle DOS pathname, make nonabsolute
****************************************************************************/
static void fixtarname(char *tptr, char *fp, int l)
{
  /* add a '.' to start of file name, convert from ugly dos \'s in path
   * to lovely unix /'s :-} */

  *tptr++='.';

  while (l > 0) {
    int skip = get_character_len(*fp);
    if(skip != 0) {
      if (skip == 2) {
        *tptr++ = *fp++;
        *tptr++ = *fp++;
        l -= 2;
      } else if (skip == 1) {
        *tptr++ = *fp++;
        l--;
      }
    } else if (*fp == '\\') {
      *tptr++ = '/';
      fp++;
      l--;
    } else {
      *tptr++ = *fp++;
      l--;
    }
  }
}
Ejemplo n.º 3
0
size_t dos_struni2(char *dst, const char *src, size_t max_len)
{
	size_t len = 0;

	if (dst == NULL)
		return 0;

	if (src != NULL) {
		for (; *src && len < max_len-2; len++, dst +=2) {
			size_t skip = get_character_len(*src);
			smb_ucs2_t val = (*src & 0xff);

			/*
			 * If this is a multibyte character (and all DOS/Windows
			 * codepages have at maximum 2 byte multibyte characters)
			 * then work out the index value for the unicode conversion.
			 */

			if (skip == 2)
				val = ((val << 8) | (src[1] & 0xff));

			SSVAL(dst,0,doscp_to_ucs2[val]);
			if (skip)
				src += skip;
			else
				src++;
		}
	}

	SSVAL(dst,0,0);

	return len;
}