summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkeithp <keithp@kemper.freedesktop.org>2006-02-15 00:52:26 -0800
committerkeithp <keithp@kemper.freedesktop.org>2006-02-15 00:52:26 -0800
commite9daee3c4da6e8b30c91a05bdf1d1e985581a558 (patch)
tree29953e9670e425dade985e8b9bb6995a5005f575
parent41d27f71c3f441500a18847eae44c544d6f0e599 (diff)
parented25b0cd454d216034d9419e45e28312fd96c1b2 (diff)
Merge in cworth changes to centralize strcmps
-rw-r--r--ssh-bleach.c75
1 files changed, 35 insertions, 40 deletions
diff --git a/ssh-bleach.c b/ssh-bleach.c
index 79273fa..4b3c3b3 100644
--- a/ssh-bleach.c
+++ b/ssh-bleach.c
@@ -25,12 +25,9 @@
int verbose = 0;
int cvs_server (char *line) {
- if (!strcmp (line, "cvs server")) {
- if (verbose)
- printf ("cvs server\n");
- return execl ("/usr/bin/cvs", "cvs", "server", NULL);
- }
- return 0;
+ if (verbose)
+ printf ("cvs server\n");
+ return execl ("/usr/bin/cvs", "cvs", "server", NULL);
}
char *get_quoted_arg (char *line)
@@ -62,42 +59,39 @@ char *get_quoted_arg (char *line)
}
int git_receive_pack (char *line) {
- char *arg;
-
- if (!strncmp (line, "git-receive-pack '", 18) &&
- (arg = get_quoted_arg (line)))
- {
- if (verbose)
- printf ("git-receive-pack '%s'\n", arg);
- return execl ("/usr/local/bin/git-receive-pack",
- "git-receive-pack",
- arg,
- NULL);
- }
- return 0;
+ char *arg = get_quoted_arg (line);
+ if (! arg)
+ return 0;
+
+ if (verbose)
+ printf ("git-receive-pack '%s'\n", arg);
+ return execl ("/usr/local/bin/git-receive-pack",
+ "git-receive-pack",
+ arg,
+ NULL);
}
int git_upload_pack (char *line) {
- char *arg;
-
- if (!strncmp (line, "git-upload-pack '", 17) &&
- (arg = get_quoted_arg (line)))
- {
- if (verbose)
- printf ("git-upload-pack '%s'\n", arg);
- return execl ("/usr/local/bin/git-upload-pack",
- "git-upload-pack",
- arg,
- NULL);
- }
- return 0;
+ char *arg = get_quoted_arg (line);
+ if (! arg)
+ return 0;
+
+ if (verbose)
+ printf ("git-upload-pack '%s'\n", arg);
+ return execl ("/usr/local/bin/git-upload-pack",
+ "git-upload-pack",
+ arg,
+ NULL);
}
-int (*commands[]) (char *line) = {
- cvs_server,
- git_receive_pack,
- git_upload_pack,
- NULL
+struct {
+ char *name;
+ int (*command) (char *line);
+} commands[] = {
+ { "cvs server", cvs_server },
+ { "git-receive-pack ", git_receive_pack },
+ { "git-upload-pack ", git_upload_pack },
+ { 0 }
};
int main (int argc, char **argv)
@@ -109,8 +103,9 @@ int main (int argc, char **argv)
verbose = 1;
if (!line)
return 1;
- for (i = 0; commands[i]; i++)
- if ((*commands[i]) (line) != 0)
- break;
+ for (i = 0; commands[i].name; i++)
+ if (! strncmp (line, commands[i].name, strlen (commands[i].name)))
+ if ((*commands[i].command) (line) != 0)
+ break;
return 1;
}