[Mt-daapd-cvs] mt-daapd/src configfile.c,1.70,1.71 daapd.h,1.25,1.26 mp3-scanner.c,1.116,1.117
Status: Beta
Brought to you by:
andrew40
From: Ron P. <rp...@us...> - 2005-07-14 21:10:15
|
Update of /cvsroot/mt-daapd/mt-daapd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15338/src Modified Files: configfile.c daapd.h mp3-scanner.c Log Message: Add support for compilation directories Index: daapd.h =================================================================== RCS file: /cvsroot/mt-daapd/mt-daapd/src/daapd.h,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** daapd.h 24 Feb 2005 05:04:05 -0000 1.25 --- daapd.h 14 Jul 2005 21:10:05 -0000 1.26 *************** *** 49,58 **** int reload; /**< Time to reload and/or rescan the database? */ char *configfile; /**< path to config file */ ! char *web_root; /**< path to the directory containing the admin-root files */ int port; /**< port to listen on */ ! int rescan_interval; /**< How often to do a background rescan of the file system */ int always_scan; /**< 0 to minimize disk usage (embedded devices) */ int process_m3u; /**< Should we process m3u files? */ ! int scan_type; /**< How hard to search mp3 files. see scan_get_mp3fileinfo() */ int compress; /**< Should we compress? */ int pid; /**< pid that will accept INT to terminate */ --- 49,58 ---- int reload; /**< Time to reload and/or rescan the database? */ char *configfile; /**< path to config file */ ! char *web_root; /**< path to the dir containing the web files */ int port; /**< port to listen on */ ! int rescan_interval; /**< How often to do a background fs rescan */ int always_scan; /**< 0 to minimize disk usage (embedded devices) */ int process_m3u; /**< Should we process m3u files? */ ! int scan_type; /**< Method for finding playtime. see scan-mp3.c */ int compress; /**< Should we compress? */ int pid; /**< pid that will accept INT to terminate */ *************** *** 70,73 **** --- 70,75 ---- char *artfilename; /**< What filename to merge coverart with */ char *logfile; /**< What file to use as a logfile */ + char *compdirs; /**< Compilations directories */ + char **complist; /**< list of compilation directories */ STATS stats; /**< Stats structure (see above) */ } CONFIG; Index: configfile.c =================================================================== RCS file: /cvsroot/mt-daapd/mt-daapd/src/configfile.c,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** configfile.c 15 Jun 2005 03:27:27 -0000 1.70 --- configfile.c 14 Jul 2005 21:10:05 -0000 1.71 *************** *** 137,140 **** --- 137,141 ---- { 1,0,0,CONFIG_TYPE_STRING,"ssc_prog",(void*)&config.ssc_prog,config_emit_string }, { 1,0,0,CONFIG_TYPE_STRING,"password",(void*)&config.readpassword, config_emit_string }, + { 1,0,0,CONFIG_TYPE_STRING,"compdirs",(void*)&config.compdirs, config_emit_string }, { 1,0,0,CONFIG_TYPE_STRING,"logfile",(void*)&config.logfile, config_emit_string }, { 0,0,0,CONFIG_TYPE_SPECIAL,"host",(void*)NULL,config_emit_host }, *************** *** 271,274 **** --- 272,278 ---- int handled; char *term; + int compterms=0,currentterm; + char *term_begin, *term_end; + char *compdirs; buffer=(char*)malloc(MAX_LINE+1); *************** *** 310,313 **** --- 314,319 ---- config.compress=0; config.latin1_tags=0; + config.compdirs=NULL; + config.complist = NULL; /* DWB: use alloced space so it can be freed without errors */ *************** *** 460,463 **** --- 466,515 ---- } + /* See how many compilation dirs we have */ + compterms=0; + term_begin=config.compdirs; + while(term_begin) { + compterms++; + term_begin=strchr(term_begin,','); + if(term_begin) + term_begin++; + } + + /* Now allocate comp dirs */ + if(compterms) { + config.complist=(char**)malloc((compterms+1) * sizeof(char*)); + if(!config.complist) + DPRINTF(E_FATAL,L_MISC,"Alloc error.\n"); + + currentterm=0; + + term_begin=config.compdirs; + while(*term_begin && *term_begin ==' ') + term_begin++; + + compdirs = strdup(term_begin); + term_begin = term_end = compdirs; + + while(term_end) { + term_end = strchr(term_begin,','); + while((*term_begin)&&(*term_begin == ' ')) + term_begin++; + + if(term_end) + *term_end='\0'; + + while(strlen(term_begin) && term_begin[strlen(term_begin)-1]==' ') + term_begin[strlen(term_begin)-1] == '\0'; + + if(strlen(term_begin)) { + config.complist[currentterm++] = term_begin; + } + + term_begin = term_end + 1; + } + + config.complist[currentterm] = NULL; + } + return err; } *************** *** 471,474 **** --- 523,532 ---- int err; + if(config.complist) { + if(config.complist[0]) + free(config.complist[0]); + free(config.complist); + } + free(config.configfile); pce=config_elements; *************** *** 531,534 **** --- 589,595 ---- fprintf(configfile,"process_m3u\t%s\n",ws_getvar(pwsc,"process_m3u")); fprintf(configfile,"compress\t%s\n",ws_getvar(pwsc,"compress")); + + fprintf(configfile,"debuglevel\t%s\n",ws_getvar(pwsc,"debuglevel")); + fprintf(configfile,"compdirs\t%s\n",ws_getvar(pwsc,"compdirs")); fclose(configfile); Index: mp3-scanner.c =================================================================== RCS file: /cvsroot/mt-daapd/mt-daapd/src/mp3-scanner.c,v retrieving revision 1.116 retrieving revision 1.117 diff -C2 -d -r1.116 -r1.117 *** mp3-scanner.c 13 Jul 2005 05:32:54 -0000 1.116 --- mp3-scanner.c 14 Jul 2005 21:10:05 -0000 1.117 *************** *** 77,81 **** static int scan_get_info(char *file, MP3FILE *pmp3); static int scan_freetags(MP3FILE *pmp3); ! static void scan_music_file(char *path, struct dirent *pde, struct stat *psb); static TAGHANDLER *scan_gethandler(char *type); --- 77,81 ---- static int scan_get_info(char *file, MP3FILE *pmp3); static int scan_freetags(MP3FILE *pmp3); ! static void scan_music_file(char *path, struct dirent *pde, struct stat *psb, int is_compdir); static TAGHANDLER *scan_gethandler(char *type); *************** *** 238,241 **** --- 238,263 ---- } + /** + * check to see if a particular path is a complation path + * + * @param path path to check + * @returns 1 if it is a compilation path, 0 otherwise + */ + int scan_is_compdir(char *path) { + int current=0; + + if(!config.complist) + return 0; + + while(config.complist[current]) { + if(strcasestr(path,config.complist[current])) + return 1; + current++; + } + + return 0; + } + + /* * scan_path *************** *** 254,257 **** --- 276,280 ---- char *ext; MP3FILE *pmp3; + int is_compdir; if((current_dir=opendir(path)) == NULL) { *************** *** 260,263 **** --- 283,288 ---- } + is_compdir=scan_is_compdir(path); + while(1) { if(config.stop) { *************** *** 311,315 **** if((!pmp3) || (pmp3->db_timestamp < modified_time) || (pmp3->force_update)) { ! scan_music_file(path,pde,&sb); } else { DPRINTF(E_DBG,L_SCAN,"Skipping file... not modified\n"); --- 336,340 ---- if((!pmp3) || (pmp3->db_timestamp < modified_time) || (pmp3->force_update)) { ! scan_music_file(path,pde,&sb,is_compdir); } else { DPRINTF(E_DBG,L_SCAN,"Skipping file... not modified\n"); *************** *** 432,436 **** * scan a particular file as a music file */ ! void scan_music_file(char *path, struct dirent *pde, struct stat *psb) { MP3FILE mp3file; char mp3_path[PATH_MAX]; --- 457,462 ---- * scan a particular file as a music file */ ! void scan_music_file(char *path, struct dirent *pde, ! struct stat *psb, int is_compdir) { MP3FILE mp3file; char mp3_path[PATH_MAX]; *************** *** 497,500 **** --- 523,529 ---- DPRINTF(E_DBG,L_SCAN," Codec: %s\n",mp3file.codectype); + if(is_compdir) + mp3file.compilation = 1; + db_add(&mp3file); } else { |