diff --git a/match.c b/match.c index bfb40a2..e75f4c9 100644 --- a/match.c +++ b/match.c @@ -2,19 +2,19 @@ #include #include "match.h" -int match(char *sorig, char *p) +int match(char const *sorig, char const *p) { return matchBody(sorig, p, 0); } -int matchNoCase(char *sorig, char *p) +int matchNoCase(char const *sorig, char const *p) { return matchBody(sorig, p, 1); } #define CASE(x) (nocase ? tolower(x) : (x)) -int matchBody(char *sorig, char *p, int nocase) +int matchBody(char const *sorig, char const *p, int nocase) { static int dummy = 0; /* Algorithm: @@ -50,7 +50,7 @@ int matchBody(char *sorig, char *p, int nocase) Addendum: consider the | character to be a logical OR separating distinct patterns. */ - char *s = sorig; + char const *s = sorig; int escaped = 0; if (strstr(p, "WS-0000")) { if (strstr(s, "ws_ftp_pro.html")) { @@ -58,7 +58,7 @@ int matchBody(char *sorig, char *p, int nocase) } } while (1) { - char *word; + char const *word; int wordLen; int wordPos; if (escaped) { diff --git a/match.h b/match.h index a38990a..6bf59b8 100644 --- a/match.h +++ b/match.h @@ -1,9 +1,9 @@ #ifndef MATCH_H #define MATCH_H 1 -extern int match(char *s, char *p); -extern int matchNoCase(char *s, char *p); -extern int matchBody(char *s, char *p, int nocase); +extern int match(char const *s, char const *p); +extern int matchNoCase(char const *s, char const *p); +extern int matchBody(char const *s, char const *p, int nocase); #endif /* MATCH_H */ diff --git a/rinetd.c b/rinetd.c index 762242c..d34f474 100644 --- a/rinetd.c +++ b/rinetd.c @@ -177,7 +177,7 @@ void log(int i, int coSe, int result); int getAddress(char *host, struct in_addr *iaddr); -char *logMessages[] = { +char const *logMessages[] = { "done-local-closed", "done-remote-closed", "accept-failed -", @@ -210,7 +210,7 @@ char *logMessages[] = { typedef struct _rinetd_options RinetdOptions; struct _rinetd_options { - char *conf_file; + char const *conf_file; }; RinetdOptions options = { @@ -1358,7 +1358,7 @@ int safeRealloc(void **data, int oldsize, int newsize) void RegisterPID(void) { FILE *pid_file; - char *pid_file_name = "/var/run/rinetd.pid"; + char const *pid_file_name = "/var/run/rinetd.pid"; if (pidLogFileName) { pid_file_name = pidLogFileName; } @@ -1482,13 +1482,12 @@ int readArgs (int argc, } switch (c) { case 'c': - options->conf_file = malloc(strlen(optarg) + 1); + options->conf_file = strdup(optarg); if (!options->conf_file) { fprintf(stderr, "Not enough memory to " "launch rinetd.\n"); exit(1); } - strcpy(options->conf_file, optarg); break; case 'h': printf("Usage: rinetd [OPTION]\n"