sselp-0.2/0000755000175000017500000000000011043660103012013 5ustar anselmanselmsselp-0.2/sselp.c0000644000175000017500000000324511043660103013311 0ustar anselmanselm/* See LICENSE file for license details. */ #include #include #include #include #include #include static unsigned char * getsel(unsigned long offset, unsigned long *len, unsigned long *remain) { Display *dpy; Atom utf8_string; Atom xa_clip_string; Window w; XEvent ev; Atom typeret; int format; unsigned char *data; unsigned char *result = NULL; dpy = XOpenDisplay(NULL); if(!dpy) return NULL; utf8_string = XInternAtom(dpy, "UTF8_STRING", False); xa_clip_string = XInternAtom(dpy, "_SSELP_STRING", False); w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, 200, 200, 1, CopyFromParent, CopyFromParent); XConvertSelection(dpy, XA_PRIMARY, utf8_string, xa_clip_string, w, CurrentTime); XFlush(dpy); XNextEvent(dpy, &ev); if(ev.type == SelectionNotify && ev.xselection.property != None) { XGetWindowProperty(dpy, w, ev.xselection.property, offset, 4096L, False, AnyPropertyType, &typeret, &format, len, remain, &data); if(*len) { result = malloc(sizeof(unsigned char) * *len); memcpy(result, data, *len); } XDeleteProperty(dpy, w, ev.xselection.property); } XDestroyWindow(dpy, w); XCloseDisplay(dpy); return result; } int main(int argc, char **argv) { unsigned char *data; unsigned long i, offset, len, remain; if((argc > 1) && !strncmp(argv[1], "-v", 3)) { fputs("sselp-"VERSION", © 2006-2008 Anselm R Garbe\n", stdout); exit(EXIT_SUCCESS); } len = offset = remain = 0; do { data = getsel(offset, &len, &remain); for(i = 0; i < len; i++) putchar(data[i]); offset += len; free(data); } while(remain); if(offset) putchar('\n'); return 0; } sselp-0.2/LICENSE0000644000175000017500000000212211043660103013015 0ustar anselmanselmMIT/X Consortium License © 2006-2008 Anselm R Garbe 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 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. sselp-0.2/Makefile0000644000175000017500000000176711043660103013466 0ustar anselmanselm# sselp - simple print selection include config.mk SRC = sselp.c OBJ = ${SRC:.c=.o} all: options sselp options: @echo sselp build options: @echo "CFLAGS = ${CFLAGS}" @echo "LDFLAGS = ${LDFLAGS}" @echo "CC = ${CC}" .c.o: @echo CC $< @${CC} -c ${CFLAGS} $< ${OBJ}: config.mk sselp: ${OBJ} @echo CC -o $@ @${CC} -o $@ ${OBJ} ${LDFLAGS} clean: @echo cleaning @rm -f sselp ${OBJ} sselp-${VERSION}.tar.gz dist: clean @echo creating dist tarball @mkdir -p sselp-${VERSION} @cp -R LICENSE Makefile README config.mk ${SRC} sselp-${VERSION} @tar -cf sselp-${VERSION}.tar sselp-${VERSION} @gzip sselp-${VERSION}.tar @rm -rf sselp-${VERSION} install: all @echo installing executable file to ${DESTDIR}${PREFIX}/bin @mkdir -p ${DESTDIR}${PREFIX}/bin @cp -f sselp ${DESTDIR}${PREFIX}/bin @chmod 755 ${DESTDIR}${PREFIX}/bin/sselp uninstall: @echo removing executable file from ${DESTDIR}${PREFIX}/bin @rm -f ${DESTDIR}${PREFIX}/bin/sselp .PHONY: all options clean dist install uninstall sselp-0.2/README0000644000175000017500000000075611043660103012703 0ustar anselmanselmsselp - simple print selection ============================== Prints X selection to standard out. Requirements ------------ In order to build sselp you need the Xlib header files. Installation ------------ Edit config.mk to match your local setup (sselp is installed into the /usr/local namespace by default). Afterwards enter the following command to build and install sselp (if necessary as root): make clean install Running sselp ------------- Simply invoke the 'sselp' command. sselp-0.2/config.mk0000644000175000017500000000066411043660103013617 0ustar anselmanselm# sselp version VERSION = 0.2 # Customize below to fit your system # paths PREFIX = /usr/local MANPREFIX = ${PREFIX}/share/man X11INC = /usr/X11R6/include X11LIB = /usr/X11R6/lib # includes and libs INCS = -I. -I/usr/include -I${X11INC} LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 # flags CPPFLAGS = -DVERSION=\"${VERSION}\" CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} LDFLAGS = -s ${LIBS} # compiler and linker CC = cc