/* EXTPROTO */ void rxvt_usage(int type) { unsigned int i, col; write(STDERR_FILENO, releasestring, sizeof(releasestring) - 1); write(STDERR_FILENO, optionsstring, sizeof(optionsstring) - 1); write(STDERR_FILENO, APL_NAME, sizeof(APL_NAME) - 1); switch (type) { case 0: /* brief listing */ fprintf(stderr, " [-help] [--help]\n"); for (col = 1, i = 0; i < optList_size(); i++) if (optList[i].desc != NULL) { int len = 0; if (!optList_isBool(i)) { len = optList_strlen(i); if (len > 0) len++; /* account for space */ } #ifdef DEBUG_STRICT assert(optList[i].opt != NULL); #endif len += 4 + STRLEN(optList[i].opt) + (optList_isBool(i) ? 2: 0); col += len; if (col > 79) { /* assume regular width */ putc('\n', stderr); col = 1 + len; } fprintf(stderr, " [-%s%s", (optList_isBool(i) ? "/+" : ""), optList[i].opt); if (optList_strlen(i)) fprintf(stderr, " %s]", optList[i].arg); else fprintf(stderr, "]"); } break; case 1: /* full command-line listing */ fprintf(stderr, " [options] [-e command args]\n\n" "where options include:\n"); for (i = 0; i < optList_size(); i++) if (optList[i].desc != NULL) { #ifdef DEBUG_STRICT assert(optList[i].opt != NULL); #endif fprintf(stderr, " %s%s %-*s%s%s\n", (optList_isBool(i) ? "-/+" : "-"), optList[i].opt, (INDENT - STRLEN(optList[i].opt) + (optList_isBool(i) ? 0 : 2)), (optList[i].arg ? optList[i].arg : ""), (optList_isBool(i) ? "turn on/off " : ""), optList[i].desc); } fprintf(stderr, "\n --help to list long-options"); break; case 2: /* full resource listing */ fprintf(stderr, " [options] [-e command args]\n\n" "where resources (long-options) include:\n"); for (i = 0; i < optList_size(); i++) if (optList[i].kw != NULL) fprintf(stderr, " %s: %*s%s\n", optList[i].kw, (INDENT - STRLEN(optList[i].kw)), "", /* XXX */ (optList_isBool(i) ? "boolean" : optList[i].arg)); #ifdef KEYSYM_RESOURCE fprintf(stderr, " " "keysym.sym" ": %*s%s\n", (INDENT - sizeof("keysym.sym") + 1), "", /* XXX */ "keysym"); #endif fprintf(stderr, "\n -help to list options"); break; } fprintf(stderr, "\n\n"); exit(EXIT_FAILURE); /* NOTREACHED */ }
/*----------------------------------------------------------------------*/ void rxvt_term::rxvt_usage (int type) { unsigned int i, col; rxvt_log ("%s%s%s", releasestring, optionsstring, RESNAME); switch (type) { case 0: /* brief listing */ rxvt_log (" [-help] [--help]\n"); for (col = 1, i = 0; i < ecb_array_length (optList); i++) if (optList[i].desc != NULL) { int len = 0; if (optList[i].arg) len = strlen (optList[i].arg) + 1; assert (optList[i].opt != NULL); len += 4 + strlen (optList[i].opt) + (optList_isBool (i) ? 2 : 0); col += len; if (col > 79) { /* assume regular width */ rxvt_log ("\n"); col = 1 + len; } rxvt_log (" [-%s%s", (optList_isBool (i) ? "/+" : ""), optList[i].opt); if (optList[i].arg) rxvt_log (" %s]", optList[i].arg); else rxvt_log ("]"); } break; case 1: /* full command-line listing */ rxvt_log (" [options] [-e command args]\n\nwhere options include:\n"); for (i = 0; i < ecb_array_length (optList); i++) if (optList[i].desc != NULL) { assert (optList[i].opt != NULL); rxvt_log (" %s%s %-*s%s%s\n", (optList_isBool (i) ? "-/+" : "-"), optList[i].opt, (INDENT - strlen (optList[i].opt) + (optList_isBool (i) ? 0 : 2)), (optList[i].arg ? optList[i].arg : ""), (optList_isBool (i) ? "turn on/off " : ""), optList[i].desc); } #if ENABLE_PERL rxvt_perl.init (this); rxvt_perl.usage (this, 1); #endif rxvt_log ("\n --help to list long-options"); break; case 2: /* full resource listing */ rxvt_log (" [options] [-e command args]\n\n" "where resources (long-options) include:\n"); for (i = 0; i < ecb_array_length (optList); i++) if (optList[i].kw != NULL) rxvt_log (" %s: %*s%s\n", optList[i].kw, (INDENT + 2 - strlen (optList[i].kw)), "", /* XXX */ (optList_isBool (i) ? "boolean" : optList[i].arg)); #if ENABLE_PERL rxvt_perl.init (this); rxvt_perl.usage (this, 2); #endif rxvt_log ("\n -help to list options"); break; } rxvt_log ("\n\n"); rxvt_exit_failure (); }