From: <ny...@us...> - 2007-01-26 00:37:56
|
Revision: 278 http://svn.sourceforge.net/pmplib/?rev=278&view=rev Author: nyaochi Date: 2007-01-25 16:37:56 -0800 (Thu, 25 Jan 2007) Log Message: ----------- Updated EasyPMP CUI progress reports. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/common/database.c trunk/pmplib/frontend/easypmp/common/easypmp.h trunk/pmplib/frontend/easypmp/common/playlist.c trunk/pmplib/frontend/easypmp/cui/device.c trunk/pmplib/frontend/easypmp/cui/main.c trunk/pmplib/frontend/easypmp/cui/option.c trunk/pmplib/frontend/easypmp/cui/option.h trunk/pmplib/pmp.sln Modified: trunk/pmplib/frontend/easypmp/common/database.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/database.c 2007-01-25 22:16:09 UTC (rev 277) +++ trunk/pmplib/frontend/easypmp/common/database.c 2007-01-26 00:37:56 UTC (rev 278) @@ -39,11 +39,6 @@ #include <gmi.h> #include <easypmp.h> -/** - * \addtogroup common - * @{ - */ - #ifdef _WIN32 #define COMP_STR(x, y) lstrcmpiW(x, y) /* FAT32 treats upper/lower letters as identical. */ #else @@ -99,8 +94,8 @@ int easypmp_database( - const easypmp_filelist_t* fl, pmp_t* pmp, + const easypmp_filelist_t* fl, const option_t* opt, pmp_music_record_t** ptr_records, uint32_t* ptr_num_records, @@ -118,25 +113,12 @@ uint32_t num_old_records = 0, num_obtained = 0; uint32_t ts_import = get_current_time(); - if (progress(instance, EASYPMPDBP_START, 0, 0, NULL) != 0) { - return EASYPMPE_CANCEL; - } - filepath_combinepath(music_path, MAX_PATH, pmp->info.path_to_root, pmp->info.path_to_music); /* * Read the existing database for update processing mode. */ if (opt->verb & MODE_DATABASE_UPDATE) { - /* - * Read the existing database for update processing mode. - */ - // Start reading a database. - if (progress(instance, EASYPMPDBP_READ | EASYPMPSP_START, 0, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } - // Obtain the number of records in the database. res = pmpdb->get_records(pmpdb, NULL, &num_old_records); if (res != 0) { @@ -160,11 +142,6 @@ // Sort the records for binary search. qsort(old_records, num_old_records, sizeof(pmp_music_record_t), comp_filename); - } else { - if (progress(instance, EASYPMPDBP_READ | EASYPMPSP_SKIPPED, 0, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } } /* @@ -179,7 +156,7 @@ /* * Obtain music information. */ - if (progress(instance, EASYPMPDBP_GMI | EASYPMPSP_START, fl->num_elements, 0, NULL) != 0) { + if (progress(instance, EASYPMPP_MUSIC_GMI | EASYPMPSP_START, fl->num_elements, 0, NULL) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } @@ -195,7 +172,7 @@ timestamp = (uint32_t)ucs2stat_mtime(filename); // Report the progress. - if (progress(instance, EASYPMPDBP_GMI | EASYPMPSP_PROGRESS, i, 0, filename) != 0) { + if (progress(instance, EASYPMPP_MUSIC_GMI | EASYPMPSP_PROGRESS, i, 0, filename) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } @@ -235,40 +212,21 @@ record->ts_import = ts_import; } } - if (progress(instance, EASYPMPDBP_GMI | EASYPMPSP_END, num_obtained, 0, NULL) != 0) { + if (progress(instance, EASYPMPP_MUSIC_GMI | EASYPMPSP_END, num_obtained, 0, NULL) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } - // Generate database. - if (progress(instance, EASYPMPDBP_UPDATE | EASYPMPSP_START, 0, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } res = pmpdb->set_records(pmpdb, records, fl->num_elements); if (res != 0) { result = MAKE_PMP_ERROR(res); goto error_exit; } - if (progress(instance, EASYPMPDBP_UPDATE | EASYPMPSP_END, 0, 0, NULL) != 0) { + if (progress(instance, EASYPMPP_MUSIC_UPDATE | EASYPMPSP_END, 0, 0, NULL) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } - if (progress(instance, EASYPMPDBP_WRITE | EASYPMPSP_START, 0, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } - if (progress(instance, EASYPMPDBP_WRITE | EASYPMPSP_END, 0, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } - - if (progress(instance, EASYPMPDBP_END, 0, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } - error_exit: /* * Free allocated memory. @@ -364,5 +322,3 @@ } return 0; } - -/** @} */ Modified: trunk/pmplib/frontend/easypmp/common/easypmp.h =================================================================== --- trunk/pmplib/frontend/easypmp/common/easypmp.h 2007-01-25 22:16:09 UTC (rev 277) +++ trunk/pmplib/frontend/easypmp/common/easypmp.h 2007-01-26 00:37:56 UTC (rev 278) @@ -36,17 +36,14 @@ */ enum { - EASYPMPDBP_START = 0x00010000, - EASYPMPDBP_READ = 0x00020000, - EASYPMPDBP_GMI = 0x00030000, - EASYPMPDBP_UPDATE = 0x00040000, - EASYPMPDBP_WRITE = 0x00050000, - EASYPMPDBP_END = 0x00060000, + EASYPMPP_START = 0x00010000, + EASYPMPP_OPEN = 0x00020000, + EASYPMPP_MUSIC_GMI = 0x00030000, + EASYPMPP_MUSIC_UPDATE = 0x00040000, + EASYPMPP_PLAYLIST_CONVERT = 0x02050000, + EASYPMPP_CLOSE = 0x00060000, + EASYPMPP_END = 0x00070000, - EASYPMPPLP_START = 0x01000000, - EASYPMPPLP_CONVERT = 0x02000000, - EASYPMPPLP_END = 0x03000000, - EASYPMPSP_START = 0x00000001, EASYPMPSP_PROGRESS = 0x00000002, EASYPMPSP_SKIPPED = 0x00000003, @@ -141,8 +138,8 @@ int easypmp_database( - const easypmp_filelist_t* fl, pmp_t* pmp, + const easypmp_filelist_t* fl, const option_t* opt, pmp_music_record_t** ptr_records, uint32_t* ptr_num_records, Modified: trunk/pmplib/frontend/easypmp/common/playlist.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/playlist.c 2007-01-25 22:16:09 UTC (rev 277) +++ trunk/pmplib/frontend/easypmp/common/playlist.c 2007-01-26 00:37:56 UTC (rev 278) @@ -48,7 +48,7 @@ static void callback_from_playlist(void *instance, int level, ucs2char_t* message) { - int phase = EASYPMPPLP_CONVERT; + int phase = EASYPMPP_PLAYLIST_CONVERT; callback_data_t* cd = (callback_data_t*)instance; switch (level) { @@ -93,12 +93,6 @@ filepath_combinepath(dstpath, MAX_PATH, pmp->info.path_to_root, pmp->info.path_to_playlist); - // Start playlist processing. - if (progress(instance, EASYPMPPLP_START, 0, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } - // Convert easypmp_filelist_t array to playlist_mediafile_t array. mediafiles = calloc(musics->num_elements, sizeof(playlist_mediafile_t)); if (musics->num_elements > 0 && !mediafiles) { @@ -114,7 +108,7 @@ playlist_normalize_prepare(mediafiles, musics->num_elements); // Start playlist conversion. - if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_START, playlists->num_elements, 0, NULL) != 0) { + if (progress(instance, EASYPMPP_PLAYLIST_CONVERT | EASYPMPSP_START, playlists->num_elements, 0, NULL) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } @@ -134,7 +128,7 @@ filepath_combinepath(src, MAX_PATH, plf_path, plf->filename); // Report the source filename. - if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_PROGRESS, i, 0, src) != 0) { + if (progress(instance, EASYPMPP_PLAYLIST_CONVERT | EASYPMPSP_PROGRESS, i, 0, src) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } @@ -175,7 +169,7 @@ // Skip an empty playlist. if (pl->num_entries == 0) { - if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_SKIP_PLAYLIST, i, 0, src) != 0) { + if (progress(instance, EASYPMPP_PLAYLIST_CONVERT | EASYPMPSP_SKIP_PLAYLIST, i, 0, src) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } @@ -193,13 +187,13 @@ if (n < pl->num_entries) { if ((opt->verb & MODE_PLAYLIST_SKIP) && 0 < n) { // Report a warning. - if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_WARN_PLAYLIST, i, 0, src) != 0) { + if (progress(instance, EASYPMPP_PLAYLIST_CONVERT | EASYPMPSP_WARN_PLAYLIST, i, 0, src) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } } else { // Report a error (skipping). - if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_SKIP_PLAYLIST, i, 0, src) != 0) { + if (progress(instance, EASYPMPP_PLAYLIST_CONVERT | EASYPMPSP_SKIP_PLAYLIST, i, 0, src) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } @@ -208,7 +202,7 @@ // Report missing media files. for (j = 0;j < pl->num_entries;++j) { if (!pl->entries[j].valid) { - if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_MISSING_MEDIA, i, 0, pl->entries[j].filename) != 0) { + if (progress(instance, EASYPMPP_PLAYLIST_CONVERT | EASYPMPSP_MISSING_MEDIA, i, 0, pl->entries[j].filename) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } @@ -248,17 +242,11 @@ music->set_playlists(music, pmppls, num_pmppls); // Finish playlist conversion. - if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_END, num_succeeded, 0, NULL) != 0) { + if (progress(instance, EASYPMPP_PLAYLIST_CONVERT | EASYPMPSP_END, num_succeeded, 0, NULL) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } - // Finish the whole processing. - if (progress(instance, EASYPMPPLP_END, 0, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } - error_exit: for (i = 0;i < num_pmppls;++i) { pmplib_playlist_finish(&pmppls[i]); Modified: trunk/pmplib/frontend/easypmp/cui/device.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/device.c 2007-01-25 22:16:09 UTC (rev 277) +++ trunk/pmplib/frontend/easypmp/cui/device.c 2007-01-26 00:37:56 UTC (rev 278) @@ -74,18 +74,18 @@ static void enumerate_devid_callback(void *instance, const char *devid) { - pmplib_t *pmphelp = (pmplib_t*)instance; + pmplib_t *pmplib = (pmplib_t*)instance; pmp_t* pmp = NULL; ucs2char_t ucs2cs_empty[] = {0}; - pmplib_create(pmphelp, &pmp, ucs2cs_empty, devid); + pmplib_create(pmplib, &pmp, ucs2cs_empty, devid); device_show_information(pmp, stdout); fprintf(stderr, "\n"); pmp->release(pmp); } -void device_enumerate(pmplib_t* pmphelp) +void device_enumerate(pmplib_t* pmplib) { - pmplib_enumerate_devid(pmphelp, enumerate_devid_callback, pmphelp); + pmplib_enumerate_devid(pmplib, enumerate_devid_callback, pmplib); } /** @} */ Modified: trunk/pmplib/frontend/easypmp/cui/main.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/main.c 2007-01-25 22:16:09 UTC (rev 277) +++ trunk/pmplib/frontend/easypmp/cui/main.c 2007-01-26 00:37:56 UTC (rev 278) @@ -51,18 +51,13 @@ #include <windows.h> #endif -/** - * \addtogroup cui - * @{ - */ - #define APPLICATION_S "EasyPMP [CUI]" #define VERSION_S "0.13 alpha" #define COPYRIGHT_S "Copyright (c) 2005-2007 Nyaochi" int database_dump(pmp_t* pmp, FILE *fpo, int level); void device_show_information(pmp_t* pmp, FILE *fpe); -void device_enumerate(pmplib_t* pmphelp); +void device_enumerate(pmplib_t* pmplib); int easypmp_progress_num_str( @@ -96,81 +91,76 @@ FILE *fpe = stderr; switch (phase) { - case EASYPMPDBP_START: + case EASYPMPP_START: break; - case EASYPMPDBP_READ|EASYPMPSP_START: - fprintf(fpo, "Reading database\n"); + case EASYPMPP_OPEN|EASYPMPSP_START: + fprintf(fpo, "Opening the device\n"); break; - case EASYPMPDBP_READ|EASYPMPSP_PROGRESS: + case EASYPMPP_OPEN|EASYPMPSP_END: + fprintf(fpo, "\n"); break; - case EASYPMPDBP_READ|EASYPMPSP_END: + case EASYPMPP_CLOSE|EASYPMPSP_START: + fprintf(fpo, "Closing the device\n"); + break; + case EASYPMPP_CLOSE|EASYPMPSP_END: fprintf(fpo, "\n"); break; - case EASYPMPDBP_GMI|EASYPMPSP_START: + case EASYPMPP_END: + break; + + case EASYPMPP_MUSIC_GMI|EASYPMPSP_START: fprintf(fpo, "Obtaining media information from %d files\n", param_int); break; - case EASYPMPDBP_GMI|EASYPMPSP_PROGRESS: + case EASYPMPP_MUSIC_GMI|EASYPMPSP_PROGRESS: easypmp_progress_num_str(fpo, param_int+1, filepath_skippath(param_str)); break; - case EASYPMPDBP_GMI|EASYPMPSP_END: + case EASYPMPP_MUSIC_GMI|EASYPMPSP_END: console_clearln(fpo); fprintf(fpo, " %d files were imported\n", param_int); fprintf(fpo, "\n"); break; - case EASYPMPDBP_UPDATE|EASYPMPSP_START: - fprintf(fpo, "Updating database\n"); + case EASYPMPP_MUSIC_UPDATE|EASYPMPSP_START: + fprintf(fpo, "Updating database entries\n"); break; - case EASYPMPDBP_UPDATE|EASYPMPSP_END: + case EASYPMPP_MUSIC_UPDATE|EASYPMPSP_END: fprintf(fpo, "\n"); break; - case EASYPMPDBP_WRITE|EASYPMPSP_START: - fprintf(fpo, "Writing database\n"); - break; - case EASYPMPDBP_WRITE|EASYPMPSP_PROGRESS: - break; - case EASYPMPDBP_WRITE|EASYPMPSP_END: - fprintf(fpo, "\n"); - break; - case EASYPMPDBP_END: - break; - case EASYPMPPLP_START: - break; - case EASYPMPPLP_CONVERT|EASYPMPSP_START: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_START: fprintf(fpo, "Converting playlists\n"); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_PROGRESS: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_PROGRESS: easypmp_progress_num_str(fpo, param_int+1, filepath_skippath(param_str)); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_WARN_PLAYLIST: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_WARN_PLAYLIST: fprintf(fpe, "\n"); fprintf(fpe, " WARNING: following media files are missing:\n"); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_SKIP_PLAYLIST: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_SKIP_PLAYLIST: fprintf(fpe, "\n"); fprintf(fpe, " ERROR: following media files are missing:\n"); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_MISSING_MEDIA: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_MISSING_MEDIA: fprints(fpe, " %s\n", param_str); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_ERROR: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_JSPL_ERROR: fprintf(fpe, "\n"); fprints(fpe, " JSPL(ERROR): %s\n", param_str); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_ERROR_POS: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_JSPL_ERROR_POS: fprints(fpe, " at: %s\n", param_str); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_ERROR_LINE: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_JSPL_ERROR_LINE: fprints(fpe, " line: %s\n", param_str); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_OUTPUT: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_JSPL_OUTPUT: fprints(fpo, " JSPL: %s\n", param_str); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_END: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_END: + console_clearln(fpo); + fprintf(fpo, " %d files were successfully converted\n", param_int); fprintf(fpo, "\n"); break; - case EASYPMPPLP_END: - break; } fflush(fpe); @@ -204,10 +194,11 @@ int main(int argc, char *argv[]) { int ret = 0; + result_t res = 0; int used_args = 0; char *mbs = NULL; - pmplib_t* pmphelp = NULL; pmp_t* pmp = NULL; + pmplib_t* pmplib = NULL; easypmp_filelist_t musics, playlists; pmp_music_record_t* records = NULL; uint32_t num_records = 0; @@ -215,7 +206,9 @@ FILE *fpi = stdin, *fpo = stdout, *fpe = stderr; option_t opt; + // Initialize various routines. setlocale(LC_ALL, ""); + console_init(); // Initialize option values. option_init(&opt); @@ -240,7 +233,7 @@ } #endif/*_WIN32*/ - /* Set words to be stripped from artist names. */ + // Set words to be stripped from artist names. if (opt.mbs_strip_words) { ucs2char_t* ucs2str = mbsdupucs2(opt.mbs_strip_words); easypmp_set_strip_words(&opt, ucs2str); @@ -248,7 +241,7 @@ opt.media_info_source |= GMIF_STRIP_ARTIST; } - /* Obtain the path to root directory (path_to_root) from the command line if any. */ + // Obtain the path to root directory (path_to_root) from the command line if any. if (used_args < argc) { size_t length = strlen(argv[used_args]); if (length > 0) { @@ -270,12 +263,16 @@ goto exit_main; } - // Initialize PMP helper library. - pmplib_init(&pmphelp); + // Initialize PMPlib library. + if (res = pmplib_init(&pmplib)) { + fprintf(fpe, "ERROR: Failed to initialize PMPlib library (%d)\n", res); + ret = 1; + goto exit_main; + } // Show the list of supported devices and exit. if (opt.verb & MODE_LIST_DEVICES) { - device_enumerate(pmphelp); + device_enumerate(pmplib); ret = 0; goto exit_main; } @@ -286,17 +283,6 @@ char pwd[MAX_PATH+1]; getcwd(pwd, MAX_PATH); mbstoucs2(opt.path_to_root, MAX_PATH, pwd, strlen(pwd)+1); - } else if (opt.path_to_root[0] == '-' && opt.path_to_root[1] == 0) { -#ifdef _WIN32 - // (Win32 only) - // If path_to_root is "-", assume the root folder of the path where this executable is located. - ucs2char_t* p = NULL; - GetModuleFileNameW(GetModuleHandle(NULL), opt.path_to_root, MAX_PATH); - p = (ucs2char_t*)filepath_skip_one_directory(opt.path_to_root); - if (p) { - *p = 0; - } -#endif } filepath_addslash(opt.path_to_root); @@ -318,38 +304,50 @@ } // Create a PMP instance. - ret = pmplib_create(pmphelp, &pmp, opt.path_to_root, opt.model); + res = pmplib_create(pmplib, &pmp, opt.path_to_root, opt.model); if (!pmp) { - fprintf(fpe, "Failed to find a player (%d)\n", ret); + fprintf(fpe, "ERROR: Failed to find a player (%d)\n", res); ret = 1; goto exit_main; } - // Open flag. + // Generate open flag. if (opt.verb & MODE_DATABASE) { + openflag |= PMPOF_MUSIC_DB_WRITE; if (opt.verb & MODE_DATABASE_UPDATE) { openflag |= PMPOF_MUSIC_DB_READ; } - openflag |= PMPOF_MUSIC_DB_WRITE; } if (opt.verb & MODE_DATABASE_REPR) { openflag |= PMPOF_MUSIC_DB_READ; } - if (opt.verb & MODE_PLAYLIST) { openflag |= PMPOF_MUSIC_PL_WRITE; } - // Open the PMP. - ret = pmp->open(pmp, openflag); + // Open the portable media device. + if (easypmp_progress(NULL, EASYPMPP_OPEN | EASYPMPSP_START, 0, 0, NULL) != 0) { + ret = 1; + goto exit_main; + } + res = pmp->open(pmp, openflag); + if (res) { + fprintf(fpe, "ERROR: Failed to open the player (%d)\n", res); + ret = 1; + goto exit_main; + } + if (easypmp_progress(NULL, EASYPMPP_OPEN | EASYPMPSP_END, 0, 0, NULL) != 0) { + ret = 1; + goto exit_main; + } // Show player information. device_show_information(pmp, fpo); fprintf(fpo, "\n"); + // Enumerate music files for database and playlist modes. memset(&musics, 0, sizeof(musics)); - console_init(); - if ((opt.verb & MODE_DATABASE) || ((opt.verb & MODE_PLAYLIST) && (opt.verb & MODE_PLAYLIST_FIND))) { + if ((opt.verb & MODE_DATABASE) || (opt.verb & MODE_PLAYLIST)) { fprintf(fpo, "Enumerating music files\n"); easypmp_enumerate_music(&musics, pmp, &opt, easypmp_enumerate_progress, NULL); console_clearln(fpo); @@ -357,6 +355,7 @@ fprintf(fpo, "\n"); } + // Enumerate playlist files for playlist mode. memset(&playlists, 0, sizeof(playlists)); if (opt.verb & MODE_PLAYLIST) { fprintf(fpe, "Enumerating playlist files\n"); @@ -366,17 +365,13 @@ fprintf(fpo, "\n"); } - // Execute jobs. - if (opt.verb & MODE_DATABASE) { - easypmp_database(&musics, pmp, &opt, &records, &num_records, easypmp_progress, NULL); + // Update database entries for database mode and JSPL playlists. + if ((opt.verb & MODE_DATABASE) || (opt.verb & MODE_PLAYLIST_JSPL)) { + easypmp_database(pmp, &musics, &opt, &records, &num_records, easypmp_progress, NULL); } + + // Convert playlists. if (opt.verb & MODE_PLAYLIST) { - /* - // Read the database for JSPL. - if ((opt.verb & MODE_PLAYLIST_JSPL) && (!records)) { - easypmp_database_read(pmp, &opt, &records, &num_records, easypmp_progress, NULL); - } - */ #ifndef HAVE_JSAPI_H if(opt.verb & MODE_PLAYLIST_JSPL) { fprintf(fpe, "Warning: Ignoring -j/--jspl option. This version of easypmp\n"); @@ -385,22 +380,36 @@ #endif easypmp_playlist(&playlists, &musics, pmp, &opt, records, num_records, easypmp_progress, NULL); } + + // Dump the database if specified. if (opt.verb & MODE_DATABASE_REPR) { database_dump(pmp, fpo, opt.repr_level); } - if (records) { - /* Free the record array. */ - int i; - for (i = 0;i < num_records;++i) { - pmplib_record_finish(&records[i]); - } - free(records); + // Free the music records. + if (records && num_records) { + pmplib_records_finish(records, num_records); } - pmp->close(pmp); + // Close the portable media device. + if (easypmp_progress(NULL, EASYPMPP_CLOSE | EASYPMPSP_START, 0, 0, NULL) != 0) { + ret = 1; + goto exit_main; + } + res = pmp->close(pmp); + if (res) { + fprintf(fpe, "ERROR: Failed to close the player (%d)\n", res); + ret = 1; + goto exit_main; + } + if (easypmp_progress(NULL, EASYPMPP_CLOSE | EASYPMPSP_END, 0, 0, NULL) != 0) { + ret = 1; + goto exit_main; + } + + // Uninitialize. pmp->release(pmp); - pmplib_finish(pmphelp); + pmplib_finish(pmplib); option_finish(&opt); return ret; @@ -410,11 +419,10 @@ pmp->release(pmp); pmp = NULL; } - if (pmphelp) { - pmplib_finish(pmphelp); - pmphelp = NULL; + if (pmplib) { + pmplib_finish(pmplib); + pmplib = NULL; } option_finish(&opt); return ret; } -/** @} */ Modified: trunk/pmplib/frontend/easypmp/cui/option.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/option.c 2007-01-25 22:16:09 UTC (rev 277) +++ trunk/pmplib/frontend/easypmp/cui/option.c 2007-01-26 00:37:56 UTC (rev 278) @@ -83,10 +83,9 @@ fprintf(fp, "\n"); fprintf(fp, "Playlist options:\n"); fprintf(fp, " -p, --playlist Convert playlist files in PLAYLIST directory\n"); - fprintf(fp, " -m, --music Convert playlist files in MUSIC directory\n"); fprintf(fp, " -r, --reconvert Discard the existing playlist files and reconvert\n"); fprintf(fp, " -f, --find-missing Correct playlists with corrupt references to media files\n"); - fprintf(fp, " -s, --skip-missing Continue a conversion even if a media file is missing\n"); + fprintf(fp, " -i, --ignore-missing Continue a conversion even if a media file is missing\n"); #ifdef HAVE_JSAPI_H fprintf(fp, " -j, --jspl Enable JavaScript playlist (JSPL)\n"); #endif @@ -94,6 +93,8 @@ fprintf(fp, "Player options:\n"); fprintf(fp, " -l, --list-device Show the list of supported devices and exit\n"); fprintf(fp, " -d, --device Specify a device identifier for the player\n"); + fprintf(fp, " -s, --set=NAME=VALUE Set a variable NAME to VALUE\n"); + fprintf(fp, " -V, --show-variables Show list of variables and their default values\n"); fprintf(fp, "\n"); #ifndef _WIN32 fprintf(fp, "Language-specific options:\n"); @@ -161,13 +162,14 @@ {"repr-level", required_argument, 0, 'L'}, {"strip-words", required_argument, 0, 't'}, {"playlist", no_argument, 0, 'p'}, - {"music", no_argument, 0, 'm'}, {"reconvert", no_argument, 0, 'r'}, {"find-missing", no_argument, 0, 'f'}, - {"skip-missing", no_argument, 0, 's'}, + {"ignore-missing", no_argument, 0, 's'}, {"jspl", no_argument, 0, 'j'}, {"list-device", no_argument, 0, 'l'}, {"device", required_argument, 0, 'd'}, + {"set", required_argument, 0, 's'}, + {"show-variables", no_argument, 0, 'V'}, #ifndef _WIN32 {"encoding", required_argument, 0, 'e'}, {"tagencoding", required_argument, 0, 'w'}, @@ -222,16 +224,13 @@ case 'p': opt->verb |= (MODE_PLAYLIST | MODE_PLAYLIST_PLAYLIST); break; - case 'm': - opt->verb |= (MODE_PLAYLIST | MODE_PLAYLIST_MUSIC); - break; case 'r': opt->verb |= MODE_PLAYLIST_RECONVERT; break; case 'f': opt->verb |= MODE_PLAYLIST_FIND; break; - case 's': + case 'i': opt->verb |= MODE_PLAYLIST_SKIP; break; case 'j': @@ -243,6 +242,10 @@ case 'd': strcpy(opt->model, optarg); break; + case 's': + break; + case 'V': + break; #ifndef _WIN32 case 'e': free(opt->system_encoding); Modified: trunk/pmplib/frontend/easypmp/cui/option.h =================================================================== --- trunk/pmplib/frontend/easypmp/cui/option.h 2007-01-25 22:16:09 UTC (rev 277) +++ trunk/pmplib/frontend/easypmp/cui/option.h 2007-01-26 00:37:56 UTC (rev 278) @@ -25,16 +25,9 @@ #ifndef __OPTION_H__ #define __OPTION_H__ -/** - * \addtogroup cui - * @{ - */ - void option_init(option_t* opt); void option_finish(option_t* opt); int option_parse(option_t* opt, int argc, char *argv[], FILE *fpe); void option_usage(FILE *fp, const char *argv0); -/** @} */ - #endif/*__OPTION_H__*/ Modified: trunk/pmplib/pmp.sln =================================================================== --- trunk/pmplib/pmp.sln 2007-01-25 22:16:09 UTC (rev 277) +++ trunk/pmplib/pmp.sln 2007-01-26 00:37:56 UTC (rev 278) @@ -44,11 +44,8 @@ ProjectSection(ProjectDependencies) = postProject {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} {3575EFC2-9051-467A-BEB4-E71E2F8664D7} = {3575EFC2-9051-467A-BEB4-E71E2F8664D7} - {544769C2-6989-452F-B626-E442CAC6553B} = {544769C2-6989-452F-B626-E442CAC6553B} {3419FA86-F518-4D3B-94C6-B05436439102} = {3419FA86-F518-4D3B-94C6-B05436439102} {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} - {2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1} = {2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1} - {E393575C-6B10-43BD-B2C0-63C5040A49F7} = {E393575C-6B10-43BD-B2C0-63C5040A49F7} {AA8DA82B-C209-4ABE-ABA1-22352962426D} = {AA8DA82B-C209-4ABE-ABA1-22352962426D} EndProjectSection EndProject @@ -72,9 +69,9 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pmp_iriverplus3", "lib\pmp_iriverplus3\pmp_iriverplus3.vcproj", "{C74FE9C9-B5C4-438A-B157-9BCB6C8A7546}" ProjectSection(ProjectDependencies) = postProject - {AA8DA82B-C209-4ABE-ABA1-22352962426D} = {AA8DA82B-C209-4ABE-ABA1-22352962426D} - {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} + {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} + {AA8DA82B-C209-4ABE-ABA1-22352962426D} = {AA8DA82B-C209-4ABE-ABA1-22352962426D} EndProjectSection EndProject Global This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |