summaryrefslogtreecommitdiff
path: root/contrib/global/gozilla/gozilla.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/global/gozilla/gozilla.c')
-rw-r--r--contrib/global/gozilla/gozilla.c68
1 files changed, 51 insertions, 17 deletions
diff --git a/contrib/global/gozilla/gozilla.c b/contrib/global/gozilla/gozilla.c
index fd43bbf6150d..32d4730d21d8 100644
--- a/contrib/global/gozilla/gozilla.c
+++ b/contrib/global/gozilla/gozilla.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved.
+ * Copyright (c) 1996, 1997, 1998 Shigio Yamaguchi. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,17 +28,20 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * gozilla.c 27-Oct-97
+ * gozilla.c 17-Jul-98
*
*/
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "global.h"
-char *progname = "gozilla"; /* command name */
+const char *progname = "gozilla"; /* command name */
static void usage __P((void));
-void main __P((int, char **));
+
+int main __P((int, char **));
+int issource __P((char *));
int sendcommand __P((char *));
int bflag;
@@ -54,17 +57,17 @@ usage()
exit(1);
}
-void
+int
main(argc, argv)
int argc;
char *argv[];
{
char c, *p, *q;
- char *browser = (char *)0;
- char *command = (char *)0;
- char *arg = (char *)0;
+ char *browser = NULL;
+ char *command = NULL;
+ char *arg = NULL;
char URL[MAXPATHLEN+1];
- char com[MAXCOMLINE+1];
+ char com[MAXFILLEN+1];
int linenumber = 0;
int status;
@@ -101,16 +104,19 @@ char *argv[];
}
if (argc == 0)
usage();
- if (locatestring(argv[0], "http:", 1) || locatestring(argv[0], "file:", 1))
+ if (locatestring(argv[0], "http:", MATCH_AT_FIRST) ||
+ locatestring(argv[0], "ftp:", MATCH_AT_FIRST) ||
+ locatestring(argv[0], "news:", MATCH_AT_FIRST) ||
+ locatestring(argv[0], "mail:", MATCH_AT_FIRST) ||
+ locatestring(argv[0], "file:", MATCH_AT_FIRST))
strcpy(URL, argv[0]);
else {
char *abspath;
- char pathbuf[MAXPATHLEN+1];
- char htmlpath[MAXPATHLEN+1];
+ char buf[MAXPATHLEN+1];
- if (!test("f", argv[0]) && !test("d", argv[0]))
+ if (!test("f", argv[0]) && !test("d", NULL))
die1("path '%s' not found.", argv[0]);
- if (!(abspath = realpath(argv[0], pathbuf)))
+ if (!(abspath = realpath(argv[0], buf)))
die1("cannot make absolute path name. realpath(%s) failed.", argv[0]);
if (*abspath != '/')
die("realpath(3) is not compatible with BSD version.");
@@ -152,7 +158,7 @@ char *argv[];
/*
* execute generic browser.
*/
- if (browser && !locatestring(browser, "netscape", 3)) {
+ if (browser && !locatestring(browser, "netscape", MATCH_AT_LAST)) {
sprintf(com, "%s '%s'", browser, URL);
system(com);
exit (0);
@@ -171,7 +177,7 @@ char *argv[];
if ((pid = fork()) < 0) {
die("cannot execute netscape (fork).");
} else if (pid == 0) {
- execlp("netscape", "netscape", URL, (char *)0);
+ execlp("netscape", "netscape", URL, NULL);
die("loading mozilla failed.");
}
exit(0);
@@ -179,6 +185,34 @@ char *argv[];
exit(status);
}
int
+issource(path)
+char *path;
+{
+ STRBUF *sb = stropen();
+ char *p;
+ char suff[MAXPATHLEN+1];
+ int retval = 0;
+
+ if (!getconfs("suffixes", sb)) {
+ strclose(sb);
+ return 0;
+ }
+ suff[0] = '.';
+ for (p = strvalue(sb); p; ) {
+ char *unit = p;
+ if ((p = locatestring(p, ",", MATCH_FIRST)) != NULL)
+ *p++ = 0;
+ strcpy(&suff[1], unit);
+ if (locatestring(path, suff, MATCH_AT_LAST)) {
+ retval = 1;
+ break;
+ }
+ }
+ strclose(sb);
+ return retval;
+
+}
+int
sendcommand(com)
char *com;
{
@@ -188,7 +222,7 @@ char *com;
argv[0] = "netscape-remote";
argv[1] = "-remote";
argv[2] = com;
- argv[3] = (char *)0;
+ argv[3] = NULL;
return netscape_remote(argc, argv);
}