wip for today
author"Luc Saillard <luc@saillard.org>"
Wed May 21 00:49:59 2008 +0200 (7 months ago)
changeset 455cc82376967c
parent 44882f27821a93
child 463c34d8914e3a
wip for today
src/Makefile.am
src/foomatic-rip.c
--- a/src/Makefile.am Wed May 21 00:03:45 2008 +0200
+++ b/src/Makefile.am Wed May 21 00:49:59 2008 +0200
@@ -33,4 +33,6 @@ foomatic_rip_SOURVES=foomatic-rip.c util
foomatic_rip_SOURVES=foomatic-rip.c utils.c utils.h
foomatic_rip_CFLAGS=$(GLIB2_CFLAGS)
foomatic_rip_LDADD=$(GLIB2_LIBS)
+foomatic_rip_CPPFLAGS = \
+ -DLOCALEDIR=\"$(localedir)\"
--- a/src/foomatic-rip.c Wed May 21 00:03:45 2008 +0200
+++ b/src/foomatic-rip.c Wed May 21 00:49:59 2008 +0200
@@ -1,11 +1,141 @@
+/*
+ * 9lpr: a lpr alternative (no spooling, direct printing support)
+ * Copyright (C) 2006-2008 Luc Saillard <luc@saillard.org>
+ * 2006-2008 Neuf Cegetel
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "utils.h"
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+#include <stdlib.h>
+#include <stdio.h>
-int main(int argc, char **argv)
+#define SPOOLER_UNKNOWN 0
+#define SPOOLER_CUPS 1
+
+
+
+
+static int opt_debug;
+static int opt_print_version;
+static int opt_verbose;
+static int opt_spooler;
+static char *opt_ppdfile; /* Point to the PPD filename (must be free by g_free() is not NULL) */
+
+
+
+
+
+
+
+
+static int parse_options(int argc, char **argv);
+
+
+
+
+
+
+
+
+
+
+
+
+
+int
+main(int argc, char **argv)
{
+ setlocale(LC_ALL, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset(PACKAGE, "UTF-8");
+ textdomain(PACKAGE);
+ parse_options(argc, argv);
+
+ return 0;
}
+
+
+
+
+
+static GOptionEntry entries[] =
+{
+ { "debug", 0, 0, G_OPTION_ARG_NONE, &opt_debug, N_("Use debug mode"), NULL},
+ { "version", 'V', 0, G_OPTION_ARG_NONE, &opt_print_version, N_("Print version"), NULL},
+ { "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, N_("Be verbose"), NULL},
+ { NULL }
+};
+
+/*
+ * Parse environment and command line, and allocate any structure need to
+ * run the filter.
+ */
+static int
+parse_options(int argc, char **argv)
+{
+ const char *env_PPD;
+ GError *gerror = NULL;
+ GOptionContext *option_context;
+
+ /* Feature: Don't support any other spooler */
+ opt_spooler = SPOOLER_UNKNOWN;
+ env_PPD = getenv("PPD");
+ if (env_PPD)
+ {
+ opt_spooler = SPOOLER_CUPS;
+ opt_ppdfile = g_strdup(env_PPD);
+ }
+
+ /* Parse command line */
+
+
+ option_context = g_option_context_new(_("- Cups filter script"));
+ g_option_context_add_main_entries(option_context, entries, PACKAGE_NAME);
+ if (g_option_context_parse(option_context, &argc, &argv, &gerror) == FALSE)
+ {
+ printf("option parsing failed: %s\n", gerror->message);
+ exit(1);
+ }
+
+ if (opt_print_version)
+ {
+ printf("%s - Build %s\n", PACKAGE_VERSION, __DATE__);
+ exit(0);
+ }
+
+
+ return 0;
+}
+
+
+
+
+
+
+
+