X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=systemv%2Flpstat.c;h=316617382989d3e1febdf45b1a9e8c3f114970ed;hb=c07d5b2daf136da7af01c48ff78135d06d2762fc;hp=fd58f2774bebfdb0b7031d030be73e0b47b6d71f;hpb=b423cd4cb9fa8cf030cc046a59c28196f3edf6b4;p=thirdparty%2Fcups.git diff --git a/systemv/lpstat.c b/systemv/lpstat.c index fd58f2774..316617382 100644 --- a/systemv/lpstat.c +++ b/systemv/lpstat.c @@ -1,5 +1,5 @@ /* - * "$Id: lpstat.c 5199 2006-02-27 22:01:02Z mike $" + * "$Id: lpstat.c 181 2006-06-22 20:01:18Z jlovell $" * * "lpstat" command for the Common UNIX Printing System (CUPS). * @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -70,23 +71,58 @@ static void show_scheduler(http_t *); */ int -main(int argc, /* I - Number of command-line arguments */ - char *argv[]) /* I - Command-line arguments */ +main(int argc, /* I - Number of command-line arguments */ + char *argv[]) /* I - Command-line arguments */ { - int i, /* Looping var */ - status; /* Exit status */ - http_t *http; /* Connection to server */ - int num_dests; /* Number of user destinations */ - cups_dest_t *dests; /* User destinations */ - int long_status; /* Long status report? */ - int ranking; /* Show job ranking? */ - const char *which; /* Which jobs to show? */ - char op; /* Last operation on command-line */ + int i, /* Looping var */ + status; /* Exit status */ + http_t *http; /* Connection to server */ + int num_dests; /* Number of user destinations */ + cups_dest_t *dests; /* User destinations */ + int long_status; /* Long status report? */ + int ranking; /* Show job ranking? */ + const char *which; /* Which jobs to show? */ + char op; /* Last operation on command-line */ + /* + * Set the locale so that times, etc. are displayed properly. + * + * Unfortunately, while we need the localized time value, we *don't* + * want to use the localized charset for the time value, so we need + * to set LC_TIME to the locale name with .UTF-8 on the end (if + * the locale includes a character set specifier...) + */ + + setlocale(LC_ALL, ""); + #ifdef LC_TIME - setlocale(LC_TIME, ""); + { + const char *lc_time; /* Current LC_TIME value */ + char new_lc_time[255], /* New LC_TIME value */ + *charset; /* Pointer to character set */ + + if ((lc_time = setlocale(LC_TIME, NULL)) == NULL) + lc_time = setlocale(LC_ALL, NULL); + + if (lc_time) + { + strlcpy(new_lc_time, lc_time, sizeof(new_lc_time)); + if ((charset = strchr(new_lc_time, '.')) == NULL) + charset = new_lc_time + strlen(new_lc_time); + + strlcpy(charset, ".UTF-8", sizeof(new_lc_time) - (charset - new_lc_time)); + } + else + strcpy(new_lc_time, "C"); + + setlocale(LC_TIME, new_lc_time); + } #endif /* LC_TIME */ + + /* + * Parse command-line options... + */ http = NULL; num_dests = 0; @@ -233,10 +269,10 @@ main(int argc, /* I - Number of command-line arguments */ } else { - _cupsLangPuts(stderr, - _("%s: Error - expected destination after " - "\'-b\' option!\n"), - argv[0]); + _cupsLangPrintf(stderr, + _("%s: Error - expected destination after " + "\'-b\' option!\n"), + argv[0]); return (1); } @@ -2246,5 +2282,5 @@ show_scheduler(http_t *http) /* I - HTTP connection to server */ /* - * End of "$Id: lpstat.c 5199 2006-02-27 22:01:02Z mike $". + * End of "$Id: lpstat.c 181 2006-06-22 20:01:18Z jlovell $". */