[hackers] [PATCH] Fix spelling of otherwise in surf.1
Add more spelling to surf. --- surf.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surf.1 b/surf.1 index 867783d..c1d339a 100644 --- a/surf.1 +++ b/surf.1 @@ -225,7 +225,7 @@ page. Toggle fullscreen mode. .SH INDICATORS OF OPERATION Surf is showing indicators of operation in front of the site title. -For all indicators, unless otherwsie specified, a lower case letter means disabled and an upper case letter means enabled. +For all indicators, unless otherwise specified, a lower case letter means disabled and an upper case letter means enabled. .TP .B A all cookies accepted -- 1.9.1
[hackers] [farbfeld] fix segfault on JPG error || FRIGN
commit dbfeeacb8c678974f89eb1fd09a7ef6a6076c8fb Author: FRIGNAuthorDate: Tue Dec 8 16:57:22 2015 +0100 Commit: FRIGN CommitDate: Tue Dec 8 16:57:22 2015 +0100 fix segfault on JPG error thanks Quentin Rameau! diff --git a/jpg2ff.c b/jpg2ff.c index f7ac5fc..52b4928 100644 --- a/jpg2ff.c +++ b/jpg2ff.c @@ -37,7 +37,7 @@ main(int argc, char *argv[]) struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; uint32_t width, height, val_be; - uint16_t *ff_row; + uint16_t *ff_row = NULL; size_t jpeg_row_len, ff_row_len, i, dx, sx; int ret = 1; JSAMPARRAY buffer; /* output row buffer */
Re: [hackers] [farbfeld] jpg2ff: fix segfault on JPG error
On Tue, 8 Dec 2015 11:28:17 +0100 Quentin Rameauwrote: > We would try to free unitialized ff_row pointer in cleanup on jpeg > errors. thanks, applied! :) -- FRIGN
Re: [hackers] sj: [PATCH] search path for executables
Sorry, this is not for sj. I use it for sj, but it is actually for https://github.com/younix/ucspi. On 12/08/2015 12:35 PM, Greg Reagle wrote: Without this patch, when I use the command tcpclient "$SJ_SERVER" 5223 tlsc ucspi-tee sj I have to use a full path for ucspi-tee and sj. In other words, the above command, as it is typed above, fails. With this patch, it automatically searches my $PATH, so the above command succeeds.
[hackers] [surf] Fix spelling of otherwise in surf.1 || Michael Stevens
commit 002e82d188d286f27ba5806939d51ed9df5857ef Author: Michael StevensAuthorDate: Tue Dec 8 11:12:14 2015 + Commit: Christoph Lohmann <2...@r-36.net> CommitDate: Tue Dec 8 18:26:30 2015 +0100 Fix spelling of otherwise in surf.1 Add more spelling to surf. Signed-off-by: Christoph Lohmann <2...@r-36.net> diff --git a/surf.1 b/surf.1 index 867783d..c1d339a 100644 --- a/surf.1 +++ b/surf.1 @@ -225,7 +225,7 @@ page. Toggle fullscreen mode. .SH INDICATORS OF OPERATION Surf is showing indicators of operation in front of the site title. -For all indicators, unless otherwsie specified, a lower case letter means disabled and an upper case letter means enabled. +For all indicators, unless otherwise specified, a lower case letter means disabled and an upper case letter means enabled. .TP .B A all cookies accepted
[hackers] sj: [PATCH] search path for executables
Without this patch, when I use the command tcpclient "$SJ_SERVER" 5223 tlsc ucspi-tee sj I have to use a full path for ucspi-tee and sj. In other words, the above command, as it is typed above, fails. With this patch, it automatically searches my $PATH, so the above command succeeds. >From e85a6da16ed3270794784abd26f0ce4d6263f3cf Mon Sep 17 00:00:00 2001 From: Greg ReagleDate: Tue, 8 Dec 2015 12:30:59 -0500 Subject: [PATCH] search path for executables --- tlsc.c | 4 ++-- ucspi-tee.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tlsc.c b/tlsc.c index be22e10..8be63cd 100644 --- a/tlsc.c +++ b/tlsc.c @@ -212,8 +212,8 @@ main(int argc, char *argv[], char *envp[]) if (close(pi[PIPE_WRITE]) < 0) err(EXIT_FAILURE, "close"); if (close(po_read) < 0) err(EXIT_FAILURE, "close"); - execve(prog, argv, environ); - err(EXIT_FAILURE, "execve"); + execvpe(prog, argv, environ); + err(EXIT_FAILURE, "execvpe"); default: break; /* parent */ } diff --git a/ucspi-tee.c b/ucspi-tee.c index 34905ee..62d4d28 100644 --- a/ucspi-tee.c +++ b/ucspi-tee.c @@ -112,8 +112,8 @@ main(int argc, char *argv[], char *envp[]) if (close(pi[PIPE_WRITE]) < 0) goto err; if (close(po_read) < 0) goto err; - execve(prog, argv, environ); - err(EXIT_FAILURE, "execve()"); + execvpe(prog, argv, environ); + err(EXIT_FAILURE, "execvpe()"); default: break; } -- 1.9.1
[hackers] [scc] Simplify escape() || Roberto E. Vargas Caballero
commit 6d01242876fda6bd9861414b477196e6f25bc8d8 Author: Roberto E. Vargas CaballeroAuthorDate: Tue Dec 8 19:02:56 2015 +0100 Commit: Roberto E. Vargas Caballero CommitDate: Tue Dec 8 19:02:56 2015 +0100 Simplify escape() Why assign and return instead of returning directly?. This patch also fixes an error in case '\'', where escape() was returning '\\' instead of '\''. diff --git a/cc1/lex.c b/cc1/lex.c index 2bcdb98..32d6246 100644 --- a/cc1/lex.c +++ b/cc1/lex.c @@ -395,19 +395,19 @@ number(void) static char escape(void) { - int c, base; + int n, base; switch (*++input->p) { - case '\\': c = '\\'; return c; - case 'a': c = '\a'; return c; - case 'f': c = '\f'; return c; - case 'n': c = '\n'; return c; - case 'r': c = '\r'; return c; - case 't': c = '\t'; return c; - case 'v': c = '\v'; return c; - case '\'': c = '\\'; return c; - case '"': c = '"'; return c; - case '?': c = '?'; return c; + case 'a': return '\a'; + case 'f': return '\f'; + case 'n': return '\n'; + case 'r': return '\r'; + case 't': return '\t'; + case 'v': return '\v'; + case '"': return '"'; + case '\'': return '\''; + case '\\': return '\\'; + case '\?': return '\?'; case 'u': /* * FIXME: universal constants are not correctly handled
Re: [hackers] [dmenu][RFC][PATCH] History functionality
Heyhey On Thu, Dec 03, 2015 at 02:57:52AM -0800, Xarchus wrote: > [...] > > - improved the history/cache parsing/de-duplication awk one-liner in > dmenu_path; the former 'NR==FNR' test was not enough: in case of a not > supplied or empty history file it attempted to remove a count followed by a > tab from the file names in the cache. Obviously to find such an occurrence > would be crazy rare, so it was quite harmless (I suppose that you don't > have any executables in your path of the form "count\tname", do you ? > Anyway, now you can :) ) > > New patch attached. I have tested it briefly and it works for me. I would remove all the checks as done in the attached version of the patch. If you are happy with this version we should put it on the website. The question is whether we should replace the current version that does not apply to tip or just add it as an alternate history patch. Cheers, Silvan diff --git a/dmenu_path b/dmenu_path old mode 100644 new mode 100755 index 338bac4..c928173 --- a/dmenu_path +++ b/dmenu_path @@ -1,4 +1,6 @@ #!/bin/sh +HISTORY="$1" + cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"} if [ -d "$cachedir" ]; then cache=$cachedir/dmenu_run @@ -7,7 +9,6 @@ else fi IFS=: if stest -dqr -n "$cache" $PATH; then - stest -flx $PATH | sort -u | tee "$cache" -else - cat "$cache" + stest -flx $PATH | sort -u > "$cache" fi +awk '!cache { sub("^[0-9]+\t","") } !x[$0]++' "$HISTORY" cache=1 "$cache" diff --git a/dmenu_run b/dmenu_run index 834ede5..cfb8323 100755 --- a/dmenu_run +++ b/dmenu_run @@ -1,2 +1,32 @@ #!/bin/sh -dmenu_path | dmenu "$@" | ${SHELL:-"/bin/sh"} & + +historyfile=~/.cache/dmenu/history + +dmenu_path $historyfile | dmenu "$@" \ + | awk -v histfile=$historyfile ' + BEGIN { + FS=OFS="\t" + if(histfile) { +while ( (getline < histfile) > 0 ) { + count=$1 + sub("^[0-9]+\t","") + fname=$0 + history[fname]=count +} +close(histfile) + } + } + + { + history[$0]++ + print + } + + END { + if(!histfile) +exit + for (f in history) +print history[f],f | "sort -t '\t' -k1rn >" histfile + } + ' \ + | while read cmd; do ${SHELL:-"/bin/sh"} -c "$cmd" & done
[hackers] [sent] Support farbfeld as an intermediate format || sin
commit b516f468faa3a80c31932cbcb1ea8ccd1468ffc1 Author: sinAuthorDate: Wed Nov 18 10:41:02 2015 + Commit: Markus Teich CommitDate: Tue Dec 8 20:01:36 2015 +0100 Support farbfeld as an intermediate format Sent now uses farbfeld[0] as an intermediate format. A series of filters is specified in config.h that matches file extensions to filter programs. The programs will convert between formats such as png to farbfeld. Internally in sent we do not need to worry on how to parse png or any other format. This also works with jpg and gif and others. The 2ff wrapper will use imagemagick conversion tools. This is temporary as jpg2ff and gif2ff will also be implemented. To make this work, you will have to clone[0] and put png2ff and 2ff in your PATH. [0] http://git.2f30.org/farbfeld/ diff --git a/LICENSE b/LICENSE index d1da8fc..8d5665e 100644 --- a/LICENSE +++ b/LICENSE @@ -2,8 +2,6 @@ The MIT License (MIT) Copyright (c) 2014-2015 Markus Teich -png handling stuff adapted from meh by John Hawthorn - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights diff --git a/README.md b/README.md index 007564b..e213efb 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,6 @@ presentation file could look like this: depends on - Xlib - - libpng sent FILENAME one slide per paragraph diff --git a/config.def.h b/config.def.h index 2dae620..94ed09e 100644 --- a/config.def.h +++ b/config.def.h @@ -45,3 +45,8 @@ static Shortcut shortcuts[] = { { XK_n, advance,{.i = +1} }, { XK_p, advance,{.i = -1} }, }; + +static Filter filters[] = { + { "\\.png$", "png2ff" }, + { "\\.(jpg|gif)$", "2ff" }, +}; diff --git a/config.mk b/config.mk index ed08199..52d5fb1 100644 --- a/config.mk +++ b/config.mk @@ -12,7 +12,7 @@ X11LIB = /usr/X11R6/lib # includes and libs INCS = -I. -I/usr/include -I/usr/include/freetype2 -I${X11INC} -LIBS = -L/usr/lib -lc -lm -L${X11LIB} -lXft -lfontconfig -lX11 -lpng +LIBS = -L/usr/lib -lc -lm -L${X11LIB} -lXft -lfontconfig -lX11 # flags CPPFLAGS = -DVERSION=\"${VERSION}\" -D_XOPEN_SOURCE=600 diff --git a/example b/example index 39e0206..d4b62d2 100644 --- a/example +++ b/example @@ -20,7 +20,6 @@ easy to use depends on ⽠Xlib -⢠libpng ~1000 lines of code diff --git a/sent.c b/sent.c index e717a69..eb3aadc 100644 --- a/sent.c +++ b/sent.c @@ -1,12 +1,17 @@ /* See LICENSE for licence details. */ +#include +#include + #include +#include #include -#include +#include #include #include #include #include #include +#include #include #include #include @@ -36,13 +41,16 @@ typedef struct { unsigned int bufwidth, bufheight; imgstate state; XImage *ximg; - FILE *f; - png_structp png_ptr; - png_infop info_ptr; + int fd; int numpasses; } Image; typedef struct { + char *regex; + char *bin; +} Filter; + +typedef struct { unsigned int linecount; char **lines; Image *img; @@ -79,12 +87,12 @@ typedef struct { const Arg arg; } Shortcut; -static Image *pngopen(char *filename); -static void pngfree(Image *img); -static int pngread(Image *img); -static int pngprepare(Image *img); -static void pngscale(Image *img); -static void pngdraw(Image *img); +static Image *ffopen(char *filename); +static void fffree(Image *img); +static int ffread(Image *img); +static int ffprepare(Image *img); +static void ffscale(Image *img); +static void ffdraw(Image *img); static void getfontsize(Slide *s, unsigned int *width, unsigned int *height); static void cleanup(); @@ -128,56 +136,87 @@ static void (*handler[LASTEvent])(XEvent *) = { [KeyPress] = kpress, }; -Image *pngopen(char *filename) +int +filter(int fd, const char *cmd) +{ + int fds[2]; + + if (pipe(fds) < 0) + eprintf("pipe:"); + + switch (fork()) { + case -1: + eprintf("fork:"); + case 0: + dup2(fd, 0); + dup2(fds[1], 1); + close(fds[0]); + close(fds[1]); + execlp(cmd, cmd, (char *)0); + eprintf("execlp %s:", cmd); + } + close(fds[1]); + return fds[0]; +} + +Image *ffopen(char *filename) { - FILE *f; - unsigned char buf[8]; + unsigned char hdr[16]; + char *bin; + regex_t regex; Image *img; + size_t i; + int tmpfd, fd; + + for (bin = NULL, i = 0; i < LEN(filters); i++) { + if (regcomp(, filters[i].regex, + REG_NOSUB | REG_EXTENDED | REG_ICASE)) +
[hackers] [sent] minor syntax, style and README fixes || Markus Teich
commit 24762d01720aaee44334249fa70498a0536ff89e Author: Markus TeichAuthorDate: Tue Dec 8 22:09:26 2015 +0100 Commit: Markus Teich CommitDate: Tue Dec 8 22:09:26 2015 +0100 minor syntax, style and README fixes diff --git a/README.md b/README.md index e213efb..3fda5ee 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,19 @@ sent is a simple plaintext presentation tool. sent does not need latex, libreoffice or any other fancy file format, it uses -plaintext files and png images. Every paragraph represents a slide in the -presentation. +plaintext files to describe the slides and can include images via farbfeld. +Every paragraph represents a slide in the presentation. The presentation is displayed in a simple X11 window. The content of each slide is automatically scaled to fit the window and centered so you also don't have to worry about alignment. Instead you can really concentrate on the content. +Dependencies + +You need Xlib to build sent and the farbfeld[0] tools installed to use images in +your presentations. + Demo To get a little demo, just type @@ -47,3 +52,6 @@ presentation file could look like this: Development sent is developed at http://tools.suckless.org/sent + + +0: http://git.2f30.org/farbfeld/about/ diff --git a/example b/example index d4b62d2..8b385f0 100644 --- a/example +++ b/example @@ -20,6 +20,7 @@ easy to use depends on â½ Xlib +â farbfeld ~1000 lines of code diff --git a/sent.c b/sent.c index e10e8ca..5f3cb59 100644 --- a/sent.c +++ b/sent.c @@ -186,7 +186,7 @@ Image *ffopen(char *filename) tmpfd = fd; fd = filter(fd, bin); if (fd < 0) - eprintf("could not filter %s:", filename); + eprintf("Unable to filter %s:", filename); close(tmpfd); if (read(fd, hdr, 16) != 16) @@ -218,7 +218,7 @@ int ffread(Image *img) uint8_t opac; uint8_t fg_r, fg_g, fg_b, bg_r, bg_g, bg_b; size_t rowlen, off, nbytes; - ssize_t r; + ssize_t count; if (!img) return 0; @@ -249,10 +249,10 @@ int ffread(Image *img) for (off = 0, y = 0; y < img->bufheight; y++) { nbytes = 0; while (nbytes < rowlen) { - r = read(img->fd, (char *)row + nbytes, rowlen - nbytes); - if (r < 0) - eprintf("read:"); - nbytes += r; + count = read(img->fd, (char *)row + nbytes, rowlen - nbytes); + if (count < 0) + eprintf("Unable to read from pipe:"); + nbytes += count; } for (x = 0; x < rowlen / 2; x += 4) { fg_r = ntohs(row[x + 0]) / 256; @@ -346,7 +346,7 @@ void ffdraw(Image *img) int xoffset = (xw.w - img->ximg->width) / 2; int yoffset = (xw.h - img->ximg->height) / 2; XPutImage(xw.dpy, xw.win, d->gc, img->ximg, 0, 0, - xoffset, yoffset, img->ximg->width, img->ximg->height); + xoffset, yoffset, img->ximg->width, img->ximg->height); XFlush(xw.dpy); img->state |= DRAWN; } @@ -604,12 +604,13 @@ void xinit() resize(DisplayWidth(xw.dpy, xw.scr), DisplayHeight(xw.dpy, xw.scr)); xw.attrs.bit_gravity = CenterGravity; - xw.attrs.event_mask = KeyPressMask | ExposureMask | StructureNotifyMask - | ButtonMotionMask | ButtonPressMask; + xw.attrs.event_mask = KeyPressMask | ExposureMask | StructureNotifyMask | + ButtonMotionMask | ButtonPressMask; xw.win = XCreateWindow(xw.dpy, XRootWindow(xw.dpy, xw.scr), 0, 0, - xw.w, xw.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput, xw.vis, - CWBitGravity | CWEventMask, ); + xw.w, xw.h, 0, XDefaultDepth(xw.dpy, xw.scr), + InputOutput, xw.vis, CWBitGravity | CWEventMask, + ); xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False); xw.netwmname = XInternAtom(xw.dpy, "_NET_WM_NAME", False);
[hackers] [sent] support transparent images || Markus Teich
commit 0798e82d2326fc330168733997006020cc59e215 Author: Markus TeichAuthorDate: Tue Dec 8 21:46:18 2015 +0100 Commit: Markus Teich CommitDate: Tue Dec 8 21:46:18 2015 +0100 support transparent images diff --git a/sent.c b/sent.c index eb3aadc..e10e8ca 100644 --- a/sent.c +++ b/sent.c @@ -215,6 +215,8 @@ int ffread(Image *img) { uint32_t y, x; uint16_t *row; + uint8_t opac; + uint8_t fg_r, fg_g, fg_b, bg_r, bg_g, bg_b; size_t rowlen, off, nbytes; ssize_t r; @@ -239,6 +241,11 @@ int ffread(Image *img) return 0; } + /* extract window background color channels for transparency */ + bg_r = (sc->bg.pix >> 16) % 256; + bg_g = (sc->bg.pix >> 8) % 256; + bg_b = (sc->bg.pix >> 0) % 256; + for (off = 0, y = 0; y < img->bufheight; y++) { nbytes = 0; while (nbytes < rowlen) { @@ -248,9 +255,15 @@ int ffread(Image *img) nbytes += r; } for (x = 0; x < rowlen / 2; x += 4) { - img->buf[off++] = ntohs(row[x + 0]) / 257; - img->buf[off++] = ntohs(row[x + 1]) / 257; - img->buf[off++] = ntohs(row[x + 2]) / 257; + fg_r = ntohs(row[x + 0]) / 256; + fg_g = ntohs(row[x + 1]) / 256; + fg_b = ntohs(row[x + 2]) / 256; + opac = ntohs(row[x + 3]) / 256; + /* blend opaque part of image data with window background color to +* emulate transparency */ + img->buf[off++] = (fg_r * opac + bg_r * (255 - opac)) / 256; + img->buf[off++] = (fg_g * opac + bg_g * (255 - opac)) / 256; + img->buf[off++] = (fg_b * opac + bg_b * (255 - opac)) / 256; } }
Re: [hackers] [sent] check for bin == NULL || Markus Teich
On Tue, Dec 08, 2015 at 10:32:36PM +0100, g...@suckless.org wrote: > commit edb46305647d909199a860b6b0812595742f6fe4 > Author: Markus Teich> AuthorDate: Tue Dec 8 22:34:48 2015 +0100 > Commit: Markus Teich > CommitDate: Tue Dec 8 22:34:48 2015 +0100 > > check for bin == NULL > > diff --git a/sent.c b/sent.c > index 5f3cb59..5c72597 100644 > --- a/sent.c > +++ b/sent.c > @@ -173,7 +173,8 @@ Image *ffopen(char *filename) > REG_NOSUB | REG_EXTENDED | REG_ICASE)) > continue; > if (!regexec(, filename, 0, NULL, 0)) { > - bin = filters[i].bin; > + if (!(bin = filters[i].bin)) > + return NULL; > break; > } > } Hm yes, i actually meant to initialize bin to NULL and then check it outside of the loop in case no regex matched. This patch you applied fixes a different issue.
[hackers] [sent] fix 2 uninitialized variables and bin == NULL check || Markus Teich
commit 008ff1b88b3e9cdd13e82d0ec4fb573c977f6a3d Author: Markus TeichAuthorDate: Wed Dec 9 00:50:05 2015 +0100 Commit: Markus Teich CommitDate: Wed Dec 9 00:50:05 2015 +0100 fix 2 uninitialized variables and bin == NULL check diff --git a/drw.c b/drw.c index 15797ce..be30400 100644 --- a/drw.c +++ b/drw.c @@ -228,7 +228,7 @@ int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert) { char buf[1024]; int tx, ty, th; - unsigned int ew; + unsigned int ew = 0; Colormap cmap; Visual *vis; XftDraw *d; diff --git a/sent.c b/sent.c index 5c72597..51f6eed 100644 --- a/sent.c +++ b/sent.c @@ -162,23 +162,25 @@ filter(int fd, const char *cmd) Image *ffopen(char *filename) { unsigned char hdr[16]; - char *bin; + char *bin = NULL; regex_t regex; Image *img; size_t i; int tmpfd, fd; - for (bin = NULL, i = 0; i < LEN(filters); i++) { + for (i = 0; i < LEN(filters); i++) { if (regcomp(, filters[i].regex, REG_NOSUB | REG_EXTENDED | REG_ICASE)) continue; if (!regexec(, filename, 0, NULL, 0)) { - if (!(bin = filters[i].bin)) - return NULL; + bin = filters[i].bin break; } } + if (!bin) + return NULL; + if ((fd = open(filename, O_RDONLY)) < 0) { eprintf("Unable to open file %s:", filename); return NULL; @@ -355,7 +357,7 @@ void ffdraw(Image *img) void getfontsize(Slide *s, unsigned int *width, unsigned int *height) { int i, j; - unsigned int curw, imax; + unsigned int curw, new_max; float lfac = linespacing * (s->linecount - 1) + 1; /* fit height */ @@ -369,13 +371,12 @@ void getfontsize(Slide *s, unsigned int *width, unsigned int *height) *width = 0; for (i = 0; i < s->linecount; i++) { curw = drw_fontset_getwidth(d, s->lines[i]); - if (curw >= *width) - imax = i; + newmax = (curw >= *width); while (j > 0 && curw > xw.uw) { drw_setfontset(d, fonts[--j]); curw = drw_fontset_getwidth(d, s->lines[i]); } - if (imax == i) + if (newmax) *width = curw; } *height = fonts[j]->h * lfac;
Re: [hackers] [PATCH] [sent] Quick patch to replace png with farbfeld
On Tue, Dec 08, 2015 at 10:31:31PM +0100, Markus Teich wrote: > FRIGN wrote: > > Dimitris Papastamoswrote: > > > This also works with jpg and gif and others. The 2ff wrapper will use > > > imagemagick conversion tools. This is temporary as jpg2ff and gif2ff will > > > also be implemented. > > > > As a side note, the 2ff-filter can also receive png-images and already > > automatically call png2ff when it detects a png. If you look at the 2ff > > script, you'll notice how simple it is really. > > Heyho, > > as you guys can see from the push hook mails, I just merged the second > farbfeld > patch from Dimitris. Since case-switching in sent (the filters array) and in > 2ff > again seems kind of redundant, I would remove the filter array and regex code > again and just call filter() on the 2ff script. Of course this only works, if > 2ff does not go „full pipeline“ and continues to support handling one > argument. I would be inclined to keep regex matching. 2ff is a helper. One can imagine piping gnuplot files to generate graphs. > Another change I want to make is combining the open and read function. Then we > would know if every image could be loaded correctly before even starting the > presentation, which prevents erroring out right in the middle of your talk, > when > some image could not be loaded from advance(). Yes makes sense.
[hackers] [sent] unbreak the build || Markus Teich
commit 11f2c648eb1849976fddf57af8b66fcc43d425dc Author: Markus TeichAuthorDate: Wed Dec 9 00:52:39 2015 +0100 Commit: Markus Teich CommitDate: Wed Dec 9 00:52:39 2015 +0100 unbreak the build diff --git a/sent.c b/sent.c index 51f6eed..fc5e389 100644 --- a/sent.c +++ b/sent.c @@ -173,7 +173,7 @@ Image *ffopen(char *filename) REG_NOSUB | REG_EXTENDED | REG_ICASE)) continue; if (!regexec(, filename, 0, NULL, 0)) { - bin = filters[i].bin + bin = filters[i].bin; break; } } @@ -357,7 +357,7 @@ void ffdraw(Image *img) void getfontsize(Slide *s, unsigned int *width, unsigned int *height) { int i, j; - unsigned int curw, new_max; + unsigned int curw, newmax; float lfac = linespacing * (s->linecount - 1) + 1; /* fit height */
Re: [hackers] sj: Properly receive and respond to presence notices
sj definitely rocks. Now I can use the following shell script to see which of my buddies are online, and to keep it constantly updated call it from watch: #!/bin/sh cd "$SJ_DIR" if pgrep presenced > /dev/null; then egrep '.+' `find . -name status` | sed 's|\./||g' | sed 's|:|: |g' else echo 'Presence daemon not running' fi On Tue, Dec 08, 2015 at 07:46:02PM -0500, Greg Reagle wrote: > Patch attached. > > -- > "No data yet," he answered. "It is a capital mistake to theorize > before you have all the evidence. It biases the judgement." > by Arthur Conan Doyle via his character Sherlock Holmes > From feed0b1c94c49b6850b6504a9d9bc9ae2780dec8 Mon Sep 17 00:00:00 2001 > From: Greg Reagle> Date: Tue, 8 Dec 2015 19:38:33 -0500 > Subject: [PATCH] Properly receive and respond to presence notices. > > An empty (zero bytes) status file indicates offline. A non-empty (one or > more bytes) status file indicates online. Default online status text is > "online", unless overridden by a show element. > --- > presenced.c | 40 ++-- > 1 file changed, 22 insertions(+), 18 deletions(-) > > diff --git a/presenced.c b/presenced.c > index fed559b..bf42811 100644 > --- a/presenced.c > +++ b/presenced.c > @@ -213,13 +213,13 @@ recv_presence(char *tag, void *data) > /* HACK: we need this, cause mxml can't parse tags by itself */ > static mxml_node_t *tree = NULL; > static mxml_node_t *node = NULL; > - static mxml_node_t *status = NULL; > const char *base = ""; > const char *tag_name = NULL; > const char *from = NULL; > char *slash = NULL; > char path[PATH_MAX]; > int fd; > + int is_online = 0; > > if (tree == NULL) tree = mxmlLoadString(NULL, base, MXML_NO_CALLBACK); > if (tree == NULL) err(EXIT_FAILURE, "%s: no xml tree found", __func__); > @@ -234,6 +234,11 @@ recv_presence(char *tag, void *data) > if ((from = mxmlElementGetAttr(tree->child->next, "from")) == NULL) > goto err; > > + if (mxmlElementGetAttr(tree->child->next, "type")) > + is_online = 0; /* presense of 'type' attribute indicates > offline */ > + else > + is_online = 1; /* lack of 'type' attribute indicates online */ > + > /* cut off resourcepart from jabber ID */ > if ((slash = strchr(from, '/')) != NULL) > *slash = '\0'; > @@ -251,25 +256,24 @@ recv_presence(char *tag, void *data) > > snprintf(path, sizeof path, "%s/%s/status", ctx->dir, from); > > - status = mxmlFindElement(node, tree, "status", NULL, NULL, > - MXML_DESCEND_FIRST); > + if ((fd = open(path, O_WRONLY|O_TRUNC|O_CREAT, S_IRUSR|S_IWUSR)) > + == -1) > + goto err; > > - if (status != NULL) { > - if ((fd = open(path, O_WRONLY|O_TRUNC|O_CREAT, S_IRUSR|S_IWUSR)) > - == -1) > - goto err; > - /* write text of status-tag into this file */ > - /* concatinate all text peaces */ > - for (mxml_node_t *txt = status->child; txt != NULL; > - txt = mxmlGetNextSibling(txt)) { > - int space = 0; > - const char *t = mxmlGetText(txt, ); > - if (space == 1) > - write(fd, " ", 1); > - if (write(fd, t, strlen(t)) == -1) goto err; > - } > - if (close(fd) == -1) goto err; > + if (is_online) { > + mxml_node_t *show = NULL; > + const char *status; > + if (show = mxmlFindElement(node, tree, "show", NULL, NULL, > +MXML_DESCEND_FIRST)) > + status = mxmlGetText(show, NULL); > + else > + status = "online"; > + if (write(fd, status, strlen(status)) == -1) goto err; > + } else { > + ; /* write nothing; make fd an empty file */ > } > + if (close(fd) == -1) goto err; > + > err: > if (errno != 0) > perror(__func__); > -- > 2.1.4 >
Re: [hackers] [sent] Support farbfeld as an intermediate format || sin
> +Image *ffopen(char *filename) > { > - FILE *f; > - unsigned char buf[8]; > + unsigned char hdr[16]; > + char *bin; > + regex_t regex; > Image *img; > + size_t i; > + int tmpfd, fd; > + > + for (bin = NULL, i = 0; i < LEN(filters); i++) { > + if (regcomp(, filters[i].regex, > + REG_NOSUB | REG_EXTENDED | REG_ICASE)) > + continue; > + if (!regexec(, filename, 0, NULL, 0)) { > + bin = filters[i].bin; > + break; > + } > + } I forgot an if (!bin) return NULL sort of thing here.
Re: [hackers] [PATCH] [sent] Quick patch to replace png with farbfeld
FRIGN wrote: > Dimitris Papastamoswrote: > > This also works with jpg and gif and others. The 2ff wrapper will use > > imagemagick conversion tools. This is temporary as jpg2ff and gif2ff will > > also be implemented. > > As a side note, the 2ff-filter can also receive png-images and already > automatically call png2ff when it detects a png. If you look at the 2ff > script, you'll notice how simple it is really. Heyho, as you guys can see from the push hook mails, I just merged the second farbfeld patch from Dimitris. Since case-switching in sent (the filters array) and in 2ff again seems kind of redundant, I would remove the filter array and regex code again and just call filter() on the 2ff script. Of course this only works, if 2ff does not go „full pipeline“ and continues to support handling one argument. I also noticed you used `/ 257` to convert from uint16_t to uint8_t, which I fixed in the transparency patch to be `/ 256`. Another change I want to make is combining the open and read function. Then we would know if every image could be loaded correctly before even starting the presentation, which prevents erroring out right in the middle of your talk, when some image could not be loaded from advance(). I also pushed an update to sent/index.md in the wiki describing the new situation. --Markus
Re: [hackers] [sent] Support farbfeld as an intermediate format || sin
Dimitris Papastamos wrote: > > + for (bin = NULL, i = 0; i < LEN(filters); i++) { > > + if (regcomp(, filters[i].regex, > > + REG_NOSUB | REG_EXTENDED | REG_ICASE)) > > + continue; > > + if (!regexec(, filename, 0, NULL, 0)) { > > + bin = filters[i].bin; > > + break; > > + } > > + } > > I forgot an if (!bin) return NULL sort of thing here. Heyho Dimitris, thanks, fixed. --Markus
[hackers] [sent] check for bin == NULL || Markus Teich
commit edb46305647d909199a860b6b0812595742f6fe4 Author: Markus TeichAuthorDate: Tue Dec 8 22:34:48 2015 +0100 Commit: Markus Teich CommitDate: Tue Dec 8 22:34:48 2015 +0100 check for bin == NULL diff --git a/sent.c b/sent.c index 5f3cb59..5c72597 100644 --- a/sent.c +++ b/sent.c @@ -173,7 +173,8 @@ Image *ffopen(char *filename) REG_NOSUB | REG_EXTENDED | REG_ICASE)) continue; if (!regexec(, filename, 0, NULL, 0)) { - bin = filters[i].bin; + if (!(bin = filters[i].bin)) + return NULL; break; } }