Added the $HOME variable to be used in AFMPATH
[enscript.git] / src / main.c
index de6bc33..9001051 100644 (file)
@@ -331,6 +331,7 @@ unsigned int lines_per_page = (unsigned int) -1;
  * Send mail notification to user after print job has been completed.
  */
 int mail = 0;
+char *mailto;
 
 /*
  * -M, --media
@@ -805,6 +806,7 @@ EncodingRegistry encodings[] =
   {{"88597", "greek", NULL},           ENC_ISO_8859_7,         '\n', 8},
   {{"88599", "latin5", NULL},          ENC_ISO_8859_9,         '\n', 8},
   {{"885910", "latin6", NULL},         ENC_ISO_8859_10,        '\n', 8},
+  {{"885915", "latin9", NULL},         ENC_ISO_8859_15,        '\n', 8},
   {{"ascii", NULL, NULL},              ENC_ASCII,              '\n', 8},
   {{"asciifise", "asciifi", "asciise"},        ENC_ASCII_FISE,         '\n', 8},
   {{"asciidkno", "asciidk", "asciino"},        ENC_ASCII_DKNO,         '\n', 8},
@@ -850,7 +852,7 @@ static struct option long_options[] =
   {"no-page-prefeed",          no_argument,            0, 'K'},
   {"lineprinter",              no_argument,            0, 'l'},
   {"lines-per-page",           required_argument,      0, 'L'},
-  {"mail",                     no_argument,            0, 'm'},
+  {"mail",                     optional_argument,      0, 'm'},
   {"media",                    required_argument,      0, 'M'},
   {"copies",                   required_argument,      0, 'n'},
   {"newline",                  required_argument,      0, 'N'},
@@ -1467,7 +1469,8 @@ name             width\theight\tllx\tlly\turx\tury\n\
       buffer_append (&buffer, enscript_library);
       buffer_append (&buffer, "/hl/*.st");
 
-      system (buffer_ptr (&buffer));
+      if (system (buffer_ptr (&buffer)) < 0)
+       perror("system");
       exit (0);
     }
 
@@ -1849,7 +1852,11 @@ open_output_file ()
       /* Format spooler options. */
       spooler_options[0] = '\0';
       if (mail)
-       strcat (spooler_options, "-m ");
+       {
+         strcat (spooler_options, "-m ");
+         strcat (spooler_options, mailto);
+         strcat (spooler_options, " ");
+       }
       if (no_job_header)
        {
          strcat (spooler_options, no_job_header_switch);
@@ -2012,7 +2019,7 @@ handle_options (int argc, char *argv[])
       int i;
 
       c = getopt_long (argc, argv,
-                      "#:123456789a:A:b:BcC::d:D:e::E::f:F:gGhH::i:I:jJ:kKlL:mM:n:N:o:Op:P:qrRs:S:t:T:u::U:vVw:W:X:zZ",
+                      "#:123456789a:A:b:BcC::d:D:e::E::f:F:gGhH::i:I:jJ:kKlL:m::M:n:N:o:Op:P:qrRs:S:t:T:u::U:vVw:W:X:zZ",
                       long_options, &option_index);
 
       if (c == -1)
@@ -2213,6 +2220,10 @@ handle_options (int argc, char *argv[])
 
        case 'm':               /* send mail upon completion */
          mail = 1;
+         if(optarg)
+           mailto = (optarg);
+         else
+           mailto = (*passwd).pw_name;
          break;
 
        case 'M':               /* select output media */