void nls_cstring_to_uniname(struct super_block *sb, UNI_NAME_T *p_uniname, UINT8 *p_cstring, INT32 *p_lossy) { INT32 i, j, lossy = FALSE; UINT8 *end_of_name; UINT8 upname[MAX_NAME_LENGTH * 2]; UINT16 *uniname = p_uniname->name; struct nls_table *nls = EXFAT_SB(sb)->nls_io; /* strip all trailing spaces */ end_of_name = p_cstring + STRLEN((INT8 *) p_cstring); while (*(--end_of_name) == ' ') { if (end_of_name < p_cstring) break; } *(++end_of_name) = '\0'; if (STRCMP((INT8 *) p_cstring, ".") && STRCMP((INT8 *) p_cstring, "..")) { /* strip all trailing periods */ while (*(--end_of_name) == '.') { if (end_of_name < p_cstring) break; } *(++end_of_name) = '\0'; } if (*p_cstring == '\0') lossy = TRUE; i = j = 0; while (j < (MAX_NAME_LENGTH-1)) { if (*(p_cstring+i) == '\0') break; i += convert_ch_to_uni(nls, uniname, (UINT8 *)(p_cstring+i), &lossy); if ((*uniname < 0x0020) || WSTRCHR(bad_uni_chars, *uniname)) lossy = TRUE; SET16_A(upname + j * 2, nls_upper(sb, *uniname)); uniname++; j++; } if (*(p_cstring+i) != '\0') lossy = TRUE; *uniname = (UINT16) '\0'; p_uniname->name_len = j; p_uniname->name_hash = calc_checksum_2byte((void *) upname, j<<1, 0, CS_DEFAULT); if (p_lossy != NULL) *p_lossy = lossy; } /* end of nls_cstring_to_uniname */
void nls_uniname_to_dosname(struct super_block *sb, DOS_NAME_T *p_dosname, UNI_NAME_T *p_uniname, INT32 *p_lossy) { INT32 i, j, len, lossy = FALSE; UINT8 buf[MAX_CHARSET_SIZE]; UINT8 lower = 0, upper = 0; UINT8 *dosname = p_dosname->name; UINT16 *uniname = p_uniname->name; UINT16 *p, *last_period; struct nls_table *nls = EXFAT_SB(sb)->nls_disk; for (i = 0; i < DOS_NAME_LENGTH; i++) { *(dosname+i) = ' '; } if (!nls_uniname_cmp(sb, uniname, (UINT16 *) UNI_CUR_DIR_NAME)) { *(dosname) = '.'; p_dosname->name_case = 0x0; if (p_lossy != NULL) *p_lossy = FALSE; return; } if (!nls_uniname_cmp(sb, uniname, (UINT16 *) UNI_PAR_DIR_NAME)) { *(dosname) = '.'; *(dosname+1) = '.'; p_dosname->name_case = 0x0; if (p_lossy != NULL) *p_lossy = FALSE; return; } last_period = NULL; for (p = uniname; *p; p++) { if (*p == (UINT16) '.') last_period = p; } i = 0; while (i < DOS_NAME_LENGTH) { if (i == 8) { if (last_period == NULL) break; if (uniname <= last_period) { if (uniname < last_period) lossy = TRUE; uniname = last_period + 1; } } if (*uniname == (UINT16) '\0') { break; } else if (*uniname == (UINT16) ' ') { lossy = TRUE; } else if (*uniname == (UINT16) '.') { if (uniname < last_period) lossy = TRUE; else i = 8; } else if (WSTRCHR(bad_dos_chars, *uniname)) { lossy = TRUE; *(dosname+i) = '_'; i++; } else { len = convert_uni_to_ch(nls, buf, *uniname, &lossy); if (len > 1) { if ((i >= 8) && ((i+len) > DOS_NAME_LENGTH)) { break; } if ((i < 8) && ((i+len) > 8)) { i = 8; continue; } lower = 0xFF; for (j = 0; j < len; j++, i++) { *(dosname+i) = *(buf+j); } } else { if ((*buf >= 'a') && (*buf <= 'z')) { *(dosname+i) = *buf - ('a' - 'A'); if (i < 8) lower |= 0x08; else lower |= 0x10; } else if ((*buf >= 'A') && (*buf <= 'Z')) { *(dosname+i) = *buf; if (i < 8) upper |= 0x08; else upper |= 0x10; } else { *(dosname+i) = *buf; } i++; } } uniname++; } if (*dosname == 0xE5) *dosname = 0x05; if (*uniname != 0x0) lossy = TRUE; if (upper & lower) p_dosname->name_case = 0xFF; else p_dosname->name_case = lower; if (p_lossy != NULL) *p_lossy = lossy; }
void CContactInfo::FillMultiField(AEEAddrField *pField, int &nPos, AECHAR *pwzName, AEEAddrFieldID type) { // pwzName = [email protected]<NEW>[email protected] if (NULL==pwzName ) return; AECHAR pwzNewTag[]=NEW_FIELD; char pszNewtag[10]; SPRINTF(pszNewtag, "%S", pwzNewTag); int nTagLen = STRLEN(pszNewtag); char *pszTmp=NULL; int nLen=WSTRLEN(pwzName); pszTmp = (char*)MALLOC(nLen+1); if ( NULL==pszTmp ) return; WSTRTOSTR(pwzName, pszTmp, nLen+1); char *pNext=pszTmp; char *pFound=NULL; char *pValue=NULL; char *pEnd=NULL; int nValueLen =0; int nBufferPos=0; pValue = pNext; DBGPRINTF("%s", pValue); while ( NULL!=(pFound=STRSTR(pNext, pszNewtag))) { pField[nPos].fID = type; pField[nPos].fType = AEEDB_FT_STRING; nBufferPos = STRLEN(pszTmp)-STRLEN(pValue); pField[nPos].pBuffer = pwzName+ nBufferPos; //value lenth nValueLen = STRLEN(pValue)-STRLEN(pFound); DBGPRINTF("%s", pValue); pField[nPos].wDataLen = (nValueLen+1)*sizeof(AECHAR); nPos++; pNext = pFound+1; pValue = pFound+ nTagLen; } DBGPRINTF("%s", pValue); pField[nPos].fID = type; pField[nPos].fType = AEEDB_FT_STRING; nBufferPos = STRLEN(pszTmp)-STRLEN(pValue); pField[nPos].pBuffer = pwzName+ nBufferPos; nValueLen=STRLEN(pValue); pField[nPos].wDataLen = (nValueLen+1)*sizeof(AECHAR); nPos++; FREEIF(pszTmp); AECHAR *pwzSart=pwzName; AECHAR *pwzEnd=NULL; AECHAR pwzNull = '\0'; while ( NULL!=(pwzEnd=WSTRCHR(pwzSart, '<'))) { *pwzEnd='\0'; pwzSart = pwzEnd+4; } }