From: <ny...@us...> - 2007-02-09 17:19:10
|
Revision: 320 http://svn.sourceforge.net/pmplib/?rev=320&view=rev Author: nyaochi Date: 2007-02-09 08:13:11 -0800 (Fri, 09 Feb 2007) Log Message: ----------- Documentation of pmp.h Modified Paths: -------------- trunk/pmplib/frontend/easypmp/cui/device.c trunk/pmplib/include/pmplib/pmp.h trunk/pmplib/lib/filepath/filepath.vcproj trunk/pmplib/lib/pmp/pmp.vcproj trunk/pmplib/lib/pmp/pmp_win32.c trunk/pmplib/lib/pmp_iriverplus2/idx.c trunk/pmplib/lib/pmp_iriverplus2/ip2db.c trunk/pmplib/lib/pmp_iriverplus2/ip2db_dat.c trunk/pmplib/lib/pmp_iriverplus2/ip2db_idx.c trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c trunk/pmplib/lib/pmp_portalplayer1/pp1db.c trunk/pmplib/lib/ucs2/ucs2.vcproj Modified: trunk/pmplib/frontend/easypmp/cui/device.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/device.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/frontend/easypmp/cui/device.c 2007-02-09 16:13:11 UTC (rev 320) @@ -40,13 +40,6 @@ * @{ */ -static void device_show_pathflag(int flag, FILE* fp) -{ - if (flag & PMPPEF_RECURSIVE) { - fprintf(fp, " sub_directory=yes"); - } -} - // Display a path name using the given string format. void device_show_path(FILE *fp, const char* const format, const ucs2char_t* const path) { Modified: trunk/pmplib/include/pmplib/pmp.h =================================================================== --- trunk/pmplib/include/pmplib/pmp.h 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/include/pmplib/pmp.h 2007-02-09 16:13:11 UTC (rev 320) @@ -24,6 +24,8 @@ #ifndef __PMP_H__ #define __PMP_H__ +#include <pmplib/os_types.h> + #ifdef PMP_EXPORTS #define PMPAPI __declspec(dllexport) #else @@ -55,24 +57,31 @@ struct tag_pmp_music_t; typedef struct tag_pmp_music_t pmp_music_t; /** - * Error codes. + * Status codes. */ enum { + /** Success. */ PMP_SUCCESS = 0, - PMP_DEVICENOTFOUND, - PMP_NOTSUPPORTED, - PMP_INSUFFICIENTMEMORY, - PMP_NOTIMPLIMENTED, - PMPDBE_OUTOFMEMORY, - PMPDBE_NOTFOUND, - PMPDBE_INVALIDTYPE, - PMPDBE_DBINCONSIST, - PMPDBE_NOTINITIALIZED, - PMPDBE_INVALIDLEAFID, - PMPDBE_OPENFORREAD, - PMPDBE_OPENFORWRITE, - PMPDBE_INSUFFICIENT, - PMPPLE_WRITE, + /** Undetermined error. */ + PMPERR_ERROR = 0x80000000, + /** Device is not found or unsupported. */ + PMPERR_DEVICENOTFOUND, + /** Insufficient memory. */ + PMPERR_INSUFFICIENTMEMORY, + /** Operation is not implemented. */ + PMPERR_NOTIMPLIMENTED, + /** The entry is not found. */ + PMPERR_ENTRYNOTFOUND, + /** Inconsistent operation/data. */ + PMPERR_INCONSISTENCY, + /** Error while opening a file for reading. */ + PMPERR_OPENFORREAD, + /** Error while opening a file for writing. */ + PMPERR_OPENFORWRITE, + /** Error while reading a file. */ + PMPERR_READ, + /** Error while writing a file. */ + PMPERR_WRITE, }; /** @@ -108,33 +117,34 @@ #define PMPFOURCC(a, b, c, d) \ ((uint32_t)(a) << 24 | (uint32_t)(b) << 16 | (uint32_t)(c) << 8 | (uint32_t)(d)) -#define PMPCODEC_NONE PMPFOURCC(' ',' ',' ',' ') /**< Unknown codec. */ -#define PMPCODEC_MPEGLAYER3 PMPFOURCC('M','P','1','3') /**< MPEG Audio Layer III */ -#define PMPCODEC_WMA PMPFOURCC('W','M','A',' ') /**< Windows Media Audio */ -#define PMPCODEC_VORBIS PMPFOURCC('O','V','1',' ') /**< Ogg Vorbis */ -#define PMPCODEC_WAV PMPFOURCC('W','A','V','E') /**< Microsoft Riff WAVE */ +/** Unknown codec. */ +#define PMPCODEC_NONE PMPFOURCC(' ',' ',' ',' ') +/** MPEG Audio Layer III. */ +#define PMPCODEC_MPEGLAYER3 PMPFOURCC('M','P','1','3') +/** Windows Media Audio. */ +#define PMPCODEC_WMA PMPFOURCC('W','M','A',' ') +/** Ogg Vorbis. */ +#define PMPCODEC_VORBIS PMPFOURCC('O','V','1',' ') +/** Microsoft Riff WAVE. */ +#define PMPCODEC_WAV PMPFOURCC('W','A','V','E') +/** + * Flags for device functionality. + */ enum { - PMPPEF_NONE = 0x0000, - PMPPEF_SUPPORT = 0x0001, - PMPPEF_CONSTANT = 0x0002, - PMPPEF_RECURSIVE = 0x0004, -}; - -enum { - PMPMF_NONE = 0x0000, + /** None. */ + PMPF_NONE = 0x0000, + /** The device supports music database. */ PMPMF_SUPPORT = 0x0001, + /** The device supports subdirs under music directory. */ PMPMF_RECURSIVE = 0x0002, + /** The device supports music playlist. */ + PMPPF_SUPPORT = 0x0010, + /** The device supports subdirs under playlist directory. */ + PMPPF_RECURSIVE = 0x0020, }; -enum { - PMPPF_NONE = 0x0000, - PMPPF_SUPPORT = 0x0001, - PMPPF_RECURSIVE = 0x0002, -}; - - /** * @defgroup device PMPlib Device API * @{ @@ -410,9 +420,23 @@ }; typedef struct tag_pmp_music_record_t pmp_music_record_t; +/** + * Structure for a playlist. + */ typedef struct { + /** + * Name of the playlist. + */ ucs2char_t *name; + + /** + * The number of entries in the playlist. + */ int num_entries; + + /** + * Pointer to an array of entries referring to media files. + */ ucs2char_t **entries; } pmp_playlist_t; @@ -615,30 +639,155 @@ */ PMPAPI result_t pmplib_records_clone(pmp_music_record_t* dst, const pmp_music_record_t* src, int num_records); +/** + * Initialize pmp_playlist_t structure. + * + * @param playlist The pointer to pmp_playlist_t instance. + */ PMPAPI void pmplib_playlist_init(pmp_playlist_t* playlist); + +/** + * Uninitialize pmp_playlist_t structure. + * + * This function frees the memory blocks used by the \a playlist. + * + * @param playlist The pointer to pmp_playlist_t instance. + */ PMPAPI void pmplib_playlist_finish(pmp_playlist_t* playlist); + +/** + * Clone a playlist. + * + * This function copies the values in the \a src playlist to \a dst. + * + * @param dst The pointer to the destination. + * @param src The pointer to the source. + */ PMPAPI void pmplib_playlist_clone(pmp_playlist_t* dst, const pmp_playlist_t* src); -PMPAPI void pmplib_playlists_finish(pmp_playlist_t* playlist, int num_playlists); +/** + * Uninitialize an array of pmp_playlist_t playlists. + * + * This function frees the memory blocks used by each playlist in the array and + * the array itself. + * + * @param playlists The pointer to pmp_playlist_t array. + * @param num_playlists The number of elements in the array. + */ +PMPAPI void pmplib_playlists_finish(pmp_playlist_t* playlists, int num_playlists); + +/** + * Clone a pmp_playlist_t array. + * + * This function copies all playlists in the \a src array to \a dst. + * + * @param dst The destination array. + * @param src The source array. + * @param num_records The number of elements in the source array. + */ PMPAPI void pmplib_playlists_clone(pmp_playlist_t* dst, const pmp_playlist_t* src, int num_playlists); /** * @} */ +/** + * \addtogroup pmp_export Export functions of a driver module + * @{ + */ -typedef result_t (*pmplib_create_t)(pmp_t** pmp, const ucs2char_t* path_to_device, const char *devid); +/** + * Prototype of a callback function receiving device IDs from pmplib_create(). + * + * @param instance The user-defined instance value. + * @param devid The device identifier. + */ +typedef void (*pmplib_enumerate_devid_callback_t)(void *instance, const char *devid); /** - * Prototype for the callback function for receiving device identifiers. + * Query a driver and construct a ::pmp_t instance. + * + * This function queries the driver suitable for the portable media device + * specified by the mount location and/or identifier. A driver module must + * return the interface to the driver (::pmp_t instance) if it supports + * the device. Parameter \a path_to_device is expected to be specified. If + * parameter \a id is not \c NULL, the driver module should return the + * interface to the driver with the device identifier specified in \a id + * parameter. If the parameter \a id is \c NULL, the driver module should + * recognize the model of the device based on the content of the files located + * under \a path_to_device. + * + * @param path_to_device A UCS-2 string representing the location of the + * target device. This parameter cannot be \c NULL. + * @param id A C-string representing the device identifier of + * the target device. If this argument is \c NULL, + * this function tries to recognize the model of the + * device based on the location (\a path_to_device). + * @retval ptr_pmp The pointer to the buffer to receive the pointer + * to the driver interface (::pmp_t instance). + * @retval result_t The status code. + * + * @assert + * @code ptr_pmp != NULL @endcode + * @code path_to_device != NULL @endcode + */ +typedef result_t (*pmplib_create_t)(pmp_t** ptr_pmp, const ucs2char_t* path_to_device, const char *id); + +/** + * Enumerate device identifiers supported by the driver module. * + * The driver module should enumerate the device identifiers supported + * by the module and invoke the \a callback function for each identifier. + * + * @param callback The pointer to the callback function to receive + * device identifiers. + * @param instance A user-defined instance value. The callback + * function will receive the same value. + * @retval result_t The status code. + * + * @assert + * @code callback != NULL @endcode */ -typedef void (*pmplib_enumerate_devid_callback_t)(void *instance, const char *devid); typedef result_t (*pmplib_enumerate_devid_t)(pmplib_enumerate_devid_callback_t callback, void *instance); +/** + * @} + */ + +/** + * \addtogroup pmp_driver Driver utility API + * @{ + */ + +/** + * Increment a variable value and check the resultant value. + * + * This function prevents more than one thread from using + * pmplib_interlocked_increment() or pmplib_interlocked_decrement() function + * to access the same variable simultaneously. + * + * @param count The pointer to the variable whose value is to be + * increased. + * @retval uint32_t The value of the variable after this increment. + */ PMPAPI uint32_t pmplib_interlocked_increment(uint32_t* count); + +/** + * Decrement a variable value and check the resultant value. + * + * This function prevents more than one thread from using + * pmplib_interlocked_increment() or pmplib_interlocked_decrement() function + * to access the same variable simultaneously. + * + * @param count The pointer to the variable whose value is to be + * decreased. + * @retval uint32_t The value of the variable after this decrement. + */ PMPAPI uint32_t pmplib_interlocked_decrement(uint32_t* count); +/** + * @} + */ @@ -671,8 +820,8 @@ * the device connected to the mount point (Win32 path "D:\"): * * @code - * #include <ucs2char.h> - * #include <pmp.h> + * #include <pmplib/ucs2char.h> + * #include <pmplib/pmp.h> * * int main(int argc, char *argv[]) * { Modified: trunk/pmplib/lib/filepath/filepath.vcproj =================================================================== --- trunk/pmplib/lib/filepath/filepath.vcproj 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/filepath/filepath.vcproj 2007-02-09 16:13:11 UTC (rev 320) @@ -159,7 +159,7 @@ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > <File - RelativePath="..\..\include\filepath.h" + RelativePath="..\..\include\pmplib\filepath.h" > </File> </Filter> Modified: trunk/pmplib/lib/pmp/pmp.vcproj =================================================================== --- trunk/pmplib/lib/pmp/pmp.vcproj 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp/pmp.vcproj 2007-02-09 16:13:11 UTC (rev 320) @@ -204,7 +204,7 @@ > </File> <File - RelativePath="..\..\include\pmp.h" + RelativePath="..\..\include\pmplib\pmp.h" > </File> </Filter> Modified: trunk/pmplib/lib/pmp/pmp_win32.c =================================================================== --- trunk/pmplib/lib/pmp/pmp_win32.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp/pmp_win32.c 2007-02-09 16:13:11 UTC (rev 320) @@ -116,13 +116,13 @@ result_t pmplib_create(pmplib_t* pmplib, pmp_t** pmp, const ucs2char_t* path_to_device, const char *id) { uint32_t i; - result_t ret = PMP_DEVICENOTFOUND; + result_t ret = PMPERR_DEVICENOTFOUND; for (i = 0;i < pmplib->num_plugins;++i) { pmplib_create_t func = (pmplib_create_t)GetProcAddress(pmplib->plugins[i], "pmp_create"); if (func) { ret = func(pmp, path_to_device, id); - if (ret != PMP_DEVICENOTFOUND) { + if (ret != PMPERR_DEVICENOTFOUND) { return ret; } } Modified: trunk/pmplib/lib/pmp_iriverplus2/idx.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/idx.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_iriverplus2/idx.c 2007-02-09 16:13:11 UTC (rev 320) @@ -153,7 +153,7 @@ /* Check key type. */ if (idxkey->type < IP2DBIDX_PAGE_NODE_ENTRYNUMBER || IP2DBIDX_PAGE_NODE_FORMAT < idxkey->type) { - return PMPDBE_INVALIDTYPE; + return PMPERR_INCONSISTENCY; } *leafid = 0; @@ -172,14 +172,14 @@ ret = 0; } else { *leafid = 0; - ret = PMPDBE_NOTFOUND; + ret = PMPERR_ENTRYNOTFOUND; } break; } else { node = child; } } else { - ret = PMPDBE_NOTFOUND; + ret = PMPERR_ENTRYNOTFOUND; break; /* Not found. */ } } Modified: trunk/pmplib/lib/pmp_iriverplus2/ip2db.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/ip2db.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_iriverplus2/ip2db.c 2007-02-09 16:13:11 UTC (rev 320) @@ -76,7 +76,7 @@ // Read dat. fp = ucs2fopen(dat_filename, "rb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } ret = ip2dbdat_read(db, fp); if (ret != 0) { @@ -88,7 +88,7 @@ // Read idx. fp = ucs2fopen(idx_filename, "rb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } ret = ip2dbidx_read(db, fp); if (ret != 0) { @@ -110,7 +110,7 @@ filepath_removefile(dat_filename); fp = ucs2fopen(dat_filename, "wb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } ret = ip2dbdat_write(db, fp); if (ret != 0) { @@ -123,7 +123,7 @@ filepath_removefile(idx_filename); fp = ucs2fopen(idx_filename, "wb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } ret = ip2dbidx_write(db, fp); if (ret != 0) { @@ -175,7 +175,7 @@ // Allocate IP2DB records. ip2db_records = (ip2db_record_t*)calloc(n, sizeof(ip2db_record_t)); if (!ip2db_records) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } // Convert records from pmp_music_record_t to ip2db_record_t. @@ -257,7 +257,7 @@ if (*num_records < n) { *num_records = n; - return PMPDBE_INSUFFICIENT; + return PMPERR_INSUFFICIENTMEMORY; } for (i = 1, j = 0;i <= n;++i) { // recid starts at 1. @@ -355,7 +355,7 @@ /* Check if the leafid is valid. */ if (recid < 1 || ip2db_get_num_record(db) < recid) { - return PMPDBE_INVALIDLEAFID; + return PMPERR_INCONSISTENCY; } /* Fill the record from an element of dat array. */ Modified: trunk/pmplib/lib/pmp_iriverplus2/ip2db_dat.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/ip2db_dat.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_iriverplus2/ip2db_dat.c 2007-02-09 16:13:11 UTC (rev 320) @@ -66,7 +66,7 @@ db->dat_size = num_records; if (!db->dat_array) { db->dat_size = 0; - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } // Just set records. @@ -116,7 +116,7 @@ uint8_t *p = NULL; uint8_t *dat_buffer = malloc(DAT_SIZE_PER_RECORD * db->dat_size); if (!dat_buffer) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } p = dat_buffer; Modified: trunk/pmplib/lib/pmp_iriverplus2/ip2db_idx.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/ip2db_idx.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_iriverplus2/ip2db_idx.c 2007-02-09 16:13:11 UTC (rev 320) @@ -50,12 +50,12 @@ if (!sortitems) { free(idxkeys); free(sortitems); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } if (!idxkeys) { free(idxkeys); free(sortitems); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } for (type = IP2DBIDX_PAGE_NODE_ENTRYNUMBER;type <= IP2DBIDX_PAGE_NODE_FORMAT;++type) { Modified: trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-02-09 16:13:11 UTC (rev 320) @@ -349,13 +349,13 @@ } } if (!md->id) { - return PMP_DEVICENOTFOUND; + return PMPERR_DEVICENOTFOUND; } // Allocate PMP class instance. pmp = (pmp_t*)calloc(1, sizeof(pmp_t)); if (!pmp) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmp->add_ref = pmp_add_ref; @@ -368,7 +368,7 @@ pmpi = (pmp_internal_t*)calloc(1, sizeof(pmp_internal_t)); if (!pmpi) { free(pmp); - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmpi->decl = md; @@ -444,13 +444,13 @@ music = calloc(1, sizeof(pmp_music_t)); if (!music) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmpmi = calloc(1, sizeof(pmp_music_internal_t)); if (!pmpmi) { free(music); - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } ip2db_init(&pmpmi->ip2db); @@ -543,7 +543,7 @@ pmp->info.path_to_playlist, plp_ext ) != 0) { - return PMPPLE_WRITE; + return PMPERR_WRITE; } } } @@ -579,7 +579,7 @@ pmplib_records_clone(records, pmpmi->records, pmpmi->num_records); return 0; } else { - return PMPDBE_INSUFFICIENT; + return PMPERR_INSUFFICIENTMEMORY; } } Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-02-09 16:13:11 UTC (rev 320) @@ -345,13 +345,13 @@ } } if (!md->id) { - return PMP_DEVICENOTFOUND; + return PMPERR_DEVICENOTFOUND; } // Allocate PMP class instance. pmp = (pmp_t*)calloc(1, sizeof(pmp_t)); if (!pmp) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmp->add_ref = pmp_add_ref; @@ -364,7 +364,7 @@ pmpi = (pmp_internal_t*)calloc(1, sizeof(pmp_internal_t)); if (!pmpi) { free(pmp); - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmpi->decl = md; @@ -440,13 +440,13 @@ music = calloc(1, sizeof(pmp_music_t)); if (!music) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmpmi = calloc(1, sizeof(pmp_music_internal_t)); if (!pmpmi) { free(music); - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } ip3db_init(&pmpmi->ip3db); @@ -656,7 +656,7 @@ pmplib_records_clone(records, pmpmi->records, pmpmi->num_records); return 0; } else { - return PMPDBE_INSUFFICIENT; + return PMPERR_INSUFFICIENTMEMORY; } } @@ -664,7 +664,7 @@ { pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; if (level > 0) { - return PMP_NOTIMPLIMENTED; + return PMPERR_NOTIMPLIMENTED; //return ip2db_repr(&pmpdbi->ip2db, fp); } else { return ip3db_dump(&pmpmi->ip3db, fp); Modified: trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c =================================================================== --- trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-02-09 16:13:11 UTC (rev 320) @@ -176,13 +176,13 @@ // Fail if this library does not support the player. if (model == MODEL_NONE) { - return PMP_DEVICENOTFOUND; + return PMPERR_DEVICENOTFOUND; } // Create a PMP instance. pmp = (pmp_t*)calloc(1, sizeof(pmp_t)); if (!pmp) { - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } // Set member methods. @@ -196,7 +196,7 @@ pmpi = (pmp_internal_t*)calloc(1, sizeof(pmp_internal_t)); if (!pmpi) { pmp_release(pmp); - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmp->instance = pmpi; @@ -310,13 +310,13 @@ music = calloc(1, sizeof(pmp_music_t)); if (!music) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmpmi = calloc(1, sizeof(pmp_music_internal_t)); if (!pmpmi) { free(music); - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } irivnavi_init(&pmpmi->db); @@ -363,24 +363,24 @@ ucs2cat(filename, ucs2cs_irivnavi_idb); fp = ucs2fopen(filename, "rb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } // Obtain the stream size. if (fseek(fp, 0, SEEK_END) != 0) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } if ((size = ftell(fp)) == -1) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } if (fseek(fp, 0, SEEK_SET) != 0) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } // Allocate a buffer that stores the whole data. buffer = (uint8_t*)malloc(size); if (!buffer) { - ret = PMPDBE_OUTOFMEMORY; + ret = PMPERR_INSUFFICIENTMEMORY; goto error_exit; } @@ -389,7 +389,7 @@ // Read the data from the buffer. if (irivnavi_serialize(&pmpmi->db, buffer, 0) == 0) { - ret = PMPDBE_DBINCONSIST; + ret = PMPERR_INCONSISTENCY; goto error_exit; } @@ -464,7 +464,7 @@ // Initialize the record array. if (irivnavi_init_records(&pmpmi->db, pmpmi->num_records) != 0) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } // Convert records from pmp_music_record_t to ip2db_record_t. @@ -493,7 +493,7 @@ filepath_removefile(filename); fp = ucs2fopen(filename, "wb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } irivnavi_update(&pmpmi->db); @@ -501,13 +501,13 @@ // Allocate a buffer that stores the whole data. buffer = (uint8_t*)malloc(pmpmi->db.size); if (!buffer) { - ret = PMPDBE_OUTOFMEMORY; + ret = PMPERR_INSUFFICIENTMEMORY; goto error_exit; } // Write the data to the buffer. if (irivnavi_serialize(&pmpmi->db, buffer, 1) == 0) { - ret = PMPDBE_DBINCONSIST; + ret = PMPERR_INCONSISTENCY; goto error_exit; } @@ -539,7 +539,7 @@ pl->num_entries, path_to_root ) != 0) { - return PMPPLE_WRITE; + return PMPERR_WRITE; } } } @@ -580,7 +580,7 @@ pmplib_records_clone(records, pmpmi->records, pmpmi->num_records); return 0; } else { - return PMPDBE_INSUFFICIENT; + return PMPERR_INSUFFICIENTMEMORY; } } Modified: trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-02-09 16:13:11 UTC (rev 320) @@ -489,13 +489,13 @@ } } if (!md->id) { - return PMP_DEVICENOTFOUND; + return PMPERR_DEVICENOTFOUND; } // Allocate PMP class instance. pmp = (pmp_t*)calloc(1, sizeof(pmp_t)); if (!pmp) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmp->add_ref = pmp_add_ref; @@ -508,7 +508,7 @@ pmpi = (pmp_internal_t*)calloc(1, sizeof(pmp_internal_t)); if (!pmpi) { free(pmp); - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmpi->decl = md; @@ -584,13 +584,13 @@ music = calloc(1, sizeof(pmp_music_t)); if (!music) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmpmi = calloc(1, sizeof(pmp_music_internal_t)); if (!pmpmi) { free(music); - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pp1db_init(&pmpmi->pp1db, pmpi->decl->hdr_initproc); @@ -681,7 +681,7 @@ pmp->info.path_to_playlist, plp_ext ) != 0) { - return PMPPLE_WRITE; + return PMPERR_WRITE; } } } @@ -717,7 +717,7 @@ pmplib_records_clone(records, pmpmi->records, pmpmi->num_records); return 0; } else { - return PMPDBE_INSUFFICIENT; + return PMPERR_INSUFFICIENTMEMORY; } } Modified: trunk/pmplib/lib/pmp_portalplayer1/pp1db.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pp1db.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_portalplayer1/pp1db.c 2007-02-09 16:13:11 UTC (rev 320) @@ -98,13 +98,13 @@ uint32_t i, j; if (!db->hdr) { - return PMPDBE_DBINCONSIST; + return PMPERR_INCONSISTENCY; } // Read hdr. fp = ucs2fopen(hdr_filename, "rb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } ret = fread_all(fp, &buffer, &size); if (ret != 0) { @@ -129,7 +129,7 @@ fp = ucs2fopen(filename, "rb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } ret = fread_all(fp, &buffer, &size); if (ret != 0) { @@ -139,7 +139,7 @@ db->dat = calloc(db->hdr->num_dat_entries, sizeof(dat_t)); if (!db->dat) { fclose(fp); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } for (j = 0;j < db->hdr->num_dat_entries;++j) { uint8_t *p = &buffer[db->hdr->dat_record_offset[j]]; @@ -153,7 +153,7 @@ ) <= 0) { free(buffer); fclose(fp); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } } free(buffer); @@ -163,7 +163,7 @@ db->idx = (idx_t**)calloc(db->hdr->num_dat_fields, sizeof(idx_t*)); if (!db->idx) { fclose(fp); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } // Read indices. @@ -178,7 +178,7 @@ fp = ucs2fopen(filename, "rb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } ret = fread_all(fp, &buffer, &size); if (ret != 0) { @@ -189,7 +189,7 @@ db->idx[i] = calloc(db->hdr->num_dat_entries, sizeof(idx_t)); if (!db->idx[i]) { fclose(fp); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } for (j = 0;j < db->hdr->num_dat_entries;++j) { p += idx_serialize(p, &db->idx[i][j], 0); @@ -213,7 +213,7 @@ uint32_t offset = 0; if (!db->hdr) { - return PMPDBE_DBINCONSIST; + return PMPERR_INCONSISTENCY; } // Write indices. @@ -227,13 +227,13 @@ fp = ucs2fopen(filename, "wb"); if (!fp) { - return PMPDBE_OPENFORWRITE; + return PMPERR_OPENFORWRITE; } buffer = calloc(db->hdr->num_dat_entries, sizeof(idx_t)); if (!buffer) { fclose(fp); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } p = buffer; @@ -254,12 +254,12 @@ fp = ucs2fopen(filename, "wb"); if (!fp) { - return PMPDBE_OPENFORWRITE; + return PMPERR_OPENFORWRITE; } p = buffer = calloc(db->hdr->num_dat_entries, field_descriptor_get_max_record_size(db->hdr)); if (!buffer) { fclose(fp); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } offset = 0; db->hdr->dat_record_offset[0] = offset; @@ -285,12 +285,12 @@ // Read hdr. fp = ucs2fopen(hdr_filename, "wb"); if (!fp) { - return PMPDBE_OPENFORWRITE; + return PMPERR_OPENFORWRITE; } buffer = calloc(db->hdr->param.size, 1); if (!buffer) { fclose(fp); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } hdr_serialize(buffer, db->hdr, 1); fwrite(buffer, 1, db->hdr->param.size, fp); @@ -305,7 +305,7 @@ uint32_t i, j; if (!db->hdr) { - return PMPDBE_DBINCONSIST; + return PMPERR_INCONSISTENCY; } hdr_repr(db->hdr, fp); @@ -458,7 +458,7 @@ sort_item_t* si = NULL; if (!db->hdr) { - return PMPDBE_NOTINITIALIZED; + return PMPERR_INCONSISTENCY; } dat_free_array(db->dat, db->hdr); @@ -474,7 +474,7 @@ db->dat = calloc(n, sizeof(dat_t)); if (!db->dat) { pp1db_finish(db); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } // Convert records from pmp_music_record_t to ip2db_record_t. @@ -498,7 +498,7 @@ si = calloc(n, sizeof(sort_item_t)); if (!si) { pp1db_finish(db); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } // Generate indices. @@ -509,7 +509,7 @@ db->idx[i] = calloc(n, sizeof(idx_t)); if (!db->idx[i]) { pp1db_finish(db); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } // Preparation for sorting records. @@ -562,7 +562,7 @@ // Check database consistency. if (db->hdr->num_dat_entries - db->hdr->num_dat_inactive_entries != n) { - return PMPDBE_DBINCONSIST; + return PMPERR_INCONSISTENCY; } if (!records) { @@ -572,7 +572,7 @@ if (*num_records < n) { *num_records = n; - return PMPDBE_INSUFFICIENT; + return PMPERR_INSUFFICIENTMEMORY; } for (i = 0, j = 0;i < db->hdr->num_dat_entries;++i) { Modified: trunk/pmplib/lib/ucs2/ucs2.vcproj =================================================================== --- trunk/pmplib/lib/ucs2/ucs2.vcproj 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/ucs2/ucs2.vcproj 2007-02-09 16:13:11 UTC (rev 320) @@ -163,7 +163,7 @@ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > <File - RelativePath="..\..\include\ucs2char.h" + RelativePath="..\..\include\pmplib\ucs2char.h" > </File> </Filter> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |