123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- #include "libcommon.h"
- #include "getopt.h"
- extern struct option long_options[];
- #define ARG_NONE 0
- #define ARG_REQUIRED 1
- #define ARG_OPTIONAL 2
- bool elementp (int item, const int *list);
- void display_usage (const char *progname, const int *omit_vals, const char *appendage, int info);
- void display_version (const char *progname, const char *written, const char *copyright);
- bool
- elementp (int item, const int *list)
- {
- int list_item;
- while ((list_item = *list++) != 0)
- {
- if (item == list_item)
- return true;
- }
- return false;
- }
-
- void
- display_usage (const char *progname, const int *omit_vals, const char *appendage, int info)
- {
- int i;
- int col = 0;
-
- fprintf (stdout, "Usage: %s", progname);
- col += (strlen (progname) + 7);
- for (i = 0; long_options[i].name; i++)
- {
- int option_len;
-
- if (elementp (long_options[i].val, omit_vals))
- continue;
- option_len = strlen (long_options[i].name);
- if (col >= 80 - (option_len + 16))
- {
- fputs ("\n\t", stdout);
- col = 8;
- }
- fprintf (stdout, " [--%s", long_options[i].name);
- col += (option_len + 4);
- if ((unsigned int)(long_options[i].val) < 256)
- {
- fprintf (stdout, " | -%c", long_options[i].val);
- col += 5;
- }
- if (long_options[i].has_arg == ARG_REQUIRED)
- {
- fputs (" arg]", stdout);
- col += 5;
- }
- else if (long_options[i].has_arg == ARG_OPTIONAL)
- {
- fputs (" [arg(s)]]", stdout);
- col += 10;
- }
- else
- {
- fputs ("]", stdout);
- col++;
- }
- }
- if (appendage != NULL)
- fputs (appendage, stdout);
- else
- fputs ("\n", stdout);
- if (info == 1)
- {
- fprintf (stdout, "\n\
- To specify an output format, type `%s -T \"format\"',\n\
- where \"format\" is one of:\n", progname);
- }
- else if (info == 2)
- {
- fprintf (stdout, "\n\
- To list available fonts, type `%s -T \"format\" --help-fonts',\n\
- where \"format\" is the output format, and is one of:\n", progname);
- }
-
- if (info == 1 || info == 2)
- {
- #ifdef INCLUDE_PNG_SUPPORT
- #ifndef X_DISPLAY_MISSING
- fprintf (stdout, "\
- X, png, pnm, or gif (bitmap formats), or\n\
- svg, ps, ai, cgm, fig, pcl, hpgl, regis, or tek (vector formats).\n");
- #else
- fprintf (stdout, "\
- png, pnm, or gif (bitmap formats), or\n\
- svg, ps, ai, cgm, fig, pcl, hpgl, regis, or tek (vector formats).\n");
- #endif
- #else
- #ifndef X_DISPLAY_MISSING
- fprintf (stdout, "\
- X, pnm, or gif (bitmap formats), or\n\
- svg, ps, ai, cgm, fig, pcl, hpgl, regis, or tek (vector formats).\n");
- #else
- fprintf (stdout, "\
- pnm or gif (bitmap formats), or\n\
- svg, ps, ai, cgm, fig, pcl, hpgl, regis, or tek (vector formats).\n");
- #endif
- #endif
- fprintf (stdout, "\
- The default format is \"meta\", which is probably not what you want.\n");
- }
-
- if ((appendage != NULL) || info == 1 || info == 2)
- fputs ("\n", stdout);
- fprintf (stdout, "\
- Report bugs to %s.\n", PACKAGE_BUGREPORT);
- }
- void
- display_version (const char *progname, const char *written, const char *copyright)
- {
- fprintf (stdout, "%s (%s) %s\n",
- progname, PACKAGE_NAME, PACKAGE_VERSION);
- fprintf (stdout, "%s\n",
- copyright);
- fprintf (stdout, "%s",
- "This is free software; see the source for copying conditions. There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
- fprintf (stdout, "%s\n",
- written);
- }
|