From c589157169366fa47f2041cfe52e7019fbc19b35 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 20 Feb 2006 07:25:59 +0100 Subject: [PATCH] rename dopey to random It isn't so dopey anymore and the upcoming plm database tool won't be much smarter, so.. --- Doxyfile | 2 -- FEATURES | 4 ++-- INSTALL | 21 +++++++---------- README | 7 +++--- README.mysql | 4 ++-- configure.ac | 2 +- db.h | 2 +- error.h | 6 ++--- mysql.c | 2 +- dopey.c => random_dbtool.c | 47 ++++++++++++++++++-------------------- server.c | 18 +++++++-------- server.ggo | 5 ++-- 12 files changed, 55 insertions(+), 65 deletions(-) rename dopey.c => random_dbtool.c (72%) diff --git a/Doxyfile b/Doxyfile index 090e1206..37c9cec1 100644 --- a/Doxyfile +++ b/Doxyfile @@ -452,8 +452,6 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -#INPUT = net.c signal.c db.h db.c ringbuffer.c ringbuffer.h stat.c afs.c afs.h string.c net.h filter.h filter_chain.c error.h recv.h http_recv.c ortp_recv.c recv_common.c http.h mp3dec.c oggdec.c ortp.h wav.c compress.c daemon.c daemon.h grab_client.c grab_client.h close_on_fork.c close_on_fork.h audiod.c audiod.h time.c mysql.c server.h command.c server.c send.h http_send.c ortp_send.c http.h ortp.h mp3.c ogg.c dopey.c string.h exec.c - INPUT = . # If the value of the INPUT tag contains directories, you can use the diff --git a/FEATURES b/FEATURES index 3dde8e97..b567f113 100644 --- a/FEATURES +++ b/FEATURES @@ -32,7 +32,7 @@ mysql-based audio file selector: small memory footprint: ~~~~~~~~~~~~~~~~~~~~~~~ paraslash is lightweight. The stripped binary of para_server - with all its features compiled in (mysql/dopey dbtool, + with all its features compiled in (mysql/random dbtool, mp3/ogg support, http/ortp support) is about 100K on i386 under Linux. para_audiod is even smaller. @@ -53,7 +53,7 @@ authentication/encryption via openssl: various user interfaces and utilities: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ o para_gui. Curses based interface, displays information in a - curses window and can be used to easily control para_server + curses window and can be used to easily control para_server and para_audiod. o para_sdl_gui. Shows pictures (on a per song basis) and diff --git a/INSTALL b/INSTALL index 3b373181..9d82c9bf 100644 --- a/INSTALL +++ b/INSTALL @@ -78,24 +78,19 @@ to retrieve the list of available commands and some server info. Choose your database tool (dbtool) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -You have three options: +You have two options: 1. Use the mysql dbtool which comes with paraslash and requires - mysql. This is recommended. + mysql. - 2. Use your own database tool. If you have that already, - skip this step. - - 3. If you can not use the mysql dbtool and you just want - to quickly make paraslash working, use the dopey dbtool. + 2. If you can not use the mysql dbtool and you just want + to quickly make paraslash working, use the random dbtool. The directory which is searched for audio files can be given - via the server option --dopey_dir. - - Note, however, that dopey is _really_ dopey. It scans - $dopey_dir on every audio file change and chooses one - randomly. You get the idea. Have a look at its source code - and feel free to modify. + via the server option --random_dbtool_dir. + Note, however, that this database tool is really dopey. It + scans the given directory on every audio file change and + chooses one randomly. There is no further functionality. The current database tool can be changed at runtime via diff --git a/README b/README index 967655fc..2c0dc76d 100644 --- a/README +++ b/README @@ -27,9 +27,10 @@ It contains the following programs: para_server needs a database tool to work, mainly to determine which song to stream next. There are two database tools - available: mysql and dopey. The former is recommended as dopey - is only meant as a fallback and as a starting point for people - that want to write their own database tool for paraslash. + available: mysql and random. The former is recommended as + the random database tool is only meant as a fallback and + as a starting point for people that want to write their own + database tool for paraslash. The mysql database tool connects to a mysql server which holds information on your audio files. It has several unusual diff --git a/README.mysql b/README.mysql index d2a27e72..7af82807 100644 --- a/README.mysql +++ b/README.mysql @@ -50,8 +50,8 @@ indeed activated, type para_client cdt -which prints the name of the current database tool. If the dopey -dbtool is still selected, try +which prints the name of the current database tool. If the mysql +dbtool is not selected, try para_client cdt mysql diff --git a/configure.ac b/configure.ac index da353502..46ba57e5 100644 --- a/configure.ac +++ b/configure.ac @@ -72,7 +72,7 @@ audiod_errlist_objs="audiod exec close_on_fork signal string daemon stat net audiod_ldflags="" server_cmdline_objs="server.cmdline" -server_errlist_objs="server mp3 afs command net string signal dopey time daemon stat +server_errlist_objs="server mp3 afs command net string signal random_dbtool time daemon stat crypt http_send db close_on_fork" server_ldflags="" diff --git a/db.h b/db.h index 960bf59f..5f9f2cbf 100644 --- a/db.h +++ b/db.h @@ -91,5 +91,5 @@ void (*shutdown)(void); }; int mysql_dbtool_init(struct dbtool*); -int dopey_dbtool_init(struct dbtool*); +int random_dbtool_init(struct dbtool*); diff --git a/error.h b/error.h index bc8475e0..028dd7f2 100644 --- a/error.h +++ b/error.h @@ -23,7 +23,7 @@ enum para_subsystem {SS_RECV, SS_NET, SS_ORTP_RECV, SS_AUDIOD, SS_EXEC, SS_CLOSE_ON_FORK, SS_SIGNAL, SS_STRING, SS_DAEMON, SS_STAT, SS_TIME, SS_GRAB_CLIENT, SS_HTTP_RECV, SS_RECV_COMMON, SS_FILTER_CHAIN, SS_WAV, SS_COMPRESS, SS_OGGDEC, SS_FILTER, - SS_COMMAND, SS_DOPEY, SS_CRYPT, SS_HTTP_SEND, SS_ORTP_SEND, SS_DB, SS_OGG, + SS_COMMAND, SS_RANDOM_DBTOOL, SS_CRYPT, SS_HTTP_SEND, SS_ORTP_SEND, SS_DB, SS_OGG, SS_MP3, SS_MP3DEC, SS_SERVER, SS_AFS, SS_MYSQL, SS_RINGBUFFER}; #define NUM_SS (SS_RINGBUFFER + 1) extern const char **para_errlist[]; @@ -185,7 +185,7 @@ extern const char **para_errlist[]; PARA_ERROR(WRITE_OK, "can not check whether fd is writable"), \ -#define DOPEY_ERRORS \ +#define RANDOM_DBTOOL_ERRORS \ PARA_ERROR(FILE_COUNT, "audio file count exceeded"), \ PARA_ERROR(NOTHING_FOUND, "no audio files found"), \ @@ -331,7 +331,7 @@ SS_ENUM(OGG); SS_ENUM(SERVER); SS_ENUM(AFS); SS_ENUM(COMMAND); -SS_ENUM(DOPEY); +SS_ENUM(RANDOM_DBTOOL); SS_ENUM(CRYPT); SS_ENUM(HTTP_SEND); SS_ENUM(ORTP_SEND); diff --git a/mysql.c b/mysql.c index b8fa02dc..9760f086 100644 --- a/mysql.c +++ b/mysql.c @@ -2514,7 +2514,7 @@ static void shutdown_connection(void) * Check the command line options and initialize all function pointers of \a db. * Connect to the mysql server and initialize the dbinfo string. * - * \sa struct dbtool, misc_meta_data::dbinfo, dopey.c + * \sa struct dbtool, misc_meta_data::dbinfo, random_dbtool.c */ int mysql_dbtool_init(struct dbtool *db) { diff --git a/dopey.c b/random_dbtool.c similarity index 72% rename from dopey.c rename to random_dbtool.c index 91e13685..d970bd7f 100644 --- a/dopey.c +++ b/random_dbtool.c @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ -/** \file dopey.c Simple database tool implementation. Feel free to modify. */ +/** \file random_dbtool. Simple database tool implementation. Feel free to modify. */ #include /* gettimeofday */ #include "server.cmdline.h" @@ -26,7 +26,7 @@ #include "net.h" #include "string.h" -static int com_dopey(int, int, char **); +static int com_random_info(int, int, char **); extern struct gengetopt_args_info conf; extern struct misc_meta_data *mmd; @@ -51,34 +51,30 @@ static int remember_file(const char *dir, const char *name) /* array of commands that are supported by this database tool */ static struct server_command cmds[] = { { -.name = "dopey", -.handler = com_dopey, +.name = "random_info", +.handler = com_random_info, .perms = 0, -.description = "about the dopey database tool", -.synopsis = "dopey", +.description = "about the random database tool", +.synopsis = "random_info", .help = -"It's so dumb. It hurts. Don't use it; switch to the mysql database\n" -"tool instead. OTOH: You typed 'help dopey', so if you serious about\n" -"that and you really intend to help the dopey database tool, look at\n" -"my source code, dopey.c, and modify it to make it something useful.\n" - +"Select a random file under the given directory" }, { .name = NULL, } }; -static int com_dopey(int fd, __unused int argc, __unused char *argv[]) +static int com_random_info(int fd, __unused int argc, __unused char *argv[]) { - return send_buffer(fd, "Please do not use me. I'm too sick to do " - "anything for you. Switch me off. Now!\n"); + return send_buffer(fd, "Don't use for huge directories as it is " + "very inefficient in this case.\n"); } /* * Load a list of all audio files into memory and chose num of them randomly. * Called by server to determine next audio file to be streamed. */ -static char **dopey_get_audio_file_list(unsigned int num) +static char **random_get_audio_file_list(unsigned int num) { int i, ret; unsigned int len; @@ -87,7 +83,7 @@ static char **dopey_get_audio_file_list(unsigned int num) audio_file_list = NULL; num_audio_files = 0; /* first run, just count all audio files. dopey */ - ret = find_audio_files(conf.dopey_dir_arg, count_audio_files); + ret = find_audio_files(conf.random_dbtool_dir_arg, count_audio_files); if (ret < 0) goto out; ret = -E_NOTHING_FOUND; @@ -97,7 +93,7 @@ static char **dopey_get_audio_file_list(unsigned int num) audio_file_list = para_malloc(num_audio_files * sizeof(char *)); audio_file_count = 0; /* second run (hot dentry cache, hopefully), fill audio_file_list */ - ret = find_audio_files(conf.dopey_dir_arg, remember_file); + ret = find_audio_files(conf.random_dbtool_dir_arg, remember_file); if (ret < 0) goto out; /* careful, files might got deleted underneath */ @@ -124,31 +120,32 @@ out: return ret_list; } -static void dopey_shutdown(void) +static void random_shutdown(void) { PARA_DEBUG_LOG("%s", "thanks for using another dbtool.\n"); } -/** dopey's (constant) database info text */ -#define DBINFO "dbinfo1:database info? You're kidding. I'm dopey!\ndbinfo2:\ndbinfo3:\n" +/** random's (constant) database info text */ +#define DBINFO "dbinfo1:database info? You're kidding. I'm still dopey!\ndbinfo2:\ndbinfo3:\n" -/** the dopey init function +/** + * the init function for the random database tool * * Init all function pointers of \a db, init the dbinfo text and seed the * PRNG. * * \sa struct dbtool, misc_meta_data::dbinfo, mysql.c */ -int dopey_dbtool_init(struct dbtool *db) +int random_dbtool_init(struct dbtool *db) { struct timeval now; - PARA_INFO_LOG("%s", "registering dopey handlers\n"); + PARA_INFO_LOG("%s", "registering random handlers ;)\n"); sprintf(mmd->dbinfo, DBINFO); gettimeofday(&now, NULL); srand(now.tv_usec); db->cmd_list = cmds; - db->get_audio_file_list = dopey_get_audio_file_list; - db->shutdown = dopey_shutdown; + db->get_audio_file_list = random_get_audio_file_list; + db->shutdown = random_shutdown; return 1; } diff --git a/server.c b/server.c index 71ee9eb6..044792f1 100644 --- a/server.c +++ b/server.c @@ -63,8 +63,8 @@ extern struct audio_format afl[]; /** the list of supported database tools */ struct dbtool dblist[] = { { - .name = "dopey", - .init = dopey_dbtool_init, + .name = "random", + .init = random_dbtool_init, .update_audio_file = NULL, }, #ifdef HAVE_MYSQL @@ -302,7 +302,7 @@ static void init_dbtool(void) mmd->dbt_change = -1; /* no change nec., set to new dbt num by com_cdt */ if (!dblist[1].name) - goto dopey; + goto random; if (conf.dbtool_given) { for (i = 0; dblist[i].name; i++) { if (strcmp(dblist[i].name, conf.dbtool_arg)) @@ -312,16 +312,16 @@ static void init_dbtool(void) if (dblist[i].init(&dblist[i]) < 0) { PARA_WARNING_LOG("init %s failed", dblist[i].name); - goto dopey; + goto random; } mmd->dbt_num = i; return; } - PARA_WARNING_LOG("%s", "no such dbtool, switching to dopey\n"); - goto dopey; + PARA_WARNING_LOG("%s", "no such dbtool, switching to random\n"); + goto random; } /* use the first dbtool that works - * (assuming that dopey always works) + * (assuming that random always works) */ for (i = 1; dblist[i].name; i++) { int ret = dblist[i].init(&dblist[i]); @@ -333,7 +333,7 @@ static void init_dbtool(void) PARA_CRIT_LOG("%s init failed: %s\n", dblist[i].name, PARA_STRERROR(-ret)); } -dopey: +random: mmd->dbt_num = 0; dblist[0].init(&dblist[0]); /* always successful */ } @@ -417,7 +417,7 @@ static void handle_dbt_change(void) return; } /* init failed */ - PARA_ERROR_LOG("%s -- switching to dopey\n", PARA_STRERROR(-ret)); + PARA_ERROR_LOG("%s -- switching to the random dbtool\n", PARA_STRERROR(-ret)); dblist[0].init(&dblist[0]); mmd->dbt_num = 0; } diff --git a/server.ggo b/server.ggo index 52dc90b6..a7db080a 100644 --- a/server.ggo +++ b/server.ggo @@ -25,8 +25,8 @@ option "mysql_default_score" - "scoring rule to use if stream definition does no -section "Dopey database tool options" -option "dopey_dir" - "dir to search for files to be streamed" string default="/home/music" no +section "Random database tool options" +option "random_dbtool_dir" - "dir to search for files to be streamed" string default="/home/music" no section "Http sender options" option "http_port" - "tcp port for http streaming" int typestr="portnumber" default="8000" no @@ -40,4 +40,3 @@ option "ortp_target" - "Add given host/port to the list of targets. This option option "ortp_no_autostart" - "do not start to send automatically" flag off option "ortp_default_port" - "default udp port if not specified" int typestr="portnumber" default="1500" no option "ortp_header_interval" H "time between extra header sends" int typestr="milliseconds" default="2000" no - -- 2.39.2