prout

print out papers using libcups
git clone git://z3bra.org/prout
Log | Files | Refs | README | LICENSE

commit b4ca05b74cf6942aa9371d53917c872d2b8b6d8c
Author: Willy Goiffon <w.goiffon@gmail.com>
Date:   Tue Oct 15 09:23:38 2013

First commit: list available printers

Diffstat:
 .gitignore | 14 +++++++++++-
 LICENSE    | 14 +++++++++++-
 Makefile   | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/pp.c   | 36 +++++++++++++++++++++++++++-
 4 files changed, 148 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,14 @@ +############## +# Directories# + +# Binaries +bin/* + +# Objects +obj/*.o + +# Scripts +*.sh + +# ctag generated file +tags diff --git a/LICENSE b/LICENSE @@ -0,0 +1,14 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/Makefile b/Makefile @@ -0,0 +1,84 @@ +#irc.freenode.net# BEGINNING OF THE FILE + +# Compilation settings +PROG=pp +CC=gcc +CFLAGS+=-Wall -I inc -pedantic `cups-config --cflags` +LDFLAGS+=`cups-config --libs` + +# Command paths +RM=/bin/rm + +# Directories +SRCDIR=src +INCDIR=inc +OBJDIR=obj +BINDIR=bin +ETCDIR=etc +QOTDIR=dat +MANDIR=man + +PREFIX:=/usr +MANPREFIX:=$(PREFIX)/share/man + + +# Filetype paths +vpath %.c $(SRCDIR) +vpath %.h $(INCDIR) + +# Files +SRC:=$(wildcard $(SRCDIR)/*.c) +OBJ:=$(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(SRC)) +INC:=$(wildcard $(INCDIR)/*.h) +QOT:=$(wildcard $(QOTDIR)/*.qot) +ETC:=$(ETCDIR)/$(PROG).conf +BIN:=$(BINDIR)/$(PROG) + +.PHONY : all echo mrproper clean init install uninstall + +$(BIN) : $(OBJ) + @if [[ ! -d $(BINDIR) ]]; then mkdir $(BINDIR); fi + @echo -e "LD $(PROG)" + @$(CC) $^ -o $@ $(LDFLAGS) + +$(OBJDIR)/%.o : $(SRCDIR)/%.c + @if [[ ! -d $(OBJDIR) ]]; then mkdir $(OBJDIR); fi + @echo -e "CC $<" + @$(CC) -c $(CFLAGS) $< -o $@ + +all : init $(BIN) $(INC) + +list : + @echo "SOURCES : $(SRC)" + @echo "OBJECTS : $(OBJ)" + @echo "INCLUDE : $(INC)" + @echo "BINARY : $(BIN)" + +mrproper : clean + $(RM) $(BIN) + +clean : + $(RM) -f $(OBJDIR)/*.o + $(RM) -f *~ + +init : + @echo "CC = $(CC)" + @echo "CFLAGS = $(CFLAGS)" + @echo "LDFLAGS = $(LDFLAGS)" + @echo + +install: $(BIN) + install -d $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/share/$(PROG) $(DESTDIR)/etc/ $(DESTDIR)$(MANPREFIX)/man1 $(DESTDIR)$(MANPREFIX)/man5 + install -m 755 bin/$(PROG) $(DESTDIR)$(PREFIX)/bin/$(PROG) + install -m 644 $(ETC) $(DESTDIR)/etc/$(PROG).conf + install -m 644 -t $(DESTDIR)$(PREFIX)/share/$(PROG) $(QOT) + install -m 644 $(MANDIR)/$(PROG).1.gz $(DESTDIR)$(MANPREFIX)/man1/$(PROG).1.gz + install -m 644 $(MANDIR)/$(PROG).conf.5.gz $(DESTDIR)$(MANPREFIX)/man5/$(PROG).conf.5.gz + +uninstall: + $(RM) $(DESTDIR)$(PREFIX)/bin/$(PROG) + $(RM) $(DESTDIR)/etc/$(PROG) + $(RM) -r $(DESTDIR)$(PREFIX)/share/$(PROG) + $(RM) $(DESTDIR)$(MANPREFIX)/man1/$(PROG).1.gz + $(RM) $(DESTDIR)$(MANPREFIX)/man1/$(PROG).conf.5.gz +## EOF diff --git a/src/pp.c b/src/pp.c @@ -0,0 +1,36 @@ +/* + * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + * Version 2, December 2004 + * + * Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> + * + * Everyone is permitted to copy and distribute verbatim or modified + * copies of this license document, and changing it is allowed as long + * as the name is changed. + * + * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + * TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + * + * 0. You just DO WHAT THE FUCK YOU WANT TO. + * + */ + +#include <stdio.h> +#include <cups/cups.h> + +int main(int argc, char **argv) +{ + int i; + cups_dest_t *dests, *dest; + int num_dests = cupsGetDests(&dests); + + for (i = num_dests, dest = dests; i > 0; i --, dest ++) + { + if (dest->instance) + printf("%s/%s\n", dest->name, dest->instance); + else + puts(dest->name); + } + + return (0); +}