From: <ny...@us...> - 2007-02-06 04:06:44
|
Revision: 297 http://svn.sourceforge.net/pmplib/?rev=297&view=rev Author: nyaochi Date: 2007-02-05 20:06:42 -0800 (Mon, 05 Feb 2007) Log Message: ----------- More work on API restructuring. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/common/database.c trunk/pmplib/frontend/easypmp/cui/option.c trunk/pmplib/include/filepath.h trunk/pmplib/include/gmi.h trunk/pmplib/include/ucs2char.h trunk/pmplib/lib/filepath/filepath_posix.c trunk/pmplib/lib/filepath/filepath_win32.c trunk/pmplib/lib/gmi/gmi.c trunk/pmplib/lib/gmi/gmi_mp3.c trunk/pmplib/lib/gmi/gmi_vorbis.c trunk/pmplib/lib/gmi/gmi_wav.c trunk/pmplib/lib/gmi/gmi_wma.c trunk/pmplib/lib/playlist/jspl.c trunk/pmplib/lib/pmp_portalplayer1/pp1db.c trunk/pmplib/lib/ucs2/ucs2char.c trunk/pmplib/lib/ucs2/ucs2char_iconv.c trunk/pmplib/lib/ucs2/ucs2char_win32.c Modified: trunk/pmplib/frontend/easypmp/common/database.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/database.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/frontend/easypmp/common/database.c 2007-02-06 04:06:42 UTC (rev 297) @@ -169,7 +169,7 @@ uint32_t timestamp = 0; filepath_combinepath(filename, MAX_PATH, target->pathname, target->filename); - timestamp = (uint32_t)ucs2stat_mtime(filename); + timestamp = (uint32_t)filepath_mtime(filename); // Report the progress. if (progress(instance, EASYPMPP_MUSIC_GMI | EASYPMPSP_PROGRESS, i, 0, filename) != 0) { @@ -202,6 +202,7 @@ filename, music_path, opt->media_info_source, + opt->music_encoding, opt->strip_words, opt->num_strip_words ) == 0) { Modified: trunk/pmplib/frontend/easypmp/cui/option.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/option.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/frontend/easypmp/cui/option.c 2007-02-06 04:06:42 UTC (rev 297) @@ -36,10 +36,6 @@ #include <direct.h> /* getcwd() */ #endif/*_MSC_VER*/ -#ifdef HAVE_LANGINFO_CODESET -#include <langinfo.h> -#endif - #include <ucs2char.h> #include <filepath.h> #include <gmi.h> @@ -106,25 +102,13 @@ fprintf(fp, " -h, --help Show this help message and exit\n"); } -static char *get_default_encoding() -{ - const char *encoding = getenv("CHARSET"); - -#ifdef HAVE_LANGINFO_CODESET - if (!encoding) { - encoding = nl_langinfo(CODESET); - } -#endif - return encoding ? strdup(encoding) : strdup("UTF-8"); -} - void option_init(option_t* opt) { memset(opt, 0, sizeof(*opt)); // Set default values here. opt->media_info_source = GMIF_TAG; - opt->system_encoding = get_default_encoding(); + opt->system_encoding = strdup(ucs2getenc()); opt->music_encoding = strdup("ISO-8859-1"); } Modified: trunk/pmplib/include/filepath.h =================================================================== --- trunk/pmplib/include/filepath.h 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/include/filepath.h 2007-02-06 04:06:42 UTC (rev 297) @@ -82,6 +82,12 @@ FILEPATHAPI int filepath_encode(ucs2char_t* path); FILEPATHAPI int filepath_decode(ucs2char_t* path); +FILEPATHAPI time_t filepath_mtime(const ucs2char_t *filename); +FILEPATHAPI uint32_t filepath_size(const ucs2char_t *filename); +FILEPATHAPI int filepath_is_dir(const ucs2char_t *filename); +FILEPATHAPI int filepath_exist(const ucs2char_t *filename); + + #ifdef __cplusplus } #endif/*__cplusplus*/ Modified: trunk/pmplib/include/gmi.h =================================================================== --- trunk/pmplib/include/gmi.h 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/include/gmi.h 2007-02-06 04:06:42 UTC (rev 297) @@ -62,6 +62,7 @@ const ucs2char_t *filename, const ucs2char_t* path_to_music, int flag, + const char *charset, ucs2char_t **strip_words, int num_strip_words ); Modified: trunk/pmplib/include/ucs2char.h =================================================================== --- trunk/pmplib/include/ucs2char.h 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/include/ucs2char.h 2007-02-06 04:06:42 UTC (rev 297) @@ -38,8 +38,17 @@ #endif/*__cplusplus*/ /** - * \addtogroup ucs2 PMPlib UCS-2 API. - * @{ + * \addtogroup ucs2 UCS-2 Character/String API + * @{ + * + * The PMPlib UCS-2 character/string API provides a manupulation utility + * for characters/strings in UCS-2 encoding. As a number of portable media + * players support Unicode for displaying song information, PMPlib deals + * with Unicode characters/strings encoded in UCS-2. + * + * The byte order of UCS-2 character is dependent on the CPU architecture + * on which this code runs: e.g., little-endian on Intel IA-32/IA-64 and + * big-endian on IBM PowerPC. */ /** @@ -47,35 +56,241 @@ */ typedef uint16_t ucs2char_t; +/** + * Initialize the UCS-2 library. + * + * This function initializes internal variables used in the UCS-2 library. + * Call this function before using any other functions in this API. + * + * @retval int Zero if succeeded, otherwise non-zero value. + */ +UCS2API int ucs2init(); +/** + * @defgroup ucs2_conv Character encoding converter + * @{ + * + * This API subset converts the character encoding of a string from one to + * another. It supports mutual conversions between: + * UCS-2 and multi-byte character (i.e., \c char); + * UCS-2 and UTF-8. + * + * By default, this library detects the character encoding of multi-byte + * characters on the current system based on the value of LANG variable + * (for POSIX) or via GetACP() function (for Win32). + */ /** - * @defgroup ucs2_conv Charaset conversion routines. - * @{ + * Set the encoding for multi-byte characters (for iconv/libiconv). + * + * This function change the default encoding for multi-byte characters to the + * character encoding specified by the \a encoding argument. + * + * @param encoding The pointer to the string specifying the character + * encoding. + * + * @note + * This function is effective only on environments with iconv (libiconv). */ +UCS2API int ucs2setenc(const char *encoding); -struct tag_ucs2conv { - const char *from; - const char *to; -}; -typedef struct tag_ucs2conv ucs2conv_t; +/** + * Get the encoding for multi-byte characters (for iconv/libiconv). + * + * This function returns the default encoding for multi-byte characters used + * in the UCS-2 API. + * + * @retval const char* The pointer to the string of the character encoding. + * + * @note + * This function is effective only on environments with iconv (libiconv). + */ +UCS2API const char *ucs2getenc(); -UCS2API int ucs2init(const char *encoding); +/** + * Set the code page for multi-byte characters (for Win32). + * + * This function change the default encoding for multi-byte characters to the + * code page specified by the \a cp argument. + * + * @param cp The code page. + * + * @note + * This function is effective only on Win32 environments. + */ +UCS2API void ucs2setcp(int cp); -UCS2API int ucs2set_encoding(const char *encoding, ucs2conv_t* conv); -UCS2API int ucs2set_encoding_music(const char *encoding, ucs2conv_t* conv); -UCS2API void ucs2set_codepage(int cp); +/** + * Get the code page for multi-byte characters (for Win32). + * + * This function returns the default code page for multi-byte characters. + * + * @param cp The code page. + * + * @note + * This function is effective only on Win32 environments. + */ +UCS2API int ucs2getcp(); +/** + * Convert a UCS-2 string to multi-byte characters. + * + * @param mbstr The pointer to the buffer for receiving multi-byte + * characters converted from the UCS-2 string. If + * \a mbs_size is zero, this argument is not be used. + * @param mbs_size The size, in bytes, of the buffer pointed to by the + * \a mbstr argument. If this value is zero, the function + * returns the number of bytes required for the buffer. + * @param ucs2str The pointer to the UCS-2 string to be converted. + * @param ucs_size The size, in number of UCS-2 characters, of the UCS-2 + * string, \a ucs2str. + * @retval size_t The number of bytes written to \a mbstr buffer if + * the conversion is successful. If \a mbs_size is zero, + * the return value is the required size, in bytes, for a + * buffer to receive the converted string. This function + * returns zero if an error occurred. + */ UCS2API size_t ucs2tombs(char *mbstr, size_t mbs_size, const ucs2char_t *ucs2str, size_t ucs_size); + +/** + * Convert multi-byte characters to a UCS-2 string. + * + * @param ucs2str The pointer to the buffer for receiving UCS-2 string + * converted from the multi-byte characters. If + * \a ucs_size is zero, this argument is not be used. + * @param ucs_size The size, in number of UCS-2 characters, of the buffer + * pointed to by the \a ucs2str argument. If this value is + * zero, the function returns the number of UCS-2 + * characters required for the buffer. + * @param mbstr The pointer to the multi-byte characters to be + * converted. + * @param mbs_size The size, in bytes, of the multi-byte characters, + * \a mbstr. + * @retval size_t The number of UCS-2 characters written to \a ucs2str + * buffer if the conversion is successful. If \a ucs_size + * is zero, the return value is the required size, in + * number of UCS-2 characters, for a buffer to receive the + * converted string. This function returns zero if an error + * occurred. + */ UCS2API size_t mbstoucs2(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size); -UCS2API size_t mbstoucs2_music(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size); + +/** + * Convert multi-byte characters in a specific encoding to a UCS-2 string. + * + * @param ucs2str The pointer to the buffer for receiving UCS-2 string + * converted from the multi-byte characters. If + * \a ucs_size is zero, this argument is not be used. + * @param ucs_size The size, in number of UCS-2 characters, of the buffer + * pointed to by the \a ucs2str argument. If this value is + * zero, the function returns the number of UCS-2 + * characters required for the buffer. + * @param mbstr The pointer to the multi-byte characters to be + * converted. + * @param mbs_size The size, in bytes, of the multi-byte characters, + * \a mbstr. + * @param charset The pointer to the string specifying the encoding of + * the multi-byte characters. + * @retval size_t The number of UCS-2 characters written to \a ucs2str + * buffer if the conversion is successful. If \a ucs_size + * is zero, the return value is the required size, in + * number of UCS-2 characters, for a buffer to receive the + * converted string. This function returns zero if an error + * occurred. + * @note + * \a charset is ignored on Win32 environments. + */ +UCS2API size_t mbstoucs2_charset(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size, const char *charset); + +/** + * Convert a UCS-2 string to multi-byte characters. + * + * @param mbstr The pointer to the buffer for receiving UTF-8 string + * converted from the UCS-2 string. If \a mbs_size is + * zero, this argument is not be used. + * @param mbs_size The size, in bytes, of the buffer pointed to by the + * \a mbstr argument. If this value is zero, the function + * returns the number of bytes required for the buffer. + * @param ucs2str The pointer to the UCS-2 string to be converted. + * @param ucs_size The size, in number of UCS-2 characters, of the UCS-2 + * string, \a ucs2str. + * @retval size_t The number of bytes written to \a mbstr buffer if + * the conversion is successful. If \a mbs_size is zero, + * the return value is the required size, in bytes, for a + * buffer to receive the converted string. This function + * returns zero if an error occurred. + */ +UCS2API size_t ucs2toutf8(char *mbstr, size_t mbs_size, const ucs2char_t *ucs2str, size_t ucs_size); + +/** + * Convert a UTF-8 string to a UCS-2 string. + * + * @param ucs2str The pointer to the buffer for receiving UCS-2 string + * converted from the UTF-8 string. If \a ucs_size is + * zero, this argument is not be used. + * @param ucs_size The size, in number of UCS-2 characters, of the buffer + * pointed to by the \a ucs2str argument. If this value is + * zero, the function returns the number of UCS-2 + * characters required for the buffer. + * @param mbstr The pointer to the UTF-8 string to be converted. + * @param mbs_size The size, in bytes, of the UTF-8 string, \a mbstr. + * @retval size_t The number of UCS-2 characters written to \a ucs2str + * buffer if the conversion is successful. If \a ucs_size + * is zero, the return value is the required size, in + * number of UCS-2 characters, for a buffer to receive the + * converted string. This function returns zero if an error + * occurred. + */ UCS2API size_t utf8toucs2(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size); +/** + * Convert and duplicate a UCS-2 string to multi-byte characters. + * + * @param ucs2str The pointer to a UCS-2 string. + * @retval char* The pointer to the duplicated string. Call ucs2free() + * to free the memory block allocated by this function. + */ +UCS2API char *ucs2dupmbs(const ucs2char_t *ucs2str); + +/** + * Convert and duplicate multi-byte characters to a UCS-2 string. + * + * @param mbstr The pointer to multi-byte characters. + * @retval char* The pointer to the duplicated string. Call ucs2free() + * to free the memory block allocated by this function. + */ UCS2API ucs2char_t* mbsdupucs2(const char *mbstr); + +/** + * Convert and duplicate multi-byte characters in a specific encoding + * to a UCS-2 string. + * + * @param mbstr The pointer to multi-byte characters. + * @param charset The pointer to the string specifying the encoding of + * the multi-byte characters. + * @retval char* The pointer to the duplicated string. Call ucs2free() + * to free the memory block allocated by this function. + */ +UCS2API ucs2char_t* mbsdupucs2_charset(const char *mbstr, const char *charset); + +/** + * Convert and duplicate a UCS-2 string to a UTF-8 string. + * + * @param ucs2str The pointer to a UCS-2 string. + * @retval char* The pointer to the duplicated string. Call ucs2free() + * to free the memory block allocated by this function. + */ +UCS2API char *ucs2duputf8(const ucs2char_t *ucs2str); + +/** + * Convert and duplicate a UTF-8 string to a UCS-2 string. + * + * @param mbstr The pointer to multi-byte characters. + * @retval char* The pointer to the duplicated string. Call ucs2free() + * to free the memory block allocated by this function. + */ UCS2API ucs2char_t* utf8dupucs2(const char *utf8str); -UCS2API ucs2char_t* mbsdupucs2_music(const char *mbstr); -UCS2API char *ucs2dupmbs(const ucs2char_t *ucs2str); /** * @} @@ -83,89 +298,324 @@ -UCS2API void ucs2big2little(ucs2char_t* value); - - /** - * @defgroup ucs2_memory Memory allocation routines. + * @defgroup ucs2_memory Memory manager routines * @{ */ +/** + * Allocate a memory block. + * + * @param size The size, in bytes, of the memory block. + * @retval void* The pointer to the allocated memory block. + */ UCS2API void *ucs2malloc(size_t size); + +/** + * Allocate a memory block with values initialized as zero. + * + * @param size The size, in bytes, of the memory block. + * @retval void* The pointer to the allocated memory block. + */ UCS2API void *ucs2calloc(size_t size); + +/** + * Resize a memory block. + * + * @param ptr The pointer to the memory block to be resized. + * @param size The size, in bytes, of the new memory block. + * @retval void* The pointer to the new memory block. + */ UCS2API void *ucs2realloc(void *ptr, size_t size); -UCS2API void ucs2free(void* str); +/** + * Free a memory block. + * + * @param ptr The pointer to the memory block to be freed. + */ +UCS2API void ucs2free(void* ptr); + /** * @} */ -UCS2API int is_ucs2surrogate(ucs2char_t c); -UCS2API int isucs2space(ucs2char_t c); -UCS2API int isucs2digit(ucs2char_t c); +/** + * @defgroup ucs2_char UCS-2 character routines + * @{ + */ +UCS2API int ucs2issurrogate(ucs2char_t c); +UCS2API int ucs2isspace(ucs2char_t c); +UCS2API int ucs2isdigit(ucs2char_t c); +UCS2API ucs2char_t ucs2lower(ucs2char_t c); +UCS2API ucs2char_t ucs2upper(ucs2char_t c); + +/** + * @} + */ + + + + + /** - * @defgroup ucs2_string_ansi ANSI C compatible string routines. + * @defgroup ucs2_string_ansi ANSI C compatible string routines * @{ + * + * This is the subset of the UCS-2 Character/String API that corresponds + * to string manupulation routines in the ANSI C standard. The following + * ANSI C functions are not defined in this subset: + * strcoll, strerror, strtok, strxfrm. */ +/** + * Concatenate two strings. + * + * @param dst The pointer to the destination of a string. + * @param src The pointer to the source of a string. + * @retval ucs2char_t* The pointer to the destination string. + */ UCS2API ucs2char_t* ucs2cat(ucs2char_t* dst, const ucs2char_t* src); -UCS2API ucs2char_t* ucs2chr(const ucs2char_t* string, ucs2char_t c); + +/** + * Search for the first occurrence of a character in a string. + * + * @param str The pointer to the string in which \a c is searched. + * @param c The target character. + * @retval ucs2char_t* The pointer to the character \a c in \a str, or \c NULL + * if \a c does not occur in \a str. + */ +UCS2API ucs2char_t* ucs2chr(const ucs2char_t* str, ucs2char_t c); + +/** + * Compare two strings. + * + * @param x The pointer to a string. + * @param y The pointer to another string. + * @retval int A positive value if \a x is greater than \a y; + * a negative value if \a x is smaller than \a y; + * zero if \a x is identical to \a y. + */ UCS2API int ucs2cmp(const ucs2char_t* x, const ucs2char_t* y); + +/** + * Copy a string. + * + * @param dst The pointer to the destination of a string. + * @param src The pointer to the source of a string. + * @retval ucs2char_t* The pointer to the destination string. + */ UCS2API ucs2char_t* ucs2cpy(ucs2char_t* dst, const ucs2char_t* src); -UCS2API size_t ucs2cspn(const ucs2char_t *str, const ucs2char_t *charset); -UCS2API ucs2char_t* ucs2dup(const ucs2char_t* src); -UCS2API size_t ucs2len(const ucs2char_t* string); -UCS2API ucs2char_t* ucs2ncat(ucs2char_t *dst, const ucs2char_t *src, size_t count); + +/** + * Count the number of characters not appearing in a character set. + * + * @param str The pointer to a string. + * @param charset The pointer to a character set. + * @retval size_t The number of characters from the beginning of \a str + * in which any character in \a charset appear for the + * first time, or the length of \a str if such a character + * does not exist. + */ +UCS2API size_t ucs2cspn(const ucs2char_t *str, const ucs2char_t *charset); + +/** + * Count the length of a string. + * + * @param str The pointer to a string. + * @retval size_t The number of characters in \a str. + */ +UCS2API size_t ucs2len(const ucs2char_t* str); + +/** + * Concatenate two strings (no more than the maximum length). + * + * @param dst The pointer to the destination of a string. + * @param src The pointer to the source of a string. + * @param n The number of characters to be concatenated. + * @retval ucs2char_t* The pointer to the destination string. + */ +UCS2API ucs2char_t* ucs2ncat(ucs2char_t *dst, const ucs2char_t *src, size_t n); + +/** + * Compare two strings (no longer than the maximum length). + * + * @param x The pointer to a string. + * @param y The pointer to another string. + * @param n The number of characters to be compared. + * @retval int A positive value if \a x is greater than \a y; + * a negative value if \a x is smaller than \a y; + * zero if \a x is identical to \a y. + */ UCS2API int ucs2ncmp(const ucs2char_t* x, const ucs2char_t* y, size_t n); -UCS2API ucs2char_t* ucs2ncpy(ucs2char_t* dst, const ucs2char_t* src, size_t count); -UCS2API ucs2char_t* ucs2pbrk(const ucs2char_t *str, const ucs2char_t *search); + +/** + * Copy a string (no more than the maximum length). + * + * @param dst The pointer to the destination of a string. + * @param src The pointer to the source of a string. + * @param n The number of characters to be copied. + * @retval ucs2char_t* The pointer to the destination string. + */ +UCS2API ucs2char_t* ucs2ncpy(ucs2char_t* dst, const ucs2char_t* src, size_t n); + +/** + * Find a character in a string that belongs to a character set. + * + * @param str The pointer to the string where \a charset is searched. + * @param charset The pointer to a character set. + * @retval ucs2char_t* The pointer to the character in \a str that belongs + * to \a charset, or \c NULL if such a character does not + * exist. + */ +UCS2API ucs2char_t* ucs2pbrk(const ucs2char_t *str, const ucs2char_t *charset); + +/** + * Search for the last occurrence of a character in a string. + * + * @param str The pointer to the string in which \a c is searched. + * @param c The target character. + * @retval ucs2char_t* The pointer to the character \a c in \a str, or \c NULL + * if \a c does not occur in \a str. + */ UCS2API ucs2char_t* ucs2rchr(const ucs2char_t* string, ucs2char_t c); + +/** + * Find a character in a string that does not belong to a character set. + * + * @param str The pointer to the string where \a charset is searched. + * @param charset The pointer to a character set. + * @retval ucs2char_t* The pointer to the character in \a str that does not + * belong to \a charset, or \c NULL if such a character + * does not exist. + */ UCS2API size_t ucs2spn(const ucs2char_t *str, const ucs2char_t *charset); -UCS2API ucs2char_t* ucs2str(const ucs2char_t* str, const ucs2char_t* search); +/** + * Find a substring in a string. + * + * @param str The pointer to the string where \a substr is searched. + * @param substr The pointer to the substring. + * @retval ucs2char_t* The pointer to the character where \a substr begins + * in \a str for the first time, or \c NULL if \a str + * does not contain \a substr. + */ +UCS2API ucs2char_t* ucs2str(const ucs2char_t* str, const ucs2char_t* substr); + /** - * @} + * @} */ + + + + /** - * @defgroup ucs2_string_ansi ANSI C compatible string routines. + * @defgroup ucs2_string_non_ansi Miscellaneous string routines * @{ */ +/** + * Duplicate a string. + * + * @param str The pointer to a string. + * @retval ucs2char_t* The pointer to the duplicated string. Call ucs2free() + * to free the memory block allocated by this function. + */ +UCS2API ucs2char_t* ucs2dup(const ucs2char_t* str); + +/** + * Duplicate a string no longer than the specified length. + * + * @param str The pointer to a string. + * @param length The maximum length of the duplicated string. + * @retval ucs2char_t* The pointer to the duplicated string. Call ucs2free() + * to free the memory block allocated by this function. + */ UCS2API ucs2char_t* ucs2ndup(const ucs2char_t* src, size_t length); + +/** + * Convert a string to lowercase. + * + * Given \a str argument, this function converts uppercase letters in the + * string to lowercase and overwrites the resultant string on the same buffer + * pointed by the \a str argument. + * + * @param str The pointer to a string. + * @retval ucs2char_t* The pointer to the string, which is the same value as + * \a str. + */ UCS2API ucs2char_t* ucs2lwr(ucs2char_t* str); + +/** + * Convert a string to uppercase. + * + * Given \a str argument, this function converts lowercase letters in the + * string to uppercase and overwrites the resultant string on the same buffer + * pointed by the \a str argument. + * + * @param str The pointer to a string. + * @retval ucs2char_t* The pointer to the string, which is the same value as + * \a str. + */ UCS2API ucs2char_t* ucs2upr(ucs2char_t* str); + +/** + * Compare two strings incasesensitively. + * + * @param x The pointer to a string. + * @param y The pointer to another string. + * @retval int A positive value if \a x is greater than \a y; + * a negative value if \a x is smaller than \a y; + * zero if \a x is identical to \a y. + */ UCS2API int ucs2icmp(const ucs2char_t* x, const ucs2char_t* y); + +/** + * Compare two strings incasesensitively (no longer than the maximum length). + * + * @param x The pointer to a string. + * @param y The pointer to another string. + * @param n The number of characters to be compared. + * @retval int A positive value if \a x is greater than \a y; + * a negative value if \a x is smaller than \a y; + * zero if \a x is identical to \a y. + */ UCS2API int ucs2incmp(const ucs2char_t* x, const ucs2char_t* y, size_t n); +/** + * Strip whitespace characters at the head and tail of a string. + * + * Given \a str argument, this function trims whilespace characters at the + * head and tail of the string and overwrites the resultant string on the + * same buffer pointed by the \a str argument. + * + * @param str The pointer to a string. + * @retval ucs2char_t* The pointer to the string, which is the same value as + * \a str. + */ +UCS2API ucs2char_t* ucs2strip(ucs2char_t* str); + /** * @} */ -UCS2API ucs2char_t ucs2lower(ucs2char_t c); -UCS2API ucs2char_t ucs2upper(ucs2char_t c); +/** + * @defgroup ucs2_std Wrapper for stdio/stdlib routines + * @{ + */ - -UCS2API ucs2char_t* ucs2strip(ucs2char_t* str); - - UCS2API int ucs2toi(const ucs2char_t* str); UCS2API ucs2char_t* itoucs2(int value, ucs2char_t *string, int radix); - - -UCS2API time_t ucs2stat_mtime(const ucs2char_t *filename); -UCS2API uint32_t ucs2stat_size(const ucs2char_t *filename); -UCS2API int ucs2stat_is_dir(const ucs2char_t *filename); -UCS2API int ucs2stat_is_exist(const ucs2char_t *filename); - UCS2API ucs2char_t fputucs2c(ucs2char_t c, FILE *fp); UCS2API FILE *ucs2fopen(const ucs2char_t *filename, const char *mode); /** @} */ +/** @} */ + #ifdef __cplusplus } #endif/*__cplusplus*/ Modified: trunk/pmplib/lib/filepath/filepath_posix.c =================================================================== --- trunk/pmplib/lib/filepath/filepath_posix.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/filepath/filepath_posix.c 2007-02-06 04:06:42 UTC (rev 297) @@ -72,7 +72,7 @@ ucs2cpy(tmp, path); ucs2cat(tmp, filename); - if (!ucs2stat_is_dir(tmp)){ + if (!filepath_is_dir(tmp)){ callback(instance, path, filename); } } @@ -101,7 +101,7 @@ ucs2cpy(tmp, path); ucs2cat(tmp, filename); - if (ucs2stat_is_dir(tmp)){ + if (filepath_is_dir(tmp)){ filepath_addslash(tmp); find_file(tmp, recursive, callback, instance); } @@ -354,7 +354,7 @@ int filepath_file_exists(const ucs2char_t* path) { - return ucs2stat_is_exist(path); + return filepath_exist(path); } int filepath_relative_to_absolute(ucs2char_t* absolute, const ucs2char_t* base, const ucs2char_t* relative) @@ -396,8 +396,8 @@ struct stat st1; struct stat st2; - time_t ret1 = ucs2stat_mtime(file1); - time_t ret2 = ucs2stat_mtime(file2); + time_t ret1 = filepath_mtime(file1); + time_t ret2 = filepath_mtime(file2); return (ret1 - ret2); } Modified: trunk/pmplib/lib/filepath/filepath_win32.c =================================================================== --- trunk/pmplib/lib/filepath/filepath_win32.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/filepath/filepath_win32.c 2007-02-06 04:06:42 UTC (rev 297) @@ -27,6 +27,9 @@ #include <os.h> +#include <sys/types.h> +#include <sys/stat.h> + #include <windows.h> #include <shlwapi.h> @@ -234,3 +237,36 @@ /* Does nothing for WIN32. */ return 0; } + +time_t filepath_mtime(const ucs2char_t *filename) +{ + int ret = 0; + struct _stat st; + ret = _wstat(filename, &st); + if (ret == 0) { + return st.st_mtime; + } + return 0; +} + +uint32_t filepath_size(const ucs2char_t *filename) +{ + int ret = 0; + struct _stat st; + ret = _wstat(filename, &st); + if (ret == 0) { + return st.st_size; + } + return 0; +} + +int filepath_is_dir(const ucs2char_t *filename) +{ + int ret = 0; + struct _stat st; + ret = _wstat(filename, &st); + if (ret == 0) { + return ((st.st_mode & S_IFMT) == S_IFDIR); + } + return 0; +} Modified: trunk/pmplib/lib/gmi/gmi.c =================================================================== --- trunk/pmplib/lib/gmi/gmi.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/gmi/gmi.c 2007-02-06 04:06:42 UTC (rev 297) @@ -37,20 +37,20 @@ * @{ */ -int gmi_mp3(media_info_t* info, const ucs2char_t *filename); +int gmi_mp3(media_info_t* info, const ucs2char_t *filename, const char *charset); static const ucs2char_t ucs2cs_ext_mp3[] = {'.','m','p','3',0}; -int gmi_wma(media_info_t* info, const ucs2char_t *filename); +int gmi_wma(media_info_t* info, const ucs2char_t *filename, const char *charset); static const ucs2char_t ucs2cs_ext_wma[] = {'.','w','m','a',0}; -int gmi_vorbis(media_info_t* info, const ucs2char_t *filename); +int gmi_vorbis(media_info_t* info, const ucs2char_t *filename, const char *charset); static const ucs2char_t ucs2cs_ext_ogg[] = {'.','o','g','g',0}; -int gmi_wav(media_info_t* info, const ucs2char_t *filename); +int gmi_wav(media_info_t* info, const ucs2char_t *filename, const char *charset); static const ucs2char_t ucs2cs_ext_wav[] = {'.','w','a','v',0}; typedef struct { - int (*func)(media_info_t* info, const ucs2char_t *filename); + int (*func)(media_info_t* info, const ucs2char_t *filename, const char *charset); const ucs2char_t* ext; } gmi_exports_t; @@ -198,6 +198,7 @@ const ucs2char_t *filename, const ucs2char_t* path_to_music, int flag, + const char *charset, ucs2char_t **strip_words, int num_strip_words ) @@ -207,12 +208,12 @@ /* Set the pathname and filename. */ info->filename = ucs2dup(filename); - info->filesize = ucs2stat_size(filename); + info->filesize = filepath_size(filename); if (flag & GMIF_TAG) { while (exp->func) { if (filepath_hasext(filename, exp->ext)) { - if (exp->func(info, filename) == 0) { + if (exp->func(info, filename, charset) == 0) { ret = 0; break; } Modified: trunk/pmplib/lib/gmi/gmi_mp3.c =================================================================== --- trunk/pmplib/lib/gmi/gmi_mp3.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/gmi/gmi_mp3.c 2007-02-06 04:06:42 UTC (rev 297) @@ -273,7 +273,7 @@ } -static ucs2char_t* get_frame_value(struct id3_tag *id3tag, const char *name) +static ucs2char_t* get_frame_value(struct id3_tag *id3tag, const char *name, const char *charset) { ucs2char_t* ret = NULL; const id3_ucs4_t *value = NULL; @@ -313,7 +313,7 @@ if (encoding == ID3_FIELD_TEXTENCODING_ISO_8859_1) { char *mbs = id3_ucs4_latin1duplicate(value); - ret = mbsdupucs2_music(mbs); /* MBS for music files. */ + ret = mbsdupucs2_charset(mbs, charset); /* MBS for music files. */ free(mbs); return ret; } else { @@ -324,7 +324,7 @@ } } -int gmi_mp3(media_info_t* info, const ucs2char_t *filename) +int gmi_mp3(media_info_t* info, const ucs2char_t *filename, const char *charset) { int i, num_tags = 0; mp3header_t mp3header; @@ -375,7 +375,7 @@ } /* Obtain track number first. */ - ucs2 = get_frame_value(id3tag, "TRCK"); + ucs2 = get_frame_value(id3tag, "TRCK", charset); if (ucs2 && *ucs2) { info->track_number = ucs2toi(ucs2); } else { @@ -384,7 +384,7 @@ ucs2free(ucs2); /* Obtain track title. */ - ucs2 = get_frame_value(id3tag, "TIT2"); + ucs2 = get_frame_value(id3tag, "TIT2", charset); if (ucs2 && *ucs2) { ucs2free(info->title); info->title = ucs2dup(ucs2); @@ -392,11 +392,11 @@ ucs2free(ucs2); /* Set artist field. */ - if (1) ucs2 = get_frame_value(id3tag, "TPE1"); - if (!ucs2) ucs2 = get_frame_value(id3tag, "TPE2"); - if (!ucs2) ucs2 = get_frame_value(id3tag, "TPE3"); - if (!ucs2) ucs2 = get_frame_value(id3tag, "TPE4"); - if (!ucs2) ucs2 = get_frame_value(id3tag, "TCOM"); + if (1) ucs2 = get_frame_value(id3tag, "TPE1", charset); + if (!ucs2) ucs2 = get_frame_value(id3tag, "TPE2", charset); + if (!ucs2) ucs2 = get_frame_value(id3tag, "TPE3", charset); + if (!ucs2) ucs2 = get_frame_value(id3tag, "TPE4", charset); + if (!ucs2) ucs2 = get_frame_value(id3tag, "TCOM", charset); if (ucs2 && *ucs2) { ucs2free(info->artist); info->artist = ucs2dup(ucs2); @@ -404,7 +404,7 @@ ucs2free(ucs2); /* Set composer field. */ - ucs2 = get_frame_value(id3tag, "TCOM"); + ucs2 = get_frame_value(id3tag, "TCOM", charset); if (ucs2 && *ucs2) { ucs2free(info->composer); info->composer = ucs2dup(ucs2); @@ -412,7 +412,7 @@ ucs2free(ucs2); /* Set album field. */ - ucs2 = get_frame_value(id3tag, "TALB"); + ucs2 = get_frame_value(id3tag, "TALB", charset); if (ucs2 && *ucs2) { ucs2free(info->album); info->album = ucs2dup(ucs2); @@ -423,7 +423,7 @@ * TCMP (compilation flag) handling for omnibus albums. * This patch was originally submitted by Espen Matheussen. */ - ucs2 = get_frame_value(id3tag, "TCMP"); + ucs2 = get_frame_value(id3tag, "TCMP", charset); if (ucs2 && *ucs2) { size_t length = 0; ucs2char_t* title = NULL; @@ -458,7 +458,7 @@ } /* Set genre field. */ - ucs2 = get_frame_value(id3tag, "TCON"); + ucs2 = get_frame_value(id3tag, "TCON", charset); if (ucs2 && *ucs2) { ucs2free(info->genre); info->genre = ucs2dup(ucs2); @@ -466,8 +466,8 @@ ucs2free(ucs2); /* Set year field. */ - if (1) ucs2 = get_frame_value(id3tag, "TYER"); - if (!ucs2) ucs2 = get_frame_value(id3tag, "TDRC"); + if (1) ucs2 = get_frame_value(id3tag, "TYER", charset); + if (!ucs2) ucs2 = get_frame_value(id3tag, "TDRC", charset); if (ucs2 && *ucs2) { ucs2free(info->date); info->date = ucs2dup(ucs2); Modified: trunk/pmplib/lib/gmi/gmi_vorbis.c =================================================================== --- trunk/pmplib/lib/gmi/gmi_vorbis.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/gmi/gmi_vorbis.c 2007-02-06 04:06:42 UTC (rev 297) @@ -46,7 +46,7 @@ #define strncasecmp _strnicmp #endif -int gmi_vorbis(media_info_t* info, const ucs2char_t *filename) +int gmi_vorbis(media_info_t* info, const ucs2char_t *filename, const char *charset) { int i, ret = 0; long lval = 0; @@ -59,7 +59,7 @@ /* Set the pathname and filename. */ /* info->filename = ucs2dup(filename); - info->filesize = ucs2stat_size(filename); + info->filesize = filepath_size(filename); */ /* Open the target file. */ Modified: trunk/pmplib/lib/gmi/gmi_wav.c =================================================================== --- trunk/pmplib/lib/gmi/gmi_wav.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/gmi/gmi_wav.c 2007-02-06 04:06:42 UTC (rev 297) @@ -77,7 +77,7 @@ -int parse_listinfo(media_info_t* info, FILE *fp, uint32_t chunksize) +int parse_listinfo(media_info_t* info, FILE *fp, uint32_t chunksize, const char *charset) { int ret = 0; char buffer[1024]; @@ -109,23 +109,23 @@ switch (ch.id) { case 0x44525049: /* "IPRD" */ ucs2free(info->album); - info->album = mbsdupucs2_music(buffer); + info->album = mbsdupucs2_charset(buffer, charset); break; case 0x4D414E49: /* "INAM" */ ucs2free(info->title); - info->title = mbsdupucs2_music(buffer); + info->title = mbsdupucs2_charset(buffer, charset); break; case 0x54524149: /* "IART" */ ucs2free(info->artist); - info->artist = mbsdupucs2_music(buffer); + info->artist = mbsdupucs2_charset(buffer, charset); break; case 0x524E4749: /* "IGNR" */ ucs2free(info->genre); - info->genre = mbsdupucs2_music(buffer); + info->genre = mbsdupucs2_charset(buffer, charset); break; case 0x44524349: /* "ICRD" */ ucs2free(info->date); - info->date = mbsdupucs2_music(buffer); + info->date = mbsdupucs2_charset(buffer, charset); break; case 0x6974726B: /* "itrk" */ info->track_number = atoi(buffer); @@ -147,7 +147,7 @@ } -int get_riff_audio_info(media_info_t* info, const ucs2char_t *filename) +int get_riff_audio_info(media_info_t* info, const ucs2char_t *filename, const char *charset) { int ret = 0; FILE *fp = NULL; @@ -235,7 +235,7 @@ goto get_riff_audio_info_error; } if (tmp32 == 0x4F464E49) { - ret |= parse_listinfo(info, fp, ch.size - 4); + ret |= parse_listinfo(info, fp, ch.size - 4, charset); if (ret != 0) { goto get_riff_audio_info_error; } @@ -254,11 +254,11 @@ return -1; } -int gmi_wav(media_info_t* info, const ucs2char_t *filename) +int gmi_wav(media_info_t* info, const ucs2char_t *filename, const char *charset) { int ret = 0; - ret = get_riff_audio_info(info, filename); + ret = get_riff_audio_info(info, filename, charset); if (ret == 0) { info->codec = PMPCODEC_WAV; } Modified: trunk/pmplib/lib/gmi/gmi_wma.c =================================================================== --- trunk/pmplib/lib/gmi/gmi_wma.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/gmi/gmi_wma.c 2007-02-06 04:06:42 UTC (rev 297) @@ -130,14 +130,14 @@ /* Skip space. */ pos--; while (begin <= pos) { - if (!isucs2space(*pos)) { + if (!ucs2isspace(*pos)) { break; } pos--; } /* Skip digits. */ while (begin <= pos) { - if (!isucs2digit(*pos)) { + if (!ucs2isdigit(*pos)) { pos++; break; } @@ -507,7 +507,7 @@ return -1; } -int gmi_wma(media_info_t* info, const ucs2char_t *filename) +int gmi_wma(media_info_t* info, const ucs2char_t *filename, const char *charset) { int ret = 0; Modified: trunk/pmplib/lib/playlist/jspl.c =================================================================== --- trunk/pmplib/lib/playlist/jspl.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/playlist/jspl.c 2007-02-06 04:06:42 UTC (rev 297) @@ -448,7 +448,7 @@ mbsfilename = ucs2dupmbs(filename); /* Obtain the filesize. */ - filesize = ucs2stat_size(filename); + filesize = filepath_size(filename); /* Read the entire file at one time. */ buff = (char*)malloc(filesize+1); Modified: trunk/pmplib/lib/pmp_portalplayer1/pp1db.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pp1db.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/pmp_portalplayer1/pp1db.c 2007-02-06 04:06:42 UTC (rev 297) @@ -414,6 +414,25 @@ return ret; } +static int is_bigendian(void) +{ + ucs2char_t c = 0x1234; + uint8_t* p = (uint8_t*)&c; + return (*p == 0x12); +} + +static void ucs2big2little(ucs2char_t* value) +{ + if (is_bigendian()) { + for (;*value;value++) { + ucs2char_t val = (*value << 8) | (*value >> 8); + *value = val; + } + } +} + + + static uint32_t ucs2crc(const ucs2char_t* value) { if (value) { Modified: trunk/pmplib/lib/ucs2/ucs2char.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/ucs2/ucs2char.c 2007-02-06 04:06:42 UTC (rev 297) @@ -59,17 +59,17 @@ free(str); } -int is_ucs2surrogate(ucs2char_t c) +int ucs2issurrogate(ucs2char_t c) { return (0xD800 <= c && c <= 0xDFFF); } -int isucs2space(ucs2char_t c) +int ucs2isspace(ucs2char_t c) { return ((0x0009 <= c && c <= 0x000D) || c == 0x0020); } -int isucs2digit(ucs2char_t c) +int ucs2isdigit(ucs2char_t c) { return (0x0030 <= c && c <= 0x0039); } @@ -299,14 +299,14 @@ if (str && *str) { ucs2char_t* p = NULL; for (p = str + ucs2len(str) - 1;str <= p;p--) { - if (!isucs2space(*p)) { + if (!ucs2isspace(*p)) { *(p + 1) = 0; break; } } for (p = str;p < str + ucs2len(str);p++) { - if (!isucs2space(*p)) { + if (!ucs2isspace(*p)) { break; } } @@ -381,12 +381,12 @@ return dst; } -ucs2char_t* mbsdupucs2_music(const char *mbstr) +ucs2char_t* mbsdupucs2_charset(const char *mbstr, const char *charset) { - size_t ucs2_size = mbstoucs2_music(NULL, 0, mbstr, strlen(mbstr)) + 1; + size_t ucs2_size = mbstoucs2_charset(NULL, 0, mbstr, strlen(mbstr), charset) + 1; ucs2char_t* dst = (ucs2char_t*)malloc(ucs2_size * sizeof(ucs2char_t)); if (dst) { - mbstoucs2_music(dst, ucs2_size * sizeof(ucs2char_t), mbstr, strlen(mbstr)+1); + mbstoucs2_charset(dst, ucs2_size * sizeof(ucs2char_t), mbstr, strlen(mbstr)+1, charset); } return dst; } Modified: trunk/pmplib/lib/ucs2/ucs2char_iconv.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-06 04:06:42 UTC (rev 297) @@ -39,11 +39,17 @@ #include <iconv.h> -/** - * \addtogroup ucs2 - * @{ - */ +#ifdef HAVE_LANGINFO_CODESET +#include <langinfo.h> +#endif + +struct tag_ucs2conv { + const char *from; + const char *to; +}; +typedef struct tag_ucs2conv ucs2conv_t; + #ifdef USE_LIBICONV_GNU #define iconv_open libiconv_open #define iconv_convert libiconv_convert @@ -57,9 +63,20 @@ #define MBS_CHARSET "UTF-8" static char g_encoding[128]; -static char g_encoding_music[128]; static char g_ucs2encoding[128]; +static char *get_default_encoding() +{ + const char *encoding = getenv("CHARSET"); + +#ifdef HAVE_LANGINFO_CODESET + if (!encoding) { + encoding = nl_langinfo(CODESET); + } +#endif + return encoding ? strdup(encoding) : strdup("UTF-8"); +} + static void print_ucs2(const ucs2char_t* str) { while (*str) { @@ -69,13 +86,6 @@ fprintf(stderr, "\n"); } -static int is_bigendian(void) -{ - ucs2char_t c = 0x1234; - uint8_t* p = (uint8_t*)&c; - return (*p == 0x12); -} - static const char *get_ucs2encoding(void) { static const char *unicode_big = "UNICODEBIG"; @@ -83,13 +93,12 @@ return is_bigendian() ? unicode_big : unicode_little; } -int ucs2init(const char *encoding) +int ucs2init() { if (!encoding) { encoding = MBS_CHARSET; } strcpy(g_encoding, encoding); - strcpy(g_encoding_music, encoding); } static int ucs2check(ucs2conv_t* conv) @@ -127,31 +136,16 @@ return 0; } -int ucs2set_encoding(const char *encoding, ucs2conv_t* conv) +int ucs2setenc(const char *encoding) { + int ret = 0; + ucs2conv_t conv; strncpy(g_encoding, encoding, sizeof(g_encoding)); strncpy(g_ucs2encoding, get_ucs2encoding(), sizeof(g_ucs2encoding)); - return ucs2check(conv); + return ucs2check(&conv); } -int ucs2set_encoding_music(const char *encoding, ucs2conv_t* conv) -{ - strncpy(g_encoding_music, encoding, sizeof(g_encoding_music)); - strncpy(g_ucs2encoding, get_ucs2encoding(), sizeof(g_ucs2encoding)); - return ucs2check(conv); -} - -void ucs2big2little(ucs2char_t* value) -{ - if (is_bigendian()) { - for (;*value;value++) { - ucs2char_t val = (*value << 8) | (*value >> 8); - *value = val; - } - } -} - int ucs2toi(const ucs2char_t* str) { int ret; @@ -267,7 +261,7 @@ return fp; } -time_t ucs2stat_mtime(const ucs2char_t *filename) +time_t filepath_mtime(const ucs2char_t *filename) { int ret = 0; struct stat st; @@ -284,7 +278,7 @@ return 0; } -uint32_t ucs2stat_size(const ucs2char_t *filename) +uint32_t filepath_size(const ucs2char_t *filename) { int ret = 0; struct stat st; @@ -301,7 +295,7 @@ return 0; } -int ucs2stat_is_dir(const ucs2char_t *filename) +int filepath_is_dir(const ucs2char_t *filename) { int ret = 0; struct stat st; @@ -318,7 +312,7 @@ return 0; } -int ucs2stat_is_exist(const ucs2char_t *filename) +int filepath_exist(const ucs2char_t *filename) { int ret = 0; struct stat st; @@ -336,5 +330,3 @@ } return 0; } - -/** @} */ Modified: trunk/pmplib/lib/ucs2/ucs2char_win32.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char_win32.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/ucs2/ucs2char_win32.c 2007-02-06 04:06:42 UTC (rev 297) @@ -29,8 +29,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/types.h> -#include <sys/stat.h> #include <ucs2char.h> #ifdef _WIN32 @@ -42,14 +40,16 @@ #endif static UINT g_codepage = CP_ACP; +static const char *g_encoding = ""; -void ucs2set_codepage(int cp) +void ucs2setcp(int cp) { g_codepage = (UINT)cp; } -void ucs2big2little(ucs2char_t* value) +UCS2API const char *ucs2getenc() { + return g_encoding; } int ucs2toi(const ucs2char_t* str) @@ -73,7 +73,7 @@ return MultiByteToWideChar(g_codepage, 0, mbstr, (int)mbs_len, ucs2str, (int)ucs_len); } -size_t mbstoucs2_music(ucs2char_t *ucs2str, size_t ucs_len, const char *mbstr, size_t mbs_len) +size_t mbstoucs2_charset(ucs2char_t *ucs2str, size_t ucs_len, const char *mbstr, size_t mbs_len, const char *charset) { return MultiByteToWideChar(g_codepage, 0, mbstr, (int)mbs_len, ucs2str, (int)ucs_len); } @@ -120,36 +120,3 @@ } return fp; } - -time_t ucs2stat_mtime(const ucs2char_t *filename) -{ - int ret = 0; - struct _stat st; - ret = _wstat(filename, &st); - if (ret == 0) { - return st.st_mtime; - } - return 0; -} - -uint32_t ucs2stat_size(const ucs2char_t *filename) -{ - int ret = 0; - struct _stat st; - ret = _wstat(filename, &st); - if (ret == 0) { - return st.st_size; - } - return 0; -} - -int ucs2stat_is_dir(const ucs2char_t *filename) -{ - int ret = 0; - struct _stat st; - ret = _wstat(filename, &st); - if (ret == 0) { - return ((st.st_mode & S_IFMT) == S_IFDIR); - } - return 0; -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |