use const qualifiers where possible
authorAndre <maan@p133.(none)>
Sun, 26 Mar 2006 00:29:50 +0000 (01:29 +0100)
committerAndre <maan@p133.(none)>
Sun, 26 Mar 2006 00:29:50 +0000 (01:29 +0100)
25 files changed:
SFont.c
SFont.h
audioc.c
audiod.c
client.c
command.c
dbadm.c
exec.c
fade.c
filter.c
filter_chain.c
gui.c
http_send.c
mp3.c
mysql_selector.c
net.c
net.h
para.h
recv.c
sdl_gui.c
server.c
server.h
slider.c
string.c
string.h

diff --git a/SFont.c b/SFont.c
index 407ef9906462ad2836a2f7f956c0d1c81eba27b4..8a078c9f26e17d928844004e756abf998f8a6ad1 100644 (file)
--- a/SFont.c
+++ b/SFont.c
@@ -16,7 +16,7 @@
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  */
 
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  */
 
-/*Modified 2003 by Andre Noll */
+/*Modified 2003, 2006 by Andre Noll */
 
 #include <SDL/SDL.h>
 #include "SFont.h"
 
 #include <SDL/SDL.h>
 #include "SFont.h"
@@ -110,7 +110,7 @@ void InitFont(SDL_Surface * Font)
 
 
 void PutString2(SDL_Surface * Surface, SFont_FontInfo * Font, int x, int y,
 
 
 void PutString2(SDL_Surface * Surface, SFont_FontInfo * Font, int x, int y,
-               char *text)
+               const char *text)
 {
        int ofs;
        int i = 0;
 {
        int ofs;
        int i = 0;
@@ -141,13 +141,7 @@ void PutString2(SDL_Surface * Surface, SFont_FontInfo * Font, int x, int y,
                }
        }
 }
                }
        }
 }
-#if 0
-void PutString(SDL_Surface * Surface, int x, int y, char *text)
-{
-       PutString2(Surface, &InternalFont, x, y, text);
-}
 
 
-#endif
 int TextWidth2(SFont_FontInfo * Font, char *text)
 {
        int ofs = 0;
 int TextWidth2(SFont_FontInfo * Font, char *text)
 {
        int ofs = 0;
@@ -166,29 +160,8 @@ int TextWidth2(SFont_FontInfo * Font, char *text)
        return x;
 }
 
        return x;
 }
 
-#if 0
-int TextWidth(char *text)
-{
-       return TextWidth2(&InternalFont, text);
-}
-#endif
-
-void XCenteredString2(SDL_Surface * Surface, SFont_FontInfo * Font, int y,
-                     char *text)
-{
-       PutString2(Surface, Font, Surface->w / 2 - TextWidth2(Font, text) / 2,
-                  y, text);
-}
-
-#if 0
-void XCenteredString(SDL_Surface * Surface, int y, char *text)
-{
-       XCenteredString2(Surface, &InternalFont, y, text);
-}
-#endif
-
 void SFont_InternalInput(SDL_Surface * Dest, SFont_FontInfo * Font, int x,
 void SFont_InternalInput(SDL_Surface * Dest, SFont_FontInfo * Font, int x,
-                        int y, int PixelWidth, char *text)
+               int y, int PixelWidth, char *text)
 {
        SDL_Event event;
        int ch = -1, blink = 0;
 {
        SDL_Event event;
        int ch = -1, blink = 0;
diff --git a/SFont.h b/SFont.h
index acdae2aad91f2013b2c4ba53bf7bf87cd3cdb2c7..a243dddeb5b5e0a90bcb6f62e1ddf6d4f22ac1fa 100644 (file)
--- a/SFont.h
+++ b/SFont.h
@@ -36,7 +36,7 @@ void InitFont2(SFont_FontInfo *Font);
 // Destination: the suface you want to blit to
 // text: a string containing the text you want to blit.
 void PutString (SDL_Surface *Surface, int x, int y, char *text);
 // Destination: the suface you want to blit to
 // text: a string containing the text you want to blit.
 void PutString (SDL_Surface *Surface, int x, int y, char *text);
-void PutString2(SDL_Surface *Surface, SFont_FontInfo *Font, int x, int y, char *text);
+void PutString2(SDL_Surface *Surface, SFont_FontInfo *Font, int x, int y, const char *text);
 
 // Returns the width of "text" in pixels
 int TextWidth(char *text);
 
 // Returns the width of "text" in pixels
 int TextWidth(char *text);
index 23f67fbb0291078266cec811fae51c883958887e..968f84b6fcd3c6960b2dbf4e2009297e8fd1028c 100644 (file)
--- a/audioc.c
+++ b/audioc.c
@@ -28,7 +28,7 @@ char *tmpfifo;
 enum {E_SYNTAX, E_READ, E_WRITE, E_SOCKET, E_INIT_SOCK_ADDR, E_CONNECT, E_CREDENTIALS, E_SELECT, E_OVERRUN};
 
 
 enum {E_SYNTAX, E_READ, E_WRITE, E_SOCKET, E_INIT_SOCK_ADDR, E_CONNECT, E_CREDENTIALS, E_SELECT, E_OVERRUN};
 
 
-void para_log(__unused int ll, __unused char* fmt,...) /* no logging */
+void para_log(__unused int ll, __unused const char* fmt,...) /* no logging */
 {
 }
 
 {
 }
 
index 107fb35e641c157bc07667bf0549681799702ea8..9e001c67ee73562f453a69f13e5a644d04e55169 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -137,17 +137,7 @@ static void *stat_item_ringbuf;
 static FILE *logfile;
 static const struct timeval restart_delay = {0, 300 * 1000};
 
 static FILE *logfile;
 static const struct timeval restart_delay = {0, 300 * 1000};
 
-static struct audio_format_info afi[] = {
-
-[AUDIO_FORMAT_MP3] =
-       {
-               .write_cmd = "para_play",
-       },
-[AUDIO_FORMAT_OGG] =
-       {
-               .write_cmd = "para_play",
-       },
-};
+static struct audio_format_info afi[NUM_AUDIO_FORMATS];
 
 static struct audiod_command cmds[] = {
 {
 
 static struct audiod_command cmds[] = {
 {
@@ -269,7 +259,7 @@ int get_audio_format_num(char *name)
 /*
  * log function. first argument is loglevel.
  */
 /*
  * log function. first argument is loglevel.
  */
-void para_log(int ll, char* fmt,...)
+void para_log(int ll, const char* fmt,...)
 {
        va_list argp;
        FILE *outfd;
 {
        va_list argp;
        FILE *outfd;
@@ -590,7 +580,7 @@ static void __noreturn clean_exit(int status, const char *msg)
        exit(status);
 }
 
        exit(status);
 }
 
-static char *glob_cmd(char *cmd)
+__malloc static char *glob_cmd(char *cmd)
 {
        char *ret, *replacement;
        struct timeval tmp, delay, rss; /* real stream start */
 {
        char *ret, *replacement;
        struct timeval tmp, delay, rss; /* real stream start */
@@ -688,12 +678,15 @@ static void start_stream_writer(int slot_num)
        int ret, fds[3] = {1, -1, -1};
        struct slot_info *s = &slot[slot_num];
        struct audio_format_info *a = &afi[s->format];
        int ret, fds[3] = {1, -1, -1};
        struct slot_info *s = &slot[slot_num];
        struct audio_format_info *a = &afi[s->format];
-       char *glob = glob_cmd(a->write_cmd);
+       char *glob = NULL;
 
 
-       PARA_INFO_LOG("starting stream writer: %s\n", glob? glob : a->write_cmd);
+       if (a->write_cmd)
+               glob = glob_cmd(a->write_cmd);
+       if (!glob)
+               glob = para_strdup("para_play");
+       PARA_INFO_LOG("starting stream writer: %s\n", glob);
        open_filters(slot_num);
        open_filters(slot_num);
-
-       ret = para_exec_cmdline_pid(&s->wpid, glob? glob : a->write_cmd, fds);
+       ret = para_exec_cmdline_pid(&s->wpid, glob, fds);
        free(glob);
        if (ret < 0) {
                PARA_ERROR_LOG("exec failed (%d)\n", ret);
        free(glob);
        if (ret < 0) {
                PARA_ERROR_LOG("exec failed (%d)\n", ret);
@@ -1084,7 +1077,7 @@ static int setup_default_filters(void)
                if (ret < 0)
                        goto out;
                PARA_INFO_LOG("%s -> default filter: %s\n", audio_formats[i], filters[j].name);
                if (ret < 0)
                        goto out;
                PARA_INFO_LOG("%s -> default filter: %s\n", audio_formats[i], filters[j].name);
-               ret = add_filter(i, "wav");
+               ret = add_filter(i, para_strdup("wav"));
                if (ret < 0)
                        goto out;
                PARA_INFO_LOG("%s -> default filter: wav\n", audio_formats[i]);
                if (ret < 0)
                        goto out;
                PARA_INFO_LOG("%s -> default filter: wav\n", audio_formats[i]);
@@ -1427,9 +1420,8 @@ static void audiod_get_socket(void)
 static int open_stat_pipe(void)
 {
        int ret, fd[3] = {-1, 1, 0};
 static int open_stat_pipe(void)
 {
        int ret, fd[3] = {-1, 1, 0};
-       char *argv[] = {BINDIR "/para_client", "stat", NULL};
        pid_t pid;
        pid_t pid;
-       ret = para_exec(&pid, BINDIR "/para_client",  argv, fd);
+       ret = para_exec_cmdline_pid(&pid, BINDIR "/para_client stat", fd);
        if (ret >= 0) {
                ret = fd[1];
                PARA_NOTICE_LOG("stat pipe opened, fd %d\n", ret);
        if (ret >= 0) {
                ret = fd[1];
                PARA_NOTICE_LOG("stat pipe opened, fd %d\n", ret);
index 1ece195036b55a51538884f3af7539215c36b714..ce66ea7b7159c101d77896b09c77f433d1f05c54 100644 (file)
--- a/client.c
+++ b/client.c
@@ -37,7 +37,7 @@ struct gengetopt_args_info args_info;
 /*
  * client log function
  */
 /*
  * client log function
  */
-void para_log(int ll, char* fmt,...)
+void para_log(int ll, const char* fmt,...)
 {
        va_list argp;
        FILE *outfd;
 {
        va_list argp;
        FILE *outfd;
index 9c8ef85c4304f4c3fdcd10ae4117b866c3e2270e..030289af8444ac35baddb8e10b30712a542768c9 100644 (file)
--- a/command.c
+++ b/command.c
@@ -1205,7 +1205,6 @@ int handle_connect(int fd, struct sockaddr_in *addr)
        /* valid command and sufficient perms */
        alarm(0);
        argc = split_args(command, &argv, '\n');
        /* valid command and sufficient perms */
        alarm(0);
        argc = split_args(command, &argv, '\n');
-       argv[0] = cmd->name;
        mmd_lock();
        mmd->num_commands++;
        mmd_unlock();
        mmd_lock();
        mmd->num_commands++;
        mmd_unlock();
diff --git a/dbadm.c b/dbadm.c
index e7d2c33862e32a81e530ea434e2541f769cfcabc..5e7bf6e1d44f1750a2649514693f265a6f548b0d 100644 (file)
--- a/dbadm.c
+++ b/dbadm.c
@@ -37,7 +37,7 @@ WINDOW *att_win;
 static char **choices;
 
 /* no looging */
 static char **choices;
 
 /* no looging */
-void para_log(__unused int ll, __unused char *fmt,...)
+void para_log(__unused int ll, __unused const char *fmt,...)
 {
 }
 
 {
 }
 
diff --git a/exec.c b/exec.c
index 34643b8f61bf94affac5d45987e0389d87a9e9c7..1a302c16bf07dba2e8ae51cc706980487950bf88 100644 (file)
--- a/exec.c
+++ b/exec.c
  * \param args the argument array for the command
  * \param fds a pointer to a value-result array
  *
  * \param args the argument array for the command
  * \param fds a pointer to a value-result array
  *
- * This function uses fork/exec to create a new process.  \a fds must be a
- * pointer to three integers, corresponding to stdin, stdout and stderr
- * respectively. It specifies how to deal with fd 0, 1, 2 in the child.  The
- * contents of \a fds are interpreted as follows:
- *
- *     - fd[i] < 0: leave fd \a i alone
- *     - fd[i] = 0: dup fd \a i to /dev/null
- *     - fd[i] > 0: create a pipe and dup i to one end of that pipe.
- *     Upon return, fd[i] contains the file descriptor of the pipe.
- *
- *     In any case, all unneeded filedescriptors are closed.
- *
  * \return Negative on errors, positive on success.
  *
  * \sa null(4), pipe(2), dup2(2), fork(2), exec(3)
  */
  * \return Negative on errors, positive on success.
  *
  * \sa null(4), pipe(2), dup2(2), fork(2), exec(3)
  */
-int para_exec(pid_t *pid, const char *file, char *const args[], int *fds)
+static int para_exec(pid_t *pid, const char *file, char *const args[], int *fds)
 {
        int ret, in[2] = {-1, -1}, out[2] = {-1, -1}, err[2] = {-1, -1},
                null = -1; /* ;) */
 {
        int ret, in[2] = {-1, -1}, out[2] = {-1, -1}, err[2] = {-1, -1},
                null = -1; /* ;) */
@@ -134,16 +122,25 @@ err_out:
 /**
  * exec the given command
  *
 /**
  * exec the given command
  *
- * \param pid the same meaning as in para_exec()
+ * \param pid will hold the pid of the created process upon return
  * \param cmdline holds the command and its arguments, seperated by spaces
  * \param cmdline holds the command and its arguments, seperated by spaces
- * \param fds the same meaning as in para_exec()
+ * \param fds a pointer to a value-result array
+ *
+ * This function uses fork/exec to create a new process. \a fds must be a
+ * pointer to three integers, corresponding to stdin, stdout and stderr
+ * respectively. It specifies how to deal with fd 0, 1, 2 in the child. The
+ * contents of \a fds are interpreted as follows:
+ *
+ *     - fd[i] < 0: leave fd \a i alone
+ *     - fd[i] = 0: dup fd \a i to /dev/null
+ *     - fd[i] > 0: create a pipe and dup i to one end of that pipe.
+ *     Upon return, fd[i] contains the file descriptor of the pipe.
  *
  *
- * A wrapper for para_exec() which calls split_args() to seperate
- * the command line arguments.
+ *     In any case, all unneeded filedescriptors are closed.
  *
  * \return positive on success, negative on errors
  */
  *
  * \return positive on success, negative on errors
  */
-int para_exec_cmdline_pid(pid_t *pid, char *cmdline, int *fds)
+int para_exec_cmdline_pid(pid_t *pid, const char *cmdline, int *fds)
 {
        int argc, ret;
        char **argv, *tmp = para_strdup(cmdline);
 {
        int argc, ret;
        char **argv, *tmp = para_strdup(cmdline);
diff --git a/fade.c b/fade.c
index 1f66b363e0dc836f629ace5170c661ad2b9e364e..b385cee7d8a7942d0edd86e69f8306b9b220b5fd 100644 (file)
--- a/fade.c
+++ b/fade.c
@@ -34,7 +34,7 @@
 
 struct gengetopt_args_info args_info;
 
 
 struct gengetopt_args_info args_info;
 
-void para_log(__unused int ll, char *fmt,...)
+void para_log(__unused int ll, const char *fmt,...)
 {
        va_list argp;
        time_t t1;
 {
        va_list argp;
        time_t t1;
@@ -167,10 +167,10 @@ out:
        return 1;
 }
 
        return 1;
 }
 
-static int client_cmd(char *cmd,...)
+static int client_cmd(const char *cmd,...)
 {
        int ret, fds[3] = {0, 0, 0};
 {
        int ret, fds[3] = {0, 0, 0};
-        pid_t pid;
+       pid_t pid;
        char *cmdline = make_message(BINDIR "/para_client %s", cmd);
        PARA_INFO_LOG("%s", cmdline);
        ret = para_exec_cmdline_pid(&pid, cmdline, fds);
        char *cmdline = make_message(BINDIR "/para_client %s", cmd);
        PARA_INFO_LOG("%s", cmdline);
        ret = para_exec_cmdline_pid(&pid, cmdline, fds);
index 46b48251d757c91360126d927469deab08769e88..a035c6e652cdfebed3d59708d763768c5c5e3bc2 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -34,7 +34,7 @@ static struct filter_chain_info *fci = &filter_chain_info_struct;
 
 struct gengetopt_args_info conf;
 
 
 struct gengetopt_args_info conf;
 
-__printf_2_3 void para_log(int ll, char* fmt,...)
+__printf_2_3 void para_log(int ll, const char* fmt,...)
 {
        va_list argp;
 
 {
        va_list argp;
 
index 42db37830718f3618bcb0d34c25cdb04bca60e05..a04e2d8206a78520eaa8b95ecc8970eeb8366325 100644 (file)
@@ -186,25 +186,19 @@ static int parse_filter_args(int filter_num, char *options, void **conf)
 {
        struct filter *f = &filters[filter_num];
        int i, argc = 2;
 {
        struct filter *f = &filters[filter_num];
        int i, argc = 2;
-       char *dummy_args[] = {"", "", NULL};
        char **argv;
 
 //     PARA_DEBUG_LOG("%s, options: %s, parser: %p\n", f->name,
 //             options? options : "(none)", f->parse_config);
        if (!f->parse_config)
        char **argv;
 
 //     PARA_DEBUG_LOG("%s, options: %s, parser: %p\n", f->name,
 //             options? options : "(none)", f->parse_config);
        if (!f->parse_config)
-               return options? -E_BAD_FILTER_OPTIONS : filter_num;
-       if (options) {
-//             PARA_DEBUG_LOG("options: %s\n", options);
-               argc = split_args(options, &argv, ' ');
+               return strlen(options)? -E_BAD_FILTER_OPTIONS : filter_num;
+//     PARA_DEBUG_LOG("options: %s\n", options);
+       argc = split_args(options, &argv, ' ');
 //             PARA_DEBUG_LOG("argc = %d, argv[0]: %s\n", argc, argv[0]);
 //             PARA_DEBUG_LOG("argc = %d, argv[0]: %s\n", argc, argv[0]);
-               for (i = argc; i >= 0; i--)
-                       argv[i + 1] = argv[i];
-               argc += 2;
-               *conf = f->parse_config(argc, argv);
-       } else {
-               /* is it OK to have no options? */
-               *conf = f->parse_config(2, dummy_args);
-       }
+       for (i = argc; i >= 0; i--)
+               argv[i + 1] = argv[i];
+       argc += 2;
+       *conf = f->parse_config(argc, argv);
        return *conf? filter_num : -E_BAD_FILTER_OPTIONS;
 }
 
        return *conf? filter_num : -E_BAD_FILTER_OPTIONS;
 }
 
@@ -245,7 +239,8 @@ int check_filter_arg(char *fa, void **conf)
                        continue;
                if (c && !filters[j].parse_config)
                        return -E_BAD_FILTER_OPTIONS;
                        continue;
                if (c && !filters[j].parse_config)
                        return -E_BAD_FILTER_OPTIONS;
-               return parse_filter_args(j, c? fa + len + 1 : NULL, conf);
+               return parse_filter_args(j, c? fa + len + 1 :
+                       fa + strlen(fa), conf);
        }
        return -E_UNSUPPORTED_FILTER;
 }
        }
        return -E_UNSUPPORTED_FILTER;
 }
diff --git a/gui.c b/gui.c
index fff5741dca26c6a472cd67b2fdd7d638131fe3b6..7b10992c8d0b7282a3854b473ed38cebbca83d67 100644 (file)
--- a/gui.c
+++ b/gui.c
@@ -73,9 +73,9 @@ enum {GETCH_MODE, COMMAND_MODE, EXTERNAL_MODE};
 #define COLOR_BOT 40
 
 struct gui_command {
 #define COLOR_BOT 40
 
 struct gui_command {
-       char *key;
-       char *name;
-       char *description;
+       const char *key;
+       const char *name;
+       const char *description;
        void (*handler)(void);
 };
 
        void (*handler)(void);
 };
 
@@ -284,7 +284,7 @@ static void add_spaces(WINDOW* win, unsigned int num)
  * print aligned string to curses window. This function always prints
  * exactly len chars.
  */
  * print aligned string to curses window. This function always prints
  * exactly len chars.
  */
-static int align_str(WINDOW* win, char *string, unsigned int len,
+static int align_str(WINDOW* win, const char *string, unsigned int len,
                unsigned int align)
 {
        int num; /* of spaces */
                unsigned int align)
 {
        int num; /* of spaces */
@@ -313,7 +313,7 @@ static int align_str(WINDOW* win, char *string, unsigned int len,
        return 1;
 }
 
        return 1;
 }
 
-__printf_2_3 static void print_in_bar(int color, char *fmt,...)
+__printf_2_3 static void print_in_bar(int color, const char *fmt,...)
 {
        char *msg;
 
 {
        char *msg;
 
@@ -442,7 +442,7 @@ static void rb_add_entry(int color, char *msg)
 /*
  * print formated output to bot win and refresh
  */
 /*
  * print formated output to bot win and refresh
  */
-__printf_2_3 static void outputf(int color, char* fmt,...)
+__printf_2_3 static void outputf(int color, const char* fmt,...)
 {
        char *msg;
 
 {
        char *msg;
 
@@ -460,7 +460,7 @@ static void add_output_line(char *line)
        rb_add_entry(COLOR_OUTPUT, para_strdup(line));
 }
 
        rb_add_entry(COLOR_OUTPUT, para_strdup(line));
 }
 
-void para_log(int ll, char *fmt,...)
+void para_log(int ll, const char *fmt,...)
 {
        int color;
        char *msg;
 {
        int color;
        char *msg;
@@ -519,7 +519,7 @@ static void finish(int ret)
 /*
  * exit curses and print given message to stdout/stderr
  */
 /*
  * exit curses and print given message to stdout/stderr
  */
-__printf_2_3 static void msg_n_exit(int ret, char* fmt, ...)
+__printf_2_3 static void msg_n_exit(int ret, const char* fmt, ...)
 {
        va_list argp;
        FILE *outfd = ret? stderr: stdout;
 {
        va_list argp;
        FILE *outfd = ret? stderr: stdout;
@@ -1172,24 +1172,26 @@ static void com_help(void)
        int i;
 
        for (i = 0; i < conf.key_map_given; ++i) {
        int i;
 
        for (i = 0; i < conf.key_map_given; ++i) {
-               char *s = conf.key_map_arg[i], *handler, *arg,
-                       *desc = "", tmp[MAXLINE];
+               char *handler, *arg, *tmp = para_strdup(conf.key_map_arg[i]);
+               const char *handler_text = "???", *desc = NULL;
 
 
-               strcpy(tmp, s);
-               if (!split_key_map(tmp, &handler, &arg))
+               if (!split_key_map(tmp, &handler, &arg)) {
+                       free(tmp);
                        return;
                        return;
-               switch(*handler) {
+               }
+               switch (*handler) {
                        case 'i':
                        case 'i':
-                               handler = "internal";
+                               handler_text = "internal";
                                desc = command_list[find_cmd_byname(arg)].description;
                                break;
                                desc = command_list[find_cmd_byname(arg)].description;
                                break;
-                       case 'x': handler = "external"; break;
-                       case 'd': handler = "display "; break;
-                       case 'p': handler = "para    "; break;
+                       case 'x': handler_text = "external"; break;
+                       case 'd': handler_text = "display "; break;
+                       case 'p': handler_text = "para    "; break;
                }
                }
-               outputf(COLOR_MSG, "%s\t%s\t%s%s\t%s", tmp, handler, arg,
+               outputf(COLOR_MSG, "%s\t%s\t%s%s\t%s", tmp, handler_text, arg,
                        strlen(arg) < 8? "\t" : "",
                        strlen(arg) < 8? "\t" : "",
-                       desc);
+                       desc? desc : "");
+               free(tmp);
        }
        for (i = 0; command_list[i].handler; i++) {
                struct gui_command gc = command_list[i];
        }
        for (i = 0; command_list[i].handler; i++) {
                struct gui_command gc = command_list[i];
@@ -1200,7 +1202,6 @@ static void com_help(void)
        }
        print_in_bar(COLOR_MSG, "try \"para_gui -h\" or \"para_client help\" "
                "for more info");
        }
        print_in_bar(COLOR_MSG, "try \"para_gui -h\" or \"para_client help\" "
                "for more info");
-       return;
 }
 
 static void com_shrink_top_win(void)
 }
 
 static void com_shrink_top_win(void)
index 73d2fb0d51f6d63663387e16a1b2b574f7024bd7..276c0e416bb1218b2c24788bbe86f671da58731c 100644 (file)
@@ -271,7 +271,7 @@ static void http_post_select(__unused struct audio_format *af, fd_set *rfds,
 {
        int i = -1, match;
        struct http_client *hc, *tmp;
 {
        int i = -1, match;
        struct http_client *hc, *tmp;
-       char *err_msg;
+       const char *err_msg;
 
        list_for_each_entry_safe(hc, tmp, &clients, node) {
                i++;
 
        list_for_each_entry_safe(hc, tmp, &clients, node) {
                i++;
diff --git a/mp3.c b/mp3.c
index c1d5ae3f12277ae32365955e932c87570ed093cb..b605b4ea5f3df3c5c866342da55e43549206fc44 100644 (file)
--- a/mp3.c
+++ b/mp3.c
@@ -101,7 +101,7 @@ static int mp3info_bitrate[2][3][14] = {
 };
 
 static int frame_size_index[] = {24000, 72000, 72000};
 };
 
 static int frame_size_index[] = {24000, 72000, 72000};
-static char *mode_text[] = {"stereo", "joint stereo", "dual channel", "mono", "invalid"};
+static const char *mode_text[] = {"stereo", "joint stereo", "dual channel", "mono", "invalid"};
 
 static struct mp3info mp3;
 static char mp3buf[8192];
 
 static struct mp3info mp3;
 static char mp3buf[8192];
@@ -125,7 +125,7 @@ static int header_frequency(struct mp3header *h)
        return frequencies[h->version][h->freq];
 }
 
        return frequencies[h->version][h->freq];
 }
 
-static char *header_mode(struct mp3header *h)
+static const char *header_mode(struct mp3header *h)
 {
        if (h->mode > 4)
                h->mode = 4; /* invalid */
 {
        if (h->mode > 4)
                h->mode = 4; /* invalid */
index cdb36dd2d0a3d50a008c3579b8e2a733e69e8a04..a53632c524c8be7bdc05d91d2365deb9ff00289e 100644 (file)
@@ -599,7 +599,7 @@ static struct para_macro macro_list[] = {
        }
 };
 
        }
 };
 
-static int real_query(char *query)
+static int real_query(const char *query)
 {
        if (!mysql_ptr)
                return -E_NOTCONN;
 {
        if (!mysql_ptr)
                return -E_NOTCONN;
@@ -616,7 +616,7 @@ static int real_query(char *query)
  * Use open connection given by mysql_ptr to query server. Returns a
  * result pointer on succes and NULL on errors
  */
  * Use open connection given by mysql_ptr to query server. Returns a
  * result pointer on succes and NULL on errors
  */
-static struct MYSQL_RES *get_result(char *query)
+static struct MYSQL_RES *get_result(const char *query)
 {
        void *result;
 
 {
        void *result;
 
@@ -1337,7 +1337,7 @@ out:
                free(name);
        return ret;
 }
                free(name);
        return ret;
 }
-static int change_stream(char *stream)
+static int change_stream(const char *stream)
 {
        char *query;
        int ret;
 {
        char *query;
        int ret;
@@ -1516,7 +1516,7 @@ static int com_set(__unused int fd, int argc, char *argv[])
        char *q, *ebn;
        long unsigned id;
        int i, ret;
        char *q, *ebn;
        long unsigned id;
        int i, ret;
-       char *field = strcmp(argv[0], "picass")? "numplayed" : "pic_id";
+       const char *field = strcmp(argv[0], "picass")? "numplayed" : "pic_id";
 
        if (argc < 2)
                return -E_MYSQL_SYNTAX;
 
        if (argc < 2)
                return -E_MYSQL_SYNTAX;
@@ -2435,17 +2435,9 @@ static void write_msg2mmd(int success)
 /* create database */
 static int com_cdb(int fd, int argc, char *argv[])
 {
 /* create database */
 static int com_cdb(int fd, int argc, char *argv[])
 {
-       char *query, *name;
+       char *query;
        int ret;
 
        int ret;
 
-       if (argc < 1)
-               name = "paraslash";
-       else {
-               ret = -E_NAMETOOLONG;
-               name = argv[1];
-               if (strlen(name) > MAXLINE)
-                       goto out;
-       }
        if (mysql_ptr) {
                PARA_INFO_LOG("%s", "closing database\n");
                mysql_close(mysql_ptr);
        if (mysql_ptr) {
                PARA_INFO_LOG("%s", "closing database\n");
                mysql_close(mysql_ptr);
@@ -2455,14 +2447,15 @@ static int com_cdb(int fd, int argc, char *argv[])
        ret = -E_MYSQL_INIT;
        if (init_mysql_server() < 0 || !mysql_ptr)
                goto out;
        ret = -E_MYSQL_INIT;
        if (init_mysql_server() < 0 || !mysql_ptr)
                goto out;
-       query = make_message("create database %s", name);
+       conf.mysql_database_arg = para_strdup((argc < 1)?
+               "paraslash" : argv[1]);
+       query = make_message("create database %s", conf.mysql_database_arg);
        ret = real_query(query);
        free(query);
        if (ret < 0)
                goto out;
        /* reconnect with database just created */
        mysql_close(mysql_ptr);
        ret = real_query(query);
        free(query);
        if (ret < 0)
                goto out;
        /* reconnect with database just created */
        mysql_close(mysql_ptr);
-       conf.mysql_database_arg = para_strdup(name);
        ret = -E_MYSQL_INIT;
        if (init_mysql_server() < 0 || !mysql_ptr)
                goto out;
        ret = -E_MYSQL_INIT;
        if (init_mysql_server() < 0 || !mysql_ptr)
                goto out;
@@ -2493,7 +2486,8 @@ static int com_cdb(int fd, int argc, char *argv[])
        if (real_query("insert into streams (name, def) values "
                        "('current_stream', '(none)')") < 0)
                goto out;
        if (real_query("insert into streams (name, def) values "
                        "('current_stream', '(none)')") < 0)
                goto out;
-       ret = send_va_buffer(fd, "successfully created database %s\n", name);
+       ret = send_va_buffer(fd, "successfully created database %s\n",
+               conf.mysql_database_arg);
 out:
        return ret;
 }
 out:
        return ret;
 }
diff --git a/net.c b/net.c
index e897645167d86a45f454d4ef213fc198d7f8ecd1..9ca5ceac95bc47f1b3becf71d83318894f8a719a 100644 (file)
--- a/net.c
+++ b/net.c
@@ -130,7 +130,7 @@ int send_buffer(int fd, const char *buf)
  *
  * @return Positive on success, \p -E_SEND on errors.
  */
  *
  * @return Positive on success, \p -E_SEND on errors.
  */
-__printf_2_3 int send_va_buffer(int fd, char *fmt, ...)
+__printf_2_3 int send_va_buffer(int fd, const char *fmt, ...)
 {
        char *msg;
        int ret;
 {
        char *msg;
        int ret;
diff --git a/net.h b/net.h
index c2f32c78edfd4613ab2bf42ee3b5094aaa523c02..18f36c09c93c7d24e1b55a2aad6f672d54e244fa 100644 (file)
--- a/net.h
+++ b/net.h
@@ -34,7 +34,7 @@ void init_sockaddr(struct sockaddr_in*, int, const struct hostent*);
 int para_connect(int, struct sockaddr_in *);
 int send_buffer(int, const char *);
 int send_bin_buffer(int, const char *, size_t);
 int para_connect(int, struct sockaddr_in *);
 int send_buffer(int, const char *);
 int send_bin_buffer(int, const char *, size_t);
-int send_va_buffer(int, char *, ...);
+int send_va_buffer(int, const char *, ...);
 int recv_buffer(int, char *, ssize_t);
 int recv_bin_buffer(int, char *, ssize_t);
 int para_accept(int, void *addr, socklen_t size);
 int recv_buffer(int, char *, ssize_t);
 int recv_bin_buffer(int, char *, ssize_t);
 int para_accept(int, void *addr, socklen_t size);
diff --git a/para.h b/para.h
index d495139ea095ebdeea9abac7a773c053adc22f2e..9c0618f783afad96a4f71c267dfd349c8e539c67 100644 (file)
--- a/para.h
+++ b/para.h
@@ -123,8 +123,7 @@ int read_audiod_pipe(int, void (*)(char *));
 
 /* exec */
 int file_exists(const char *);
 
 /* exec */
 int file_exists(const char *);
-int para_exec(pid_t *, const char *, char *const [], int *);
-int para_exec_cmdline_pid(pid_t *, char *, int *);
+int para_exec_cmdline_pid(pid_t *pid, const char *cmdline, int *fds);
 
 /* signal */
 int para_signal_init(void);
 
 /* signal */
 int para_signal_init(void);
@@ -166,15 +165,15 @@ void dump_empty_status(void);
 unsigned for_each_line(char *, int, void (*)(char *));
 
 struct stat_item_data {
 unsigned for_each_line(char *, int, void (*)(char *));
 
 struct stat_item_data {
-       char *prefix, *postfix;
+       const char *prefix, *postfix;
        unsigned x, y, len;
        int fg, bg, align;
 };
 
 /* gui_theme */
 struct gui_theme {
        unsigned x, y, len;
        int fg, bg, align;
 };
 
 /* gui_theme */
 struct gui_theme {
-       char *name;
-       char *author;
+       const char *name;
+       const char *author;
        int sb_fg, sb_bg;
        int cmd_fg, cmd_bg;
        int output_fg, output_bg;
        int sb_fg, sb_bg;
        int cmd_fg, cmd_bg;
        int output_fg, output_bg;
@@ -182,7 +181,7 @@ struct gui_theme {
        int err_msg_fg, err_msg_bg;
        int welcome_fg, welcome_bg;
        int sep_fg, sep_bg;
        int err_msg_fg, err_msg_bg;
        int welcome_fg, welcome_bg;
        int sep_fg, sep_bg;
-       char *sep_str;
+       const char *sep_str;
        int default_fg, default_bg;
 
        int top_lines_default, top_lines_min;
        int default_fg, default_bg;
 
        int top_lines_default, top_lines_min;
@@ -198,7 +197,7 @@ void prev_theme(struct gui_theme *);
 #define CENTER 3
 
 
 #define CENTER 3
 
 
-__printf_2_3 void para_log(int, char*, ...);
+__printf_2_3 void para_log(int, const char*, ...);
 
 /* taken from printf man page */
 #define PARA_VSPRINTF(fmt, p) \
 
 /* taken from printf man page */
 #define PARA_VSPRINTF(fmt, p) \
diff --git a/recv.c b/recv.c
index 13c5c420d35059d80fa25ba4e6c9cb73551f9b06..fd82bc0fa6d998e51072284aefe1dc5d79dd3663 100644 (file)
--- a/recv.c
+++ b/recv.c
@@ -25,7 +25,7 @@ struct gengetopt_args_info conf;
 
 INIT_RECV_ERRLISTS;
 
 
 INIT_RECV_ERRLISTS;
 
-__printf_2_3 void para_log(int ll, char* fmt,...)
+__printf_2_3 void para_log(int ll, const char* fmt,...)
 {
        va_list argp;
 
 {
        va_list argp;
 
index 81acd545ff4a5be97a5b0d9afba1e96816d86f5b..d0bf2fbf65ae24df22e8224b3154f0720ff58286 100644 (file)
--- a/sdl_gui.c
+++ b/sdl_gui.c
@@ -68,19 +68,19 @@ struct gengetopt_args_info args_info;
 
 
 struct stat_item{
 
 
 struct stat_item{
-        char *name;
-        char *prefix;
-        char *postfix;
-        char *content;
-        unsigned x;
-        unsigned y;
-        unsigned w;
-        unsigned h;
+       const char *name;
+       const char *prefix;
+       const char *postfix;
+       char *content;
+       unsigned x;
+       unsigned y;
+       unsigned w;
+       unsigned h;
        Uint8 r;
        Uint8 g;
        Uint8 b;
        Uint8 r;
        Uint8 g;
        Uint8 b;
-        int font;
-        int align;
+       int font;
+       int align;
 };
 
 struct font {
 };
 
 struct font {
@@ -118,7 +118,7 @@ struct font fonts[] = {
 
 static struct stat_item stat_items[NUM_STAT_ITEMS];
 
 
 static struct stat_item stat_items[NUM_STAT_ITEMS];
 
-void para_log(__unused int ll, __unused char* fmt,...) /* no logging */
+void para_log(__unused int ll, __unused const char* fmt,...) /* no logging */
 {
 }
 
 {
 }
 
@@ -135,7 +135,6 @@ static void init_stat_items(void)
 
        s[SI_STATUS_BAR].prefix = "";
        s[SI_STATUS_BAR].postfix = "";
 
        s[SI_STATUS_BAR].prefix = "";
        s[SI_STATUS_BAR].postfix = "";
-       s[SI_STATUS_BAR].content = "";
        s[SI_STATUS_BAR].x = 0;
        s[SI_STATUS_BAR].y = 10;
        s[SI_STATUS_BAR].w = 100;
        s[SI_STATUS_BAR].x = 0;
        s[SI_STATUS_BAR].y = 10;
        s[SI_STATUS_BAR].w = 100;
@@ -148,7 +147,6 @@ static void init_stat_items(void)
 
        s[SI_PLAY_TIME].prefix = "";
        s[SI_PLAY_TIME].postfix = "";
 
        s[SI_PLAY_TIME].prefix = "";
        s[SI_PLAY_TIME].postfix = "";
-       s[SI_PLAY_TIME].content = "";
        s[SI_PLAY_TIME].x = 35;
        s[SI_PLAY_TIME].y = 20;
        s[SI_PLAY_TIME].w = 65;
        s[SI_PLAY_TIME].x = 35;
        s[SI_PLAY_TIME].y = 20;
        s[SI_PLAY_TIME].w = 65;
@@ -161,7 +159,6 @@ static void init_stat_items(void)
 
        s[SI_STATUS].prefix = "";
        s[SI_STATUS].postfix = "";
 
        s[SI_STATUS].prefix = "";
        s[SI_STATUS].postfix = "";
-       s[SI_STATUS].content = "";
        s[SI_STATUS].x = 35;
        s[SI_STATUS].y = 28;
        s[SI_STATUS].w = 12;
        s[SI_STATUS].x = 35;
        s[SI_STATUS].y = 28;
        s[SI_STATUS].w = 12;
@@ -174,7 +171,6 @@ static void init_stat_items(void)
 
        s[SI_STATUS_FLAGS].prefix = " (";
        s[SI_STATUS_FLAGS].postfix = ")";
 
        s[SI_STATUS_FLAGS].prefix = " (";
        s[SI_STATUS_FLAGS].postfix = ")";
-       s[SI_STATUS_FLAGS].content = "";
        s[SI_STATUS_FLAGS].x = 47;
        s[SI_STATUS_FLAGS].y = 28;
        s[SI_STATUS_FLAGS].w = 15;
        s[SI_STATUS_FLAGS].x = 47;
        s[SI_STATUS_FLAGS].y = 28;
        s[SI_STATUS_FLAGS].w = 15;
@@ -187,7 +183,6 @@ static void init_stat_items(void)
 
        s[SI_NUM_PLAYED].prefix = "#";
        s[SI_NUM_PLAYED].postfix = "";
 
        s[SI_NUM_PLAYED].prefix = "#";
        s[SI_NUM_PLAYED].postfix = "";
-       s[SI_NUM_PLAYED].content = "0";
        s[SI_NUM_PLAYED].x = 62;
        s[SI_NUM_PLAYED].y = 28;
        s[SI_NUM_PLAYED].w = 13;
        s[SI_NUM_PLAYED].x = 62;
        s[SI_NUM_PLAYED].y = 28;
        s[SI_NUM_PLAYED].w = 13;
@@ -200,7 +195,6 @@ static void init_stat_items(void)
 
        s[SI_UPTIME].prefix = "Up: ";
        s[SI_UPTIME].postfix = "";
 
        s[SI_UPTIME].prefix = "Up: ";
        s[SI_UPTIME].postfix = "";
-       s[SI_UPTIME].content = "";
        s[SI_UPTIME].x = 75;
        s[SI_UPTIME].y = 28;
        s[SI_UPTIME].w = 25;
        s[SI_UPTIME].x = 75;
        s[SI_UPTIME].y = 28;
        s[SI_UPTIME].w = 25;
@@ -213,7 +207,6 @@ static void init_stat_items(void)
 
        s[SI_SELECTOR].prefix = "selector: ";
        s[SI_SELECTOR].postfix = "";
 
        s[SI_SELECTOR].prefix = "selector: ";
        s[SI_SELECTOR].postfix = "";
-       s[SI_SELECTOR].content = "no content yet";
        s[SI_SELECTOR].x = 35;
        s[SI_SELECTOR].y = 48;
        s[SI_SELECTOR].w = 35;
        s[SI_SELECTOR].x = 35;
        s[SI_SELECTOR].y = 48;
        s[SI_SELECTOR].w = 35;
@@ -226,7 +219,6 @@ static void init_stat_items(void)
 
        s[SI_FORMAT].prefix = "Format: ";
        s[SI_FORMAT].postfix = "";
 
        s[SI_FORMAT].prefix = "Format: ";
        s[SI_FORMAT].postfix = "";
-       s[SI_FORMAT].content = "";
        s[SI_FORMAT].x = 70;
        s[SI_FORMAT].y = 48;
        s[SI_FORMAT].w = 30;
        s[SI_FORMAT].x = 70;
        s[SI_FORMAT].y = 48;
        s[SI_FORMAT].w = 30;
@@ -239,7 +231,6 @@ static void init_stat_items(void)
 
        s[SI_MTIME].prefix = "MTime: ";
        s[SI_MTIME].postfix = "";
 
        s[SI_MTIME].prefix = "MTime: ";
        s[SI_MTIME].postfix = "";
-       s[SI_MTIME].content = "";
        s[SI_MTIME].x = 35;
        s[SI_MTIME].y = 35;
        s[SI_MTIME].w = 65;
        s[SI_MTIME].x = 35;
        s[SI_MTIME].y = 35;
        s[SI_MTIME].w = 65;
@@ -252,7 +243,6 @@ static void init_stat_items(void)
 
        s[SI_FILE_SIZE].prefix = "Size: ";
        s[SI_FILE_SIZE].postfix = "kb";
 
        s[SI_FILE_SIZE].prefix = "Size: ";
        s[SI_FILE_SIZE].postfix = "kb";
-       s[SI_FILE_SIZE].content = "";
        s[SI_FILE_SIZE].x = 35;
        s[SI_FILE_SIZE].y = 42;
        s[SI_FILE_SIZE].w = 20;
        s[SI_FILE_SIZE].x = 35;
        s[SI_FILE_SIZE].y = 42;
        s[SI_FILE_SIZE].w = 20;
@@ -265,7 +255,6 @@ static void init_stat_items(void)
 
        s[SI_AUDIO_INFO1].prefix = "";
        s[SI_AUDIO_INFO1].postfix = "";
 
        s[SI_AUDIO_INFO1].prefix = "";
        s[SI_AUDIO_INFO1].postfix = "";
-       s[SI_AUDIO_INFO1].content = "";
        s[SI_AUDIO_INFO1].x = 0;
        s[SI_AUDIO_INFO1].y = 60;
        s[SI_AUDIO_INFO1].w = 100;
        s[SI_AUDIO_INFO1].x = 0;
        s[SI_AUDIO_INFO1].y = 60;
        s[SI_AUDIO_INFO1].w = 100;
@@ -278,7 +267,6 @@ static void init_stat_items(void)
 
        s[SI_AUDIO_INFO2].prefix = "";
        s[SI_AUDIO_INFO2].postfix = "";
 
        s[SI_AUDIO_INFO2].prefix = "";
        s[SI_AUDIO_INFO2].postfix = "";
-       s[SI_AUDIO_INFO2].content = "";
        s[SI_AUDIO_INFO2].x = 0;
        s[SI_AUDIO_INFO2].y = 65;
        s[SI_AUDIO_INFO2].w = 100;
        s[SI_AUDIO_INFO2].x = 0;
        s[SI_AUDIO_INFO2].y = 65;
        s[SI_AUDIO_INFO2].w = 100;
@@ -291,7 +279,6 @@ static void init_stat_items(void)
 
        s[SI_AUDIO_INFO3].prefix = "";
        s[SI_AUDIO_INFO3].postfix = "";
 
        s[SI_AUDIO_INFO3].prefix = "";
        s[SI_AUDIO_INFO3].postfix = "";
-       s[SI_AUDIO_INFO3].content = "";
        s[SI_AUDIO_INFO3].x = 0;
        s[SI_AUDIO_INFO3].y = 70;
        s[SI_AUDIO_INFO3].w = 100;
        s[SI_AUDIO_INFO3].x = 0;
        s[SI_AUDIO_INFO3].y = 70;
        s[SI_AUDIO_INFO3].w = 100;
@@ -305,7 +292,6 @@ static void init_stat_items(void)
        s[SI_DBINFO1].name = "dbinfo1:";
        s[SI_DBINFO1].prefix = "";
        s[SI_DBINFO1].postfix = "";
        s[SI_DBINFO1].name = "dbinfo1:";
        s[SI_DBINFO1].prefix = "";
        s[SI_DBINFO1].postfix = "";
-       s[SI_DBINFO1].content = "";
        s[SI_DBINFO1].x = 0;
        s[SI_DBINFO1].y = 83;
        s[SI_DBINFO1].w = 100;
        s[SI_DBINFO1].x = 0;
        s[SI_DBINFO1].y = 83;
        s[SI_DBINFO1].w = 100;
@@ -318,7 +304,6 @@ static void init_stat_items(void)
 
        s[SI_DBINFO2].prefix = "";
        s[SI_DBINFO2].postfix = "";
 
        s[SI_DBINFO2].prefix = "";
        s[SI_DBINFO2].postfix = "";
-       s[SI_DBINFO2].content = "";
        s[SI_DBINFO2].x = 0;
        s[SI_DBINFO2].y = 88;
        s[SI_DBINFO2].w = 100;
        s[SI_DBINFO2].x = 0;
        s[SI_DBINFO2].y = 88;
        s[SI_DBINFO2].w = 100;
@@ -332,7 +317,6 @@ static void init_stat_items(void)
        s[SI_DBINFO3].name = "dbinfo3:";
        s[SI_DBINFO3].prefix = "";
        s[SI_DBINFO3].postfix = "";
        s[SI_DBINFO3].name = "dbinfo3:";
        s[SI_DBINFO3].prefix = "";
        s[SI_DBINFO3].postfix = "";
-       s[SI_DBINFO3].content = "";
        s[SI_DBINFO3].x = 0;
        s[SI_DBINFO3].y = 93;
        s[SI_DBINFO3].w = 100;
        s[SI_DBINFO3].x = 0;
        s[SI_DBINFO3].y = 93;
        s[SI_DBINFO3].w = 100;
@@ -450,7 +434,7 @@ static void tab2space(char *text)
        }
 }
 
        }
 }
 
-static void print_msg(char *msg)
+static void print_msg(const char *msg)
 {
        SFont_FontInfo *font = &(fonts[MSG_FONT].fontinfo);
        char *buf = strdup(msg);
 {
        SFont_FontInfo *font = &(fonts[MSG_FONT].fontinfo);
        char *buf = strdup(msg);
@@ -499,7 +483,7 @@ SDLKey get_key(void)
 /*
  * print message, wait for key (blocking), return 1 for 'q', 0 else
  */
 /*
  * print message, wait for key (blocking), return 1 for 'q', 0 else
  */
-static SDLKey hit_key(char *msg)
+static SDLKey hit_key(const char *msg)
 {
        SDLKey sym;
 
 {
        SDLKey sym;
 
index c2ede7aa92566337c8d5644d1913da5b247ff512..8c9b48a6e371e27bad84baaa482556a4fda45550 100644 (file)
--- a/server.c
+++ b/server.c
@@ -123,7 +123,7 @@ static int signal_pipe;
  * \param ll the log level
  * \param fmt the format string describing the log message
  */
  * \param ll the log level
  * \param fmt the format string describing the log message
  */
-void para_log(int ll, char* fmt,...)
+void para_log(int ll, const char* fmt,...)
 {
        va_list argp;
        FILE *outfd;
 {
        va_list argp;
        FILE *outfd;
index fcda7a3ace835d65c0e960640291396e62f628ea..7f10a9fcd455bf06df0a68ba7f52b2c90cb9fecc 100644 (file)
--- a/server.h
+++ b/server.h
@@ -51,17 +51,17 @@ struct user{
  */
 struct server_command {
 /** the name of the command */
  */
 struct server_command {
 /** the name of the command */
-       char *name;
+       const char *name;
 /** pointer to the function that handles the command */
        int (*handler)(int, int, char **);
 /** the privileges a user must have to execute this command */
        unsigned int perms;
 /** one-line description of the command */
 /** pointer to the function that handles the command */
        int (*handler)(int, int, char **);
 /** the privileges a user must have to execute this command */
        unsigned int perms;
 /** one-line description of the command */
-       char *description;
+       const char *description;
 /** summary of the command line options */
 /** summary of the command line options */
-       char *synopsis;
+       const char *synopsis;
 /** the long help text */
 /** the long help text */
-       char *help;
+       const char *help;
 };
 
 /** holds the arguments for the para_server's sender command */
 };
 
 /** holds the arguments for the para_server's sender command */
index d0bb6d8df8922d6a458d56f80e6b54775ded9bab..9b7f96c8eac674970f862fd522ca399c78d7457f 100644 (file)
--- a/slider.c
+++ b/slider.c
@@ -44,7 +44,7 @@ static char **argv;
 char *streamname = NULL;
 static Zmw_Float_0_1 *slider_vals, lastplayed_val, numplayed_val;
 
 char *streamname = NULL;
 static Zmw_Float_0_1 *slider_vals, lastplayed_val, numplayed_val;
 
-void para_log(int ll, char* fmt,...) /* no logging */
+void para_log(int ll, const char* fmt,...) /* no logging */
 {
 }
 
 {
 }
 
index 156404c48ccf7036db2b875c1f1c3832a2a6f123..fba36e5fcc6f92ca1542fd9b5989f61099ad584a 100644 (file)
--- a/string.c
+++ b/string.c
@@ -374,7 +374,8 @@ __must_check __malloc char *para_homedir(void)
  * This function modifies \a args by replacing each occurance of \a delim by
  * zero. A NULL-terminated array of pointers to char* is allocated dynamically
  * and these pointers are initialized to point to the broken-up substrings
  * This function modifies \a args by replacing each occurance of \a delim by
  * zero. A NULL-terminated array of pointers to char* is allocated dynamically
  * and these pointers are initialized to point to the broken-up substrings
- * within \a args. A pointer to this array is returned via \a argv_ptr.
+ * within \a args. A pointer to this array is returned via \a argv_ptr. It's OK
+ * to call this function with \a args == NULL.
  *
  * \return The number of substrings found in \a args.
  */
  *
  * \return The number of substrings found in \a args.
  */
@@ -384,11 +385,11 @@ __must_check unsigned split_args(char *args, char ***argv_ptr, int delim)
        char **argv;
        ssize_t n = 0, i;
 
        char **argv;
        ssize_t n = 0, i;
 
-       while ((p = strchr(p, delim))) {
+       while (p && (p = strchr(p, delim))) {
                p++;
                n++;
        }
                p++;
                n++;
        }
-       *argv_ptr = para_malloc((n + 3) * sizeof(char *));
+       *argv_ptr = para_calloc((n + 3) * sizeof(char *));
        argv = *argv_ptr;
        i = 0;
        p = args;
        argv = *argv_ptr;
        i = 0;
        p = args;
@@ -404,7 +405,6 @@ __must_check unsigned split_args(char *args, char ***argv_ptr, int delim)
                        i++;
                }
        }
                        i++;
                }
        }
-       argv[n + 1] = NULL;
        return n;
 }
 
        return n;
 }
 
index 9fb42b263363b6f2584a7807ad4e7bf1b0f0fc64..bd82fd58b3bda14d73dadb68fd079dbb9f57b1ba 100644 (file)
--- a/string.h
+++ b/string.h
@@ -24,9 +24,9 @@
  */
 struct para_macro {
        /** the name of the macro */
  */
 struct para_macro {
        /** the name of the macro */
-       char *name;
+       const char *name;
        /** the replacement text */
        /** the replacement text */
-       char *replacement;
+       const char *replacement;
 };
 __must_check __malloc void *para_realloc(void *p, size_t size);
 __must_check __malloc void *para_malloc(size_t size);
 };
 __must_check __malloc void *para_realloc(void *p, size_t size);
 __must_check __malloc void *para_malloc(size_t size);