… | |
… | |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
6 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
7 | * - original version |
7 | * - original version |
8 | * Copyright (c) 1997,1998 mj olesen <olesen@me.queensu.ca> |
8 | * Copyright (c) 1997,1998 mj olesen <olesen@me.queensu.ca> |
9 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
9 | * Copyright (c) 2003-2006 Marc Lehmann <schmorp@schmorp.de> |
10 | * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it> |
10 | * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it> |
11 | * |
11 | * |
12 | * This program is free software; you can redistribute it and/or modify |
12 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License as published by |
13 | * it under the terms of the GNU General Public License as published by |
14 | * the Free Software Foundation; either version 2 of the License, or |
14 | * the Free Software Foundation; either version 2 of the License, or |
… | |
… | |
397 | switch (type) |
397 | switch (type) |
398 | { |
398 | { |
399 | case 0: /* brief listing */ |
399 | case 0: /* brief listing */ |
400 | rxvt_log (" [-help] [--help]\n"); |
400 | rxvt_log (" [-help] [--help]\n"); |
401 | |
401 | |
402 | for (col = 1, i = 0; i < ARRAY_LENGTH(optList); i++) |
402 | for (col = 1, i = 0; i < ecb_array_length (optList); i++) |
403 | if (optList[i].desc != NULL) |
403 | if (optList[i].desc != NULL) |
404 | { |
404 | { |
405 | int len = 0; |
405 | int len = 0; |
406 | |
406 | |
407 | if (optList[i].arg) |
407 | if (optList[i].arg) |
408 | len = strlen (optList[i].arg) + 1; |
408 | len = strlen (optList[i].arg) + 1; |
409 | assert (optList[i].opt != NULL); |
409 | assert (optList[i].opt != NULL); |
410 | len += 4 + strlen (optList[i].opt) + (optList_isBool (i) ? 2: 0); |
410 | len += 4 + strlen (optList[i].opt) + (optList_isBool (i) ? 2 : 0); |
411 | col += len; |
411 | col += len; |
412 | if (col > 79) |
412 | if (col > 79) |
413 | { |
413 | { |
414 | /* assume regular width */ |
414 | /* assume regular width */ |
415 | rxvt_log ("\n"); |
415 | rxvt_log ("\n"); |
… | |
… | |
425 | break; |
425 | break; |
426 | |
426 | |
427 | case 1: /* full command-line listing */ |
427 | case 1: /* full command-line listing */ |
428 | rxvt_log (" [options] [-e command args]\n\nwhere options include:\n"); |
428 | rxvt_log (" [options] [-e command args]\n\nwhere options include:\n"); |
429 | |
429 | |
430 | for (i = 0; i < ARRAY_LENGTH(optList); i++) |
430 | for (i = 0; i < ecb_array_length (optList); i++) |
431 | if (optList[i].desc != NULL) |
431 | if (optList[i].desc != NULL) |
432 | { |
432 | { |
433 | assert (optList[i].opt != NULL); |
433 | assert (optList[i].opt != NULL); |
434 | rxvt_log (" %s%s %-*s%s%s\n", |
434 | rxvt_log (" %s%s %-*s%s%s\n", |
435 | (optList_isBool (i) ? "-/+" : "-"), optList[i].opt, |
435 | (optList_isBool (i) ? "-/+" : "-"), optList[i].opt, |
… | |
… | |
444 | |
444 | |
445 | case 2: /* full resource listing */ |
445 | case 2: /* full resource listing */ |
446 | rxvt_log (" [options] [-e command args]\n\n" |
446 | rxvt_log (" [options] [-e command args]\n\n" |
447 | "where resources (long-options) include:\n"); |
447 | "where resources (long-options) include:\n"); |
448 | |
448 | |
449 | for (i = 0; i < ARRAY_LENGTH(optList); i++) |
449 | for (i = 0; i < ecb_array_length (optList); i++) |
450 | if (optList[i].kw != NULL) |
450 | if (optList[i].kw != NULL) |
451 | rxvt_log (" %s: %*s%s\n", |
451 | rxvt_log (" %s: %*s%s\n", |
452 | optList[i].kw, |
452 | optList[i].kw, |
453 | (INDENT - strlen (optList[i].kw)), "", /* XXX */ |
453 | (INDENT - strlen (optList[i].kw)), "", /* XXX */ |
454 | (optList_isBool (i) ? "boolean" : optList[i].arg)); |
454 | (optList_isBool (i) ? "boolean" : optList[i].arg)); |
… | |
… | |
461 | break; |
461 | break; |
462 | } |
462 | } |
463 | |
463 | |
464 | rxvt_log ("\n\n"); |
464 | rxvt_log ("\n\n"); |
465 | rxvt_exit_failure (); |
465 | rxvt_exit_failure (); |
466 | /* NOTREACHED */ |
|
|
467 | } |
466 | } |
468 | |
467 | |
469 | /*}}} */ |
468 | /*}}} */ |
470 | |
469 | |
471 | /*{{{ get command-line options before getting resources */ |
470 | /*{{{ get command-line options before getting resources */ |
… | |
… | |
508 | |
507 | |
509 | if (!strcmp (opt, "h")) |
508 | if (!strcmp (opt, "h")) |
510 | rxvt_usage (0); |
509 | rxvt_usage (0); |
511 | |
510 | |
512 | /* feature: always try to match long-options */ |
511 | /* feature: always try to match long-options */ |
513 | for (entry = 0; entry < ARRAY_LENGTH(optList); entry++) |
512 | for (entry = 0; entry < ecb_array_length (optList); entry++) |
514 | if ((optList[entry].kw && !strcmp (opt, optList[entry].kw)) |
513 | if ((optList[entry].kw && !strcmp (opt, optList[entry].kw)) |
515 | || (!longopt |
514 | || (!longopt |
516 | && optList[entry].opt && !strcmp (opt, optList[entry].opt))) |
515 | && optList[entry].opt && !strcmp (opt, optList[entry].opt))) |
517 | break; |
516 | break; |
518 | |
517 | |
519 | if (entry < ARRAY_LENGTH(optList)) |
518 | if (entry < ecb_array_length (optList)) |
520 | { |
519 | { |
521 | if (optList_isReverse (entry)) |
520 | if (optList_isReverse (entry)) |
522 | flag = !flag; |
521 | flag = !flag; |
523 | |
522 | |
524 | if (optList_isString (entry)) |
523 | if (optList_isString (entry)) |
525 | { |
524 | { |
526 | /* |
525 | /* |
527 | * special cases are handled in main.c:main () to allow |
526 | * special cases are handled in init_resources () to allow |
528 | * X resources to set these values before we settle for |
527 | * X resources to set these values before we settle for |
529 | * default values |
528 | * default values |
530 | */ |
529 | */ |
531 | |
530 | |
532 | if (optList[entry].doff != -1) |
531 | if (optList[entry].doff != -1) |
… | |
… | |
585 | * Define key from XrmEnumerateDatabase. |
584 | * Define key from XrmEnumerateDatabase. |
586 | * quarks will be something like |
585 | * quarks will be something like |
587 | * "rxvt" "keysym" "0xFF01" |
586 | * "rxvt" "keysym" "0xFF01" |
588 | * value will be a string |
587 | * value will be a string |
589 | */ |
588 | */ |
590 | /* ARGSUSED */ |
589 | static int |
591 | int |
|
|
592 | rxvt_define_key (XrmDatabase *database UNUSED, |
590 | rxvt_define_key (XrmDatabase *database ecb_unused, |
593 | XrmBindingList bindings UNUSED, |
591 | XrmBindingList bindings ecb_unused, |
594 | XrmQuarkList quarks, |
592 | XrmQuarkList quarks, |
595 | XrmRepresentation *type UNUSED, |
593 | XrmRepresentation *type ecb_unused, |
596 | XrmValue *value, |
594 | XrmValue *value, |
597 | XPointer closure UNUSED) |
595 | XPointer closure ecb_unused) |
598 | { |
596 | { |
599 | int last; |
597 | int last; |
600 | |
598 | |
601 | for (last = 0; quarks[last] != NULLQUARK; last++) /* look for last quark in list */ |
599 | for (last = 0; quarks[last] != NULLQUARK; last++) /* look for last quark in list */ |
602 | ; |
600 | ; |
… | |
… | |
665 | // parse modifiers |
663 | // parse modifiers |
666 | while (str < key) |
664 | while (str < key) |
667 | { |
665 | { |
668 | unsigned int i; |
666 | unsigned int i; |
669 | |
667 | |
670 | for (i=0; i < ARRAY_LENGTH(keysym_vocabulary); ++i) |
668 | for (i = 0; i < ecb_array_length (keysym_vocabulary); ++i) |
671 | { |
669 | { |
672 | if (strncmp (str, keysym_vocabulary [i].name, keysym_vocabulary [i].len) == 0) |
670 | if (strncmp (str, keysym_vocabulary [i].name, keysym_vocabulary [i].len) == 0) |
673 | { |
671 | { |
674 | state |= keysym_vocabulary[i].value; |
672 | state |= keysym_vocabulary[i].value; |
675 | str += keysym_vocabulary[i].len; |
673 | str += keysym_vocabulary[i].len; |
676 | break; |
674 | break; |
677 | } |
675 | } |
678 | } |
676 | } |
679 | |
677 | |
680 | if (i >= ARRAY_LENGTH(keysym_vocabulary)) |
678 | if (i >= ecb_array_length (keysym_vocabulary)) |
681 | return -1; |
679 | return -1; |
682 | |
680 | |
683 | if (*str == '-') |
681 | if (*str == '-') |
684 | ++str; |
682 | ++str; |
685 | } |
683 | } |
… | |
… | |
745 | XrmMergeDatabases (option_db, &database); |
743 | XrmMergeDatabases (option_db, &database); |
746 | option_db = NULL; |
744 | option_db = NULL; |
747 | /* |
745 | /* |
748 | * Query resources for options that affect us |
746 | * Query resources for options that affect us |
749 | */ |
747 | */ |
750 | for (int entry = 0; entry < ARRAY_LENGTH(optList); entry++) |
748 | for (int entry = 0; entry < ecb_array_length (optList); entry++) |
751 | { |
749 | { |
752 | int s; |
750 | int s; |
753 | const char *kw = optList[entry].kw; |
751 | const char *kw = optList[entry].kw; |
754 | |
752 | |
755 | if (kw == NULL || rs[optList[entry].doff] != NULL) |
753 | if (kw == NULL || rs[optList[entry].doff] != NULL) |
… | |
… | |
793 | class_prefix[2] = NULLQUARK; |
791 | class_prefix[2] = NULLQUARK; |
794 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
792 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
795 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
793 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
796 | XrmEnumOneLevel, rxvt_define_key, NULL); |
794 | XrmEnumOneLevel, rxvt_define_key, NULL); |
797 | # ifdef RESFALLBACK |
795 | # ifdef RESFALLBACK |
798 | name_prefix[0] = XrmStringToName (RESFALLBACK); |
|
|
799 | name_prefix[1] = XrmStringToName ("keysym"); |
|
|
800 | class_prefix[0] = XrmStringToName (RESFALLBACK); |
796 | name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK); |
801 | class_prefix[1] = XrmStringToName ("Keysym"); |
|
|
802 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
797 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
803 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
798 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
804 | XrmEnumOneLevel, rxvt_define_key, NULL); |
799 | XrmEnumOneLevel, rxvt_define_key, NULL); |
805 | # endif |
800 | # endif |
806 | # endif |
801 | # endif |