/** * The rename function updates the filename. */ int pcsl_file_rename(const pcsl_string * oldName, const pcsl_string * newName) { int res; int status; const jchar * pszOldFilename = pcsl_string_get_utf16_data(oldName); if(pszOldFilename == NULL) { return -1; } else { const jchar * pszNewFilename = pcsl_string_get_utf16_data(newName); if(pszNewFilename == NULL) { pcsl_string_release_utf16_data(pszOldFilename, oldName); return -1; } res = _wrename(pszOldFilename, pszNewFilename); if(res < 0) { status = -1; } else { status = 0; } return status; } }
/** * The function returns value of the attribute for the specified file. */ int pcsl_file_get_attribute(const pcsl_string * fileName, int type, int* result) { int attrs; const jchar * pszOsFilename = pcsl_string_get_utf16_data(fileName); if (NULL == pszOsFilename) { return -1; } attrs = GetFileAttributesW(pszOsFilename); pcsl_string_release_utf16_data(pszOsFilename, fileName); if (INVALID_FILE_ATTRIBUTES == attrs) { return -1; } switch (type) { case PCSL_FILE_ATTR_READ: case PCSL_FILE_ATTR_EXECUTE: *result = 1; break; case PCSL_FILE_ATTR_WRITE: *result = (attrs & FILE_ATTRIBUTE_READONLY) ? 0 : 1; break; case PCSL_FILE_ATTR_HIDDEN: *result = (attrs & FILE_ATTRIBUTE_HIDDEN) ? 1 : 0; break; default: return -1; } return 0; }
/** * Create Java String object from the specified pcsl_string. * * @param pcsl_str pointer to the pcsl_string instance * @param java_str pointer to the Java String instance * @return status of the operation */ pcsl_string_status midp_jstring_from_pcsl_string(KNIDECLARGS const pcsl_string * pcsl_str, jstring java_str) { if (pcsl_str == NULL) { KNI_ReleaseHandle(java_str); return PCSL_STRING_EINVAL; } else { const jsize length = pcsl_string_utf16_length(pcsl_str); if (length < 0) { KNI_ReleaseHandle(java_str); return PCSL_STRING_EINVAL; } else { const jchar * buffer = pcsl_string_get_utf16_data(pcsl_str); if (buffer == NULL) { KNI_ReleaseHandle(java_str); return PCSL_STRING_ERR; } else { KNI_NewString(buffer, length, java_str); return PCSL_STRING_OK; } } } }
/** * The getUsedSpace function checks the size of used space in storage. */ long pcsl_file_getusedspace(const pcsl_string * systemDir) { long used = 0; void* pIterator; pcsl_string current = PCSL_STRING_NULL; struct _stat stat_buf; pIterator = pcsl_file_openfilelist(systemDir); for (; ; ) { if (pcsl_file_getnextentry(pIterator, systemDir, ¤t) == -1) { break; } { const jchar * pwszFilename = pcsl_string_get_utf16_data(¤t); if (NULL == pwszFilename) { break; } /* Don't count the subdirectories "." and ".." */ if (_wstat(pwszFilename, &stat_buf) != -1 && !S_ISDIR(stat_buf.st_mode)) { used += stat_buf.st_size; } pcsl_string_release_utf16_data(pwszFilename, ¤t); } pcsl_string_free(¤t); } pcsl_file_closefilelist(pIterator); return used; }
/** * The getTotalSize function checks the total space in storage. */ long pcsl_file_gettotalsize(const pcsl_string * path) { struct _diskfree_t df; struct _stat buf; jlong size; int res; const jchar * pszOsFilename = pcsl_string_get_utf16_data(path); if (NULL == pszOsFilename) { return -1; } res = _wstat(pszOsFilename, &buf); pcsl_string_release_utf16_data(pszOsFilename, path); if (0 != res) { return -1; } if (0 != _getdiskfree(buf.st_dev + 1, &df)) { return -1; } size = (jlong)(df.total_clusters) * df.sectors_per_cluster * df.bytes_per_sector; return (size > 0x7FFFFFFFL) ? 0x7FFFFFFFL : (long)size; }
/** * Construct a bar that shows indicators. */ IndicatorBar::IndicatorBar(QWidget* parent) : QWidget(parent) { // Set fixed size setFixedSize(FULLWIDTH, 18); QString qiconPath; const pcsl_string * iconPath = storage_get_config_root(INTERNAL_STORAGE_ID); jint iconPath_len = pcsl_string_length(iconPath); const jchar * iconPath_data = pcsl_string_get_utf16_data(iconPath); if (NULL != iconPath_data) { qiconPath.setUnicodeCodes((const ushort *)iconPath_data, iconPath_len); } // else { // The qiconPath string will remain null. // If this happens, most likely, it may show as not found resources // } // Bar image is set as background , maintained by QWidget setBackgroundPixmap(QPixmap(qiconPath+"indicator_bar.png")); homeIcon = new QPixmap(qiconPath+"indicator_home.png"); trustedIcon = new QPixmap(qiconPath+"indicator_trusted.png"); networkIcon = new QPixmap(qiconPath+"indicator_network.png"); // Initialize paint flags for icons to false homeOn = KNI_FALSE; networkOn = KNI_FALSE; trustedOn = KNI_FALSE; // Remember this instance as the singleton singleton = this; pcsl_string_release_utf16_data(iconPath_data, iconPath); }
/** * The rename function updates the filename. */ int pcsl_file_rename(const pcsl_string * oldName, const pcsl_string * newName) { int status = -1; const jchar * pszOldFilename = pcsl_string_get_utf16_data(oldName); const jchar * pszNewFilename = pcsl_string_get_utf16_data(newName); if ((NULL != pszOldFilename) && (NULL != pszNewFilename)) { status = MoveFileW(pszOldFilename, pszNewFilename) ? 0 : -1; } if (pszNewFilename) pcsl_string_release_utf16_data(pszNewFilename, newName); if (pszOldFilename) pcsl_string_release_utf16_data(pszOldFilename, oldName); return status; }
/** * The open function creates and returns a new file identifier for the * file named by filename. Initially, the file position indicator for the * file is at the beginning of the file. */ int pcsl_file_open(const pcsl_string * fileName, int flags, void **handle) { HANDLE fileHandle; DWORD dwDesiredAccess; DWORD dwCreationDisposition; const jchar* pszOsFilename = pcsl_string_get_utf16_data(fileName); *handle = NULL; if (NULL == pszOsFilename) { return -1; } switch (flags & (PCSL_FILE_O_RDWR | PCSL_FILE_O_WRONLY | PCSL_FILE_O_RDONLY)) { case PCSL_FILE_O_RDONLY: dwDesiredAccess = GENERIC_READ; break; case PCSL_FILE_O_WRONLY: dwDesiredAccess = GENERIC_WRITE; break; default: /* PCSL_FILE_O_RDWR or other flag combination */ dwDesiredAccess = GENERIC_READ | GENERIC_WRITE; break; } switch (flags & (PCSL_FILE_O_CREAT | PCSL_FILE_O_TRUNC)) { case PCSL_FILE_O_CREAT | PCSL_FILE_O_TRUNC: dwCreationDisposition = CREATE_ALWAYS; break; case PCSL_FILE_O_CREAT: dwCreationDisposition = OPEN_ALWAYS; break; case PCSL_FILE_O_TRUNC: dwCreationDisposition = TRUNCATE_EXISTING; break; default: dwCreationDisposition = OPEN_EXISTING; break; } fileHandle = CreateFileW(pszOsFilename, dwDesiredAccess, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); pcsl_string_release_utf16_data(pszOsFilename, fileName); if (fileHandle == INVALID_HANDLE_VALUE) { return -1; } { PCSLFile* pFHandle = pcsl_mem_malloc(sizeof(PCSLFile)); if (pFHandle == NULL) { CloseHandle(fileHandle); return -1; } pFHandle->createFlags = flags; pFHandle->fileHandle = fileHandle; *handle = pFHandle; return 0; } }
/** * Writes string to the file. * * @param string string to be written * @return number of bytes written */ static int write_string(const pcsl_string* string) { int size = pcsl_string_utf16_length(string) * sizeof(jchar); const jchar *buf = pcsl_string_get_utf16_data(string); storageWrite(&io_error_message, table_file, (char *)&size, sizeof(int)); storageWrite(&io_error_message, table_file, (char *)buf, size); pcsl_string_release_utf16_data(buf, string); return sizeof(int) + size; }
/** * The unlink function deletes the file named filename from the persistent storage. */ int pcsl_file_unlink(const pcsl_string * fileName) { int status = -1; const jchar* pszOsFilename = pcsl_string_get_utf16_data(fileName); if (NULL != pszOsFilename) { status = DeleteFileW(pszOsFilename) ? 0 : -1; pcsl_string_release_utf16_data(pszOsFilename, fileName); } return status; }
/** * Check if the file exists in FS storage. */ int pcsl_file_exist(const pcsl_string * fileName) { DWORD attrib; const jchar* pszOsFilename = pcsl_string_get_utf16_data(fileName); if (NULL != pszOsFilename) { attrib = GetFileAttributesW(pszOsFilename); pcsl_string_release_utf16_data(pszOsFilename, fileName); if (INVALID_FILE_ATTRIBUTES != attrib) return (attrib & FILE_ATTRIBUTE_DIRECTORY) ? 0 : 1; } return -1; }
/** * The open function creates and returns a new file identifier for the * file named by filename. Initially, the file position indicator for the * file is at the beginning of the file. */ int pcsl_file_open(const pcsl_string * fileName, int flags, void **handle) { int fd; int oFlag = O_BINARY; int creationMode = 0; const jchar * pszOsFilename = pcsl_string_get_utf16_data(fileName); if(pszOsFilename == NULL) { return -1; } /* compute open control flag */ if ((flags & PCSL_FILE_O_WRONLY) == PCSL_FILE_O_WRONLY) { oFlag |= O_WRONLY; } if ((flags & PCSL_FILE_O_RDWR) == PCSL_FILE_O_RDWR) { oFlag |= O_RDWR; } if ((flags & PCSL_FILE_O_CREAT) == PCSL_FILE_O_CREAT) { oFlag |= O_CREAT; creationMode = _S_IREAD | _S_IWRITE; } if ((flags & PCSL_FILE_O_TRUNC) == PCSL_FILE_O_TRUNC) { oFlag |= O_TRUNC; } if ((flags & PCSL_FILE_O_APPEND) == PCSL_FILE_O_APPEND) { oFlag |= O_APPEND; } /* * Unlike Unix systems, Win32 will convert CR/LF pairs to LF when * reading and in reverse when writing, unless the file is opened * in binary mode. */ fd = _wopen(pszOsFilename, oFlag | O_BINARY, creationMode); pcsl_string_release_utf16_data(pszOsFilename, fileName); if(fd < 0) { *handle = NULL; return -1; } *handle = (void *)fd; return 0; }
/** * The function deletes the directory named dirName from the persistent storage. */ int pcsl_file_rmdir(const pcsl_string * dirName) { int res; const jchar * pszOsFilename = pcsl_string_get_utf16_data(dirName); if (NULL == pszOsFilename) { return -1; } res = _wrmdir(pszOsFilename); pcsl_string_release_utf16_data(pszOsFilename, dirName); return (0 == res) ? 0 : -1; }
/** * The function deletes the directory named dirName from the persistent storage. */ int pcsl_file_rmdir(const pcsl_string * dirName) { int res; const jchar * pszOsFilename = pcsl_string_get_utf16_data(dirName); if (NULL == pszOsFilename) { return -1; } res = RemoveDirectoryW(pszOsFilename) ? 0 : -1; pcsl_string_release_utf16_data(pszOsFilename, dirName); return res; }
/** * Compares two MIDP strings. * * The distinction from midpStringCmp is a posibility of * partly equal strings recognition * * @param str1 the first string to be comapred * @param str2 the second string to be comapred * @param case_sensitive indicates case sensivity * @return 0 if strings are equals; if strings are * different returns number of the first different symbol */ static int compare_two_strings(const pcsl_string *str1, const pcsl_string *str2, jsr211_boolean case_sensitive) { const jchar *buf1, *buf2, *cur1, *cur2; int i, n, res; cur1 = buf1 = pcsl_string_get_utf16_data(str1); cur2 = buf2 = pcsl_string_get_utf16_data(str2); n = pcsl_string_utf16_length(str1); i = pcsl_string_utf16_length(str2); res = n == i? 0: n < i? n: i; if (res != 0) { n = res++; } i = 0; if (!case_sensitive) { while (i++ < n) { if (to_lower_case(*cur1++) != to_lower_case(*cur2++)) { res = i; break; } } } else { while (i++ < n) { if (*cur1++ != *cur2++) { res = i; break; } } } pcsl_string_release_utf16_data(buf1, str1); pcsl_string_release_utf16_data(buf2, str2); return res; }
/** * FS only need to support MIDLets to query the size of the file. * Check the File size by file name */ long pcsl_file_sizeof(const pcsl_string * fileName) { WIN32_FILE_ATTRIBUTE_DATA attrib; int result = -1; const jchar* pOsFN = pcsl_string_get_utf16_data(fileName); if (NULL != pOsFN) { if (GetFileAttributesExW(pOsFN, GetFileExInfoStandard, &attrib)) { /* NOTE Returned only 32 lowest bit */ result = attrib.nFileSizeLow; } pcsl_string_release_utf16_data(pOsFN, fileName); } return result; }
/** * The function sets value of the attribute for the specified file. */ int pcsl_file_set_attribute(const pcsl_string * fileName, int type, int value) { int attrs, newmode; int result = -1; const jchar * pszOsFilename = pcsl_string_get_utf16_data(fileName); if (NULL == pszOsFilename) { return -1; } newmode = attrs = GetFileAttributesW(pszOsFilename); while (INVALID_FILE_ATTRIBUTES != attrs) { switch (type) { case PCSL_FILE_ATTR_READ: case PCSL_FILE_ATTR_EXECUTE: break; case PCSL_FILE_ATTR_WRITE: if (value) { newmode &= ~FILE_ATTRIBUTE_READONLY; } else { newmode |= FILE_ATTRIBUTE_READONLY; } break; case PCSL_FILE_ATTR_HIDDEN: if (value) { newmode |= FILE_ATTRIBUTE_HIDDEN; } else { newmode &= ~FILE_ATTRIBUTE_HIDDEN; } } /* do not update file attributes if they are not changed */ if (newmode == attrs) { result = 0; break; } if (0 != SetFileAttributesW(pszOsFilename, newmode)) { result = 0; } break; } pcsl_string_release_utf16_data(pszOsFilename, fileName); return result; }
/** * Check if the directory exists in FS storage. */ int pcsl_file_is_directory(const pcsl_string * path) { int attrs; const jchar * pszOsFilename = pcsl_string_get_utf16_data(path); if(NULL == pszOsFilename) { return -1; } attrs = GetFileAttributesW(pszOsFilename); pcsl_string_release_utf16_data(pszOsFilename, path); if (INVALID_FILE_ATTRIBUTES == attrs) { return -1; } return ((attrs & FILE_ATTRIBUTE_DIRECTORY) != 0) ? 1 : 0; }
/** * The function returns value of the time for the specified file. */ int pcsl_file_get_time(const pcsl_string * fileName, int type, long* result) { struct _stat buf; int res; const jchar * pszOsFilename = pcsl_string_get_utf16_data(fileName); if (NULL == pszOsFilename) { return -1; } res = _wstat(pszOsFilename, &buf); pcsl_string_release_utf16_data(pszOsFilename, fileName); if (-1 == res) { return -1; } *result = buf.st_mtime; return 0; }
/** * The unlink function deletes the file named filename from the persistent storage. */ int pcsl_file_unlink(const pcsl_string * fileName) { int status; const jchar * pszOsFilename = pcsl_string_get_utf16_data(fileName); if (pszOsFilename == NULL) { return -1; } if (_wunlink(pszOsFilename) < 0) { status = -1; } else { status = 0; } pcsl_string_release_utf16_data(pszOsFilename, fileName); return status; }
/** * Write pcsl_string to storage. * First write a jint with length, then the text in utf-16 encoding. * * @param ppszError in the case of error, receives address of a string * describing the problem * @param handle handle of the file to write to * @param str string to be written */ void storage_write_utf16_string(char** ppszError, int handle, const pcsl_string* str) { jint length; if(pcsl_string_is_null(str)) { length = -1; } else { length = pcsl_string_length(str); } storageWrite(ppszError, handle, (char*)&length, sizeof (length)); /* are there data to write? */ if (NULL == *ppszError && length > 0) { const jchar* data = pcsl_string_get_utf16_data(str); if(NULL == data) { *ppszError = (char *)OUT_OF_MEM_ERROR; } else { storageWrite(ppszError, handle, (char*)data, length * sizeof (jchar)); pcsl_string_release_utf16_data(data, str); } } }
/** * The function that will be called when Java system state * changes. * * @param pEventData */ void system_state_listener(const NamsEventData* pEventData) { printf("--- system_state_listener(event = %d, state = %d)\n", pEventData->event, pEventData->state); if (pEventData->event == MIDP_NAMS_EVENT_STATE_CHANGED && pEventData->state == MIDP_SYSTEM_STATE_ACTIVE) { int i; const jchar *jchArgsForMidlet[3]; jint argsLen[3]; /* Currently we support up to 3 arguments. */ for (i = 0; i < 3; i++) { jchArgsForMidlet[i] = pcsl_string_get_utf16_data(&argsForMidlet[i]); argsLen[i] = pcsl_string_utf16_length(&argsForMidlet[i]); } GET_PCSL_STRING_DATA_AND_LENGTH(aclassNameToRun) (void) midp_midlet_create_start_with_args(suiteIDToRun, (const jchar*)aclassNameToRun_data, aclassNameToRun_len, (const jchar**)jchArgsForMidlet, argsLen, 3, #if ENABLE_I3_TEST findNextEmptyMIDlet(0), #else /* * There is only one application * excepting namsTestService mode */ 1, #endif NULL); RELEASE_PCSL_STRING_DATA_AND_LENGTH for (i = 0; i < 3; i++) { pcsl_string_release_utf16_data(jchArgsForMidlet[i], &argsForMidlet[i]); } }
static char* storage_get_last_file_error(char* pszFunction, const pcsl_string* filename_str) { char* temp; int charsLeft; int i; int j; int lim; temp = strerror(errno); if (temp == NULL) { return "Unspecified Error"; } strcpy(errorBuffer, pszFunction); strcat(errorBuffer, ": "); charsLeft = MAX_ERROR_LEN - strlen(errorBuffer); strncat(errorBuffer, temp, charsLeft); charsLeft = MAX_ERROR_LEN - strlen(errorBuffer); strncat(errorBuffer, ", ", charsLeft); charsLeft = MAX_ERROR_LEN - strlen(errorBuffer); if (NULL_LEN == pcsl_string_length(filename_str)) { strncat(errorBuffer, "NULL", charsLeft); } else { const jchar* filename_data = pcsl_string_get_utf16_data(filename_str); int filename_len = pcsl_string_length(filename_str); lim = charsLeft < filename_len ? charsLeft : filename_len; for (i = strlen(errorBuffer), j = 0; j < lim; i++, j++) { errorBuffer[i] = (char)filename_data[j]; } errorBuffer[i] = 0; pcsl_string_release_utf16_data(filename_data,filename_str); } return errorBuffer; }
/** * Check if the file exists in FS storage. */ int pcsl_file_exist(const pcsl_string * fileName) { struct _stat stat_buf; int status; const jchar * pszOsFilename = pcsl_string_get_utf16_data(fileName); if(pszOsFilename == NULL) { return -1; } status = _wstat(pszOsFilename, &stat_buf); pcsl_string_release_utf16_data(pszOsFilename, fileName); if (status >= 0 && S_ISREG(stat_buf.st_mode)) { /* stat completed without error and it is a file */ return 1; } /* either stat completed with error or it is not a file */ return 0; }
/** * The getTotalSize function checks the total space in storage. */ jlong pcsl_file_gettotalsize(const pcsl_string * path) { BOOL res; const jchar * pszOsFilename = pcsl_string_get_utf16_data(path); ULARGE_INTEGER available; ULARGE_INTEGER totalBytes; ULARGE_INTEGER freeBytes; if (NULL == pszOsFilename) { return -1; } res = GetDiskFreeSpaceExW(pszOsFilename, &available, &totalBytes, &freeBytes); pcsl_string_release_utf16_data(pszOsFilename, path); if (!res) { return -1; } return (jlong)totalBytes.QuadPart; }
/** * The function returns value of the time for the specified file. */ int pcsl_file_get_time(const pcsl_string * fileName, int type, long* result) { /* * Expected time is count as seconds from (00:00:00), January 1, 1970 UTC * FILETIME time is 100-nanosecond intervals since January 1, 1601 UTC */ /* Visual C++ 6 suports only i64 suffix (not LL) */ static const LONGLONG FILETIME_1970_01_JAN_UTC = 116444736000000000i64; WIN32_FILE_ATTRIBUTE_DATA attrib; int state = -1; const jchar* pOsFN; if (PCSL_FILE_TIME_LAST_MODIFIED != type) return -1; pOsFN = pcsl_string_get_utf16_data(fileName); if (pOsFN != NULL) { LONGLONG fcurUTC = 0; if (GetFileAttributesExW(pOsFN, GetFileExInfoStandard, &attrib)) { /* FS times is in UTC */ fcurUTC = attrib.ftLastWriteTime.dwHighDateTime; fcurUTC = (fcurUTC << 32) | attrib.ftLastWriteTime.dwLowDateTime; } /* FILETIME members are zero if the FS does not support this time */ if (0 != fcurUTC) { fcurUTC -= FILETIME_1970_01_JAN_UTC; fcurUTC /= 10000000; state = 0; *result = (long)fcurUTC; } pcsl_string_release_utf16_data(pOsFN, fileName); } return state; }
static int findFirstMatch(PCSLFileIterator* pIterator, const pcsl_string * match, pcsl_string * result) { WIN32_FIND_DATAW findData; HANDLE handle; PCSL_DEFINE_ASCII_STRING_LITERAL_START(starSuffix) {'*', '\0'} PCSL_DEFINE_ASCII_STRING_LITERAL_END(starSuffix); pcsl_string root = PCSL_STRING_NULL; pcsl_string foundName = PCSL_STRING_NULL; pcsl_string matchStar = PCSL_STRING_NULL; jsize rootLen = 0; if (result == NULL) { return -1; } * result = PCSL_STRING_NULL; if (pcsl_string_cat(match, &starSuffix, &matchStar) != PCSL_STRING_OK) { return -1; } { const jchar * pwszMatch = pcsl_string_get_utf16_data(&matchStar); if (NULL == pwszMatch) { pcsl_string_free(&matchStar); return -1; } handle = FindFirstFileW(pwszMatch, &findData); pcsl_string_free(&matchStar); } if (INVALID_HANDLE_VALUE == handle) { return -1; } pIterator->iteratorHandle = handle; rootLen = pIterator->savedRootLength; if (pcsl_string_substring(match, 0, rootLen, &root) != PCSL_STRING_OK) { return -1; } if (pcsl_string_convert_from_utf16(findData.cFileName, wcslen(findData.cFileName), &foundName) != PCSL_STRING_OK) { pcsl_string_free(&root); return -1; } if (pcsl_string_cat(&root, &foundName, result) != PCSL_STRING_OK) { pcsl_string_free(&foundName); pcsl_string_free(&root); return -1; } pcsl_string_free(&foundName); pcsl_string_free(&root); return 0; }
/** * Version string may looks like Major:Minor:Micro * * @param ver pcsl_string that contains a version * @param major Major version * @param minor Minor version * @param micro Micro version * @return 1 == OK * 0 = BAD version */ int midpGetVersion(const pcsl_string * ver, int *major, int *minor, int *micro) { int ma = 0; int mi = 0; int mc = 0; int count = 0; int dot_count = 0; int segment_size = 0; const jchar* p = NULL; const jchar* ver_data; jsize ver_len = pcsl_string_utf16_length(ver); *major = -1; *minor = -1; *micro = -1; if ((ver_len <= 0) || (ver_len > 8)) { return 0; } printPcslStringWithMessage("ver", ver); ver_data = pcsl_string_get_utf16_data(ver); if (NULL == ver_data) { return 0; } /* most checking done here */ for (count=0; count < ver_len; count++) { if ((ver_data[count] >= '0') && (ver_data[count] <= '9')) { segment_size++; } else if (ver_data[count] == '.') { if ((segment_size == 0) || (segment_size > 2)) { REPORT_ERROR1(LC_AMS, "segment size wrong %d", segment_size); pcsl_string_release_utf16_data(ver_data, ver); return 0; } dot_count++; segment_size = 0; } else { pcsl_string_release_utf16_data(ver_data, ver); return 0; } } /* end of for */ /* can't be more then 2 dots in version */ if (dot_count > 2) { REPORT_ERROR1(LC_AMS, "too many dots (%d)", dot_count); pcsl_string_release_utf16_data(ver_data, ver); return 0; } /* * Get major version */ for (p = ver_data, count = 0; (*p != '.') && (count < ver_len); ) { if (*p >= '0' && *p <= '9') { ma *= 10; ma += *p - '0'; } else { pcsl_string_release_utf16_data(ver_data, ver); return 0; } count++; p++; } /* end of for */ if(*p == '.') { p++; count++; } /* * Get minor version. */ for ( ; (*p != '.') && (count < ver_len); ) { if (*p >= '0' && *p <= '9') { mi *= 10; mi += *p - '0'; } else { pcsl_string_release_utf16_data(ver_data, ver); return 0; } count++; p++; } if(*p == '.') { p++; count++; } /* * Get micro version; if it exists.. */ for ( ; (*p != '.') && (count < ver_len); ) { if (*p >= '0' && *p <= '9') { mc *= 10; mc += *p - '0'; } else { pcsl_string_release_utf16_data(ver_data, ver); return 0; } p++; count++; } *major = ma; *minor = mi; *micro = mc; pcsl_string_release_utf16_data(ver_data, ver); return 1; }