Commits

Trammell Hudson committed aabbb24

Add --debug option

  • Participants
  • Parent commits 3ff32fc

Comments (0)

Files changed (1)

 #define BITMAP_HEADER_NBYTES (54)
 
 /** Default for debug mode. */
-#define DEBUG (1)
+#define DEBUG (0)
 
 /** Basename for files generated by the program. */
 #define FILE_BASENAME "epilog"
 static int height = BED_HEIGHT;
 
 /** Job name for the print. */
-static char *job_name = NULL;
+static const char *job_name = NULL;
 
 /** User name that submitted the print job. */
-static char *job_user = NULL;
+static const char *job_user = NULL;
 
 /** Title for the job print. */
-static char *job_title = NULL;
+static const char *job_title = NULL;
 
 /** Variable to track the resolution of the print. */
 static int resolution = RESOLUTION_DEFAULT;
  * information.
  * @param bmp_mode a string which is one of bmp16m, bmpgray, or bmpmono.
  * @param resolution the encapsulated postscript resolution.
- * @param height the postscript height in points per inch.
- * @param width the postscript width in points per inch.
  *
  * @return Return true if the execution of ghostscript succeeds, false
  * otherwise.
 	int resolution
 )
 {
-    char buf[8192];
-    sprintf(buf,
-            "/usr/local/bin/gs -q -dBATCH -dNOPAUSE -r%d -sDEVICE=%s \
--sOutputFile=%s %s > %s",
-            resolution,
-            bmp_mode,
-            filename_bitmap,
-            filename_eps,
-            filename_vector);
+	char buf[8192];
+	snprintf(buf, sizeof(buf),
+		"/usr/local/bin/gs"
+			" -q"
+			" -dBATCH"
+			" -dNOPAUSE"
+			" -r%d"
+			" -sDEVICE=%s"
+			" -sOutputFile=%s"
+			" %s"
+			" > %s"
+			"",
+		resolution,
+		bmp_mode,
+		filename_bitmap,
+		filename_eps,
+		filename_vector
+	);
 
-    if (debug) {
-        fprintf(stderr, "%s\n", buf);
-    }
-    if (system(buf)) {
-        return false;
-    }
-    return true;
+	if (debug)
+		fprintf(stderr, "Executing: %s\n", buf);
+
+	if (system(buf))
+		return false;
+
+	return true;
 }
 
+
 /**
  *
  */
 }
 
 static const struct option long_options[] = {
+	{ "debug",		no_argument, NULL, 'D' },
 	{ "printer",		required_argument, NULL, 'p' },
 	{ "preset",		required_argument, NULL, 'P' },
 	{ "autofocus",		required_argument, NULL, 'a' },
 	// and it will be the input postcript / pdf
 	if (argc > 1)
 		usage(EXIT_FAILURE, "Only one input file may be specified\n");
+
 	const char * const filename = argc ? argv[0] : "stdin";
 
 	// If no job name is specified, use just the filename if there
 	// Report the settings on stdout
 	fprintf(stderr,
 		"Job: %s (%s)\n"
-		"Raster speed=%d power=%d dpi=%d\n"
-		"Vector speed=%d power=%d freq=%d\n"
+		"Raster: speed=%d power=%d dpi=%d\n"
+		"Vector: speed=%d power=%d freq=%d\n"
 		"",
 		job_title,
 		job_user,