Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F115917972
D48380.id148930.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D48380.id148930.diff
View Options
diff --git a/usr.bin/bintrans/bintrans.1 b/usr.bin/bintrans/bintrans.1
--- a/usr.bin/bintrans/bintrans.1
+++ b/usr.bin/bintrans/bintrans.1
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 23, 2024
+.Dd January 8, 2025
.Dt BINTRANS 1
.Os
.Sh NAME
@@ -230,7 +230,7 @@
is a quoted-printable converter
and accepts the following options:
.Bl -tag -width indent
-.It Fl u
+.It Fl d
Decode.
.It Fl o Ar output_file
Output to
diff --git a/usr.bin/bintrans/qp.c b/usr.bin/bintrans/qp.c
--- a/usr.bin/bintrans/qp.c
+++ b/usr.bin/bintrans/qp.c
@@ -26,6 +26,7 @@
*/
#include <ctype.h>
+#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
@@ -157,38 +158,44 @@
int
main_quotedprintable(int argc, char *argv[])
{
- int i;
+ int ch;
bool encode = true;
FILE *fp = stdin;
FILE *fpo = stdout;
- for (i = 1; i < argc; ++i) {
- if (argv[i][0] == '-') {
- switch (argv[i][1]) {
- case 'o':
- if (++i >= argc) {
- fprintf(stderr, "qp: -o requires a file name.\n");
- exit(EXIT_FAILURE);
- }
- fpo = fopen(argv[i], "w");
- if (fpo == NULL) {
- perror(argv[i]);
- exit(EXIT_FAILURE);
- }
- break;
- case 'u':
- encode = false;
- break;
- default:
- usage();
- exit(EXIT_FAILURE);
- }
- } else {
- fp = fopen(argv[i], "r");
- if (fp == NULL) {
- perror(argv[i]);
+ static const struct option opts[] =
+ {
+ { "decode", no_argument, NULL, 'd'},
+ { "output", required_argument, NULL, 'o'},
+ {NULL, no_argument, NULL, 0}
+ };
+
+ while ((ch = getopt_long(argc, argv, "do:u", opts, NULL)) != -1) {
+ switch(ch) {
+ case 'o':
+ fpo = fopen(optarg, "w");
+ if (fpo == NULL) {
+ perror(optarg);
exit(EXIT_FAILURE);
}
+ break;
+ case 'u':
+ /* FALLTHROUGH for backward compatibility */
+ case 'd':
+ encode = false;
+ break;
+ default:
+ usage();
+ exit(EXIT_FAILURE);
+ }
+ };
+ argc -= optind;
+ argv += optind;
+ if (argc > 0) {
+ fp = fopen(argv[0], "r");
+ if (fp == NULL) {
+ perror(argv[0]);
+ exit(EXIT_FAILURE);
}
}
qp(fp, fpo, encode);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, May 1, 9:49 AM (17 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17878839
Default Alt Text
D48380.id148930.diff (2 KB)
Attached To
Mode
D48380: bintrans(1): qp switch to getopt_long
Attached
Detach File
Event Timeline
Log In to Comment