diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | freebsd/Makefile | 2 | ||||
-rw-r--r-- | linux/Makefile | 2 | ||||
-rw-r--r-- | marco.c | 36 | ||||
-rw-r--r-- | xxxterm.c | 34 |
5 files changed, 74 insertions, 2 deletions
diff --git a/Makefile b/Makefile index d480a1a..00f35eb 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ BINDIR=${PREFIX}/bin PROG=xxxterm MAN=xxxterm.1 -SRCS= xxxterm.c +SRCS= xxxterm.c marco.c COPT+= -O2 DEBUG= -ggdb3 LDADD= -lutil diff --git a/freebsd/Makefile b/freebsd/Makefile index 4515fd7..b59b46e 100644 --- a/freebsd/Makefile +++ b/freebsd/Makefile @@ -23,6 +23,8 @@ all: ../javascript.h xxxterm xxxterm.o: ../xxxterm.o +marco.o: ../marco.o + ../xxxterm.o: ../javascript.h xxxterm: xxxterm.o freebsd.o diff --git a/linux/Makefile b/linux/Makefile index d243713..ed0ccba 100644 --- a/linux/Makefile +++ b/linux/Makefile @@ -20,7 +20,7 @@ javascript.h: ../js-merge-helper.pl ../hinting.js xxxterm.o: javascript.h -xxxterm: ../xxxterm.o linux.o +xxxterm: ../marco.o ../xxxterm.o linux.o $(CC) $(LDFLAGS) -o $@ $+ $(LDADD) install: all diff --git a/marco.c b/marco.c new file mode 100644 index 0000000..a49ab1c --- /dev/null +++ b/marco.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2011 Todd T. Fries <todd@fries.net> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <stdlib.h> +#include <string.h> + +static const char *message[] = { + "I fully support your right to put restrictions on how I can modify" + " or distribute something you created. Calling these restrictions " + "\"liberty,\" however, is just Orwellian doublespeak", +}; + +const char * +marco_message(int *len) +{ + const char *str; + + str = message[arc4random_uniform(sizeof(message)/sizeof(message[0]))]; + *len = strlen(str); + + return str; +} + diff --git a/xxxterm.c b/xxxterm.c index aaf44ef..0918f56 100644 --- a/xxxterm.c +++ b/xxxterm.c @@ -655,6 +655,8 @@ int js_show_wl(struct tab *, struct karg *); int help(struct tab *, struct karg *); int set(struct tab *, struct karg *); int stats(struct tab *, struct karg *); +int marco(struct tab *, struct karg *); +const char * marco_message(int *); int xtp_page_cl(struct tab *, struct karg *); int xtp_page_dl(struct tab *, struct karg *); int xtp_page_fl(struct tab *, struct karg *); @@ -674,6 +676,7 @@ int xtp_page_hl(struct tab *, struct karg *); #define XT_URI_ABOUT_JSWL ("jswl") #define XT_URI_ABOUT_SET ("set") #define XT_URI_ABOUT_STATS ("stats") +#define XT_URI_ABOUT_MARCO ("marco") struct about_type { char *name; @@ -690,6 +693,7 @@ struct about_type { { XT_URI_ABOUT_JSWL, js_show_wl }, { XT_URI_ABOUT_SET, set }, { XT_URI_ABOUT_STATS, stats }, + { XT_URI_ABOUT_MARCO, marco }, }; /* globals */ @@ -2457,6 +2461,36 @@ stats(struct tab *t, struct karg *args) } int +marco(struct tab *t, struct karg *args) +{ + char *message, line[64 * 1024]; + int len; + + if (t == NULL) + show_oops_s("marco invalid parameters"); + + line[0] = '\0'; + snprintf(line, sizeof line, "<br>%s", marco_message(&len)); + + message = g_strdup_printf(XT_DOCTYPE + "<html>" + "<head>" + "<title>Marco Sez...</title>" + "</head>" + "<h1>Moo</h1>" + "<body>" + "%s" + "</body>" + "</html>", + line); + + load_webkit_string(t, message, XT_URI_ABOUT_MARCO); + g_free(message); + + return (0); +} + +int blank(struct tab *t, struct karg *args) { if (t == NULL) |