/* * smb_tonetbiosname * * Creates a NetBIOS name based on the given name and suffix. * NetBIOS name is 15 capital characters, padded with space if needed * and the 16th byte is the suffix. */ void smb_tonetbiosname(char *name, char *nb_name, char suffix) { char tmp_name[NETBIOS_NAME_SZ]; smb_wchar_t wtmp_name[NETBIOS_NAME_SZ]; int len; size_t rc; len = 0; rc = smb_mbstowcs(wtmp_name, (const char *)name, NETBIOS_NAME_SZ); if (rc != (size_t)-1) { wtmp_name[NETBIOS_NAME_SZ - 1] = 0; rc = ucstooem(tmp_name, wtmp_name, NETBIOS_NAME_SZ, OEM_CPG_850); if (rc > 0) len = strlen(tmp_name); } (void) memset(nb_name, ' ', NETBIOS_NAME_SZ - 1); if (len) { (void) smb_strupr(tmp_name); (void) memcpy(nb_name, tmp_name, len); } nb_name[NETBIOS_NAME_SZ - 1] = suffix; }
/* * Generate an OEM name for the given share name. If the name is * shorter than 13 bytes the oemname will be returned; otherwise NULL * is returned. */ static char * smb_kshare_oemname(const char *shrname) { smb_wchar_t *unibuf; char *oem_name; int length; length = strlen(shrname) + 1; oem_name = smb_mem_alloc(length); unibuf = smb_mem_alloc(length * sizeof (smb_wchar_t)); (void) smb_mbstowcs(unibuf, shrname, length); if (ucstooem(oem_name, unibuf, length, OEM_CPG_850) == 0) (void) strcpy(oem_name, shrname); smb_mem_free(unibuf); if (strlen(oem_name) + 1 > SMB_SHARE_OEMNAME_MAX) { smb_mem_free(oem_name); return (NULL); } return (oem_name); }