A Simple X Image Viewer
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
12 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
12 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* Copyright 2011 Bert Muennich
  2. *
  3. * This file is part of sxiv.
  4. *
  5. * sxiv is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published
  7. * by the Free Software Foundation; either version 2 of the License,
  8. * or (at your option) any later version.
  9. *
  10. * sxiv is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #define _POSIX_C_SOURCE 200112L
  19. #define _IMAGE_CONFIG
  20. #include <stdlib.h>
  21. #include <string.h>
  22. #include <stdio.h>
  23. #include <unistd.h>
  24. #include "options.h"
  25. #include "util.h"
  26. #include "config.h"
  27. options_t _options;
  28. const options_t *options = (const options_t*) &_options;
  29. void print_usage(void)
  30. {
  31. printf("usage: sxiv [-bcdFfhioqrstvZ] [-g GEOMETRY] [-n NUM] "
  32. "[-N name] [-z ZOOM] FILES...\n");
  33. }
  34. void print_version(void)
  35. {
  36. printf("sxiv %s - Simple X Image Viewer\n", VERSION);
  37. }
  38. void parse_options(int argc, char **argv)
  39. {
  40. int opt, t;
  41. _options.from_stdin = false;
  42. _options.to_stdout = false;
  43. _options.recursive = false;
  44. _options.startnum = 0;
  45. _options.scalemode = SCALE_MODE;
  46. _options.zoom = 1.0;
  47. _options.fixed_win = false;
  48. _options.fullscreen = false;
  49. _options.hide_bar = false;
  50. _options.geometry = NULL;
  51. _options.res_name = NULL;
  52. _options.quiet = false;
  53. _options.thumb_mode = false;
  54. _options.clean_cache = false;
  55. while ((opt = getopt(argc, argv, "bcdFfg:hin:N:oqrstvZz:")) != -1) {
  56. switch (opt) {
  57. case '?':
  58. print_usage();
  59. exit(EXIT_FAILURE);
  60. case 'b':
  61. _options.hide_bar = true;
  62. break;
  63. case 'c':
  64. _options.clean_cache = true;
  65. break;
  66. case 'd':
  67. _options.scalemode = SCALE_DOWN;
  68. break;
  69. case 'F':
  70. _options.fixed_win = true;
  71. break;
  72. case 'f':
  73. _options.fullscreen = true;
  74. break;
  75. case 'g':
  76. _options.geometry = optarg;
  77. break;
  78. case 'h':
  79. print_usage();
  80. exit(EXIT_SUCCESS);
  81. case 'i':
  82. _options.from_stdin = true;
  83. break;
  84. case 'n':
  85. if (sscanf(optarg, "%d", &t) <= 0 || t < 1) {
  86. fprintf(stderr, "sxiv: invalid argument for option -n: %s\n",
  87. optarg);
  88. exit(EXIT_FAILURE);
  89. } else {
  90. _options.startnum = t - 1;
  91. }
  92. break;
  93. case 'N':
  94. _options.res_name = optarg;
  95. break;
  96. case 'o':
  97. _options.to_stdout = true;
  98. break;
  99. case 'q':
  100. _options.quiet = true;
  101. break;
  102. case 'r':
  103. _options.recursive = true;
  104. break;
  105. case 's':
  106. _options.scalemode = SCALE_FIT;
  107. break;
  108. case 't':
  109. _options.thumb_mode = true;
  110. break;
  111. case 'v':
  112. print_version();
  113. exit(EXIT_SUCCESS);
  114. case 'Z':
  115. _options.scalemode = SCALE_ZOOM;
  116. _options.zoom = 1.0;
  117. break;
  118. case 'z':
  119. _options.scalemode = SCALE_ZOOM;
  120. if (sscanf(optarg, "%d", &t) <= 0 || t <= 0) {
  121. fprintf(stderr, "sxiv: invalid argument for option -z: %s\n",
  122. optarg);
  123. exit(EXIT_FAILURE);
  124. }
  125. _options.zoom = (float) t / 100.0;
  126. break;
  127. }
  128. }
  129. _options.filenames = argv + optind;
  130. _options.filecnt = argc - optind;
  131. if (_options.filecnt == 1 && STREQ(_options.filenames[0], "-")) {
  132. _options.filenames++;
  133. _options.filecnt--;
  134. _options.from_stdin = true;
  135. }
  136. }