<commit_before>/* Copyright (c) 2015 imv authors

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#include <limits.h>
#include <stdio.h>
#include <stddef.h>
#include <stdint.h>
#include <unistd.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
#include <FreeImage.h>
#include <getopt.h>
#include <ctype.h>
#include <poll.h>
#include <errno.h>

#include "loader.h"
#include "texture.h"
#include "navigator.h"
#include "viewport.h"
#include "util.h"

enum scaling_mode {
  NONE,
  DOWN,
  FULL
};

static char *scaling_label[] = {
  "actual size",
  "best fit",
  "perfect fit"
};

struct {
  int fullscreen;
  int stdin_list;
  int recursive;
  int scaling;
  int nearest_neighbour;
  int solid_bg;
  int list;
  unsigned long delay;
  int cycle;
  unsigned char bg_r;
  unsigned char bg_g;
  unsigned char bg_b;
  int overlay;
  const char *start_at;
  const char *font;
} g_options = {
  .fullscreen = 0,
  .stdin_list = 0,
  .recursive = 0,
  .scaling = FULL,
  .nearest_neighbour = 0,
  .solid_bg = 1,
  .list = 0,
  .delay = 0,
  .cycle = 1,
  .bg_r = 0,
  .bg_g = 0,
  .bg_b = 0,
  .overlay = 0,
  .start_at = NULL,
  .font = "Monospace:24",
};

static void print_usage(void)
{
  fprintf(stdout,
  "imv %s\n"
  "See manual for usage information.\n"
  "\n"
  "Legal:\n"
  "This program is free software; you can redistribute it and/or\n"
  "modify it under the terms of the GNU General Public License\n"
  "as published by the Free Software Foundation; either version 2\n"
  "of the License, or (at your option) any later version.\n"
  "\n"
  "This software uses the FreeImage open source image library.\n"
  "See http://freeimage.sourceforge.net for details.\n"
  "FreeImage is used under the GNU GPLv2.\n"
  , IMV_VERSION);
}

static void parse_args(int argc, char** argv)
{
  /* Do not print getopt errors */
  opterr = 0;

  char *argp, *ep = *argv, o;

  while((o = getopt(argc, argv, "firasSudxhln:b:e:t:")) != -1) {
    switch(o) {
      case 'f': g_options.fullscreen = 1;   break;
      case 'i':
        g_options.stdin_list = 1;<commit_msg>Store getopt() return in a signed variable<commit_after>/* Copyright (c) 2015 imv authors

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#include <limits.h>
#include <stdio.h>
#include <stddef.h>
#include <stdint.h>
#include <unistd.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
#include <FreeImage.h>
#include <getopt.h>
#include <ctype.h>
#include <poll.h>
#include <errno.h>

#include "loader.h"
#include "texture.h"
#include "navigator.h"
#include "viewport.h"
#include "util.h"

enum scaling_mode {
  NONE,
  DOWN,
  FULL
};

static char *scaling_label[] = {
  "actual size",
  "best fit",
  "perfect fit"
};

struct {
  int fullscreen;
  int stdin_list;
  int recursive;
  int scaling;
  int nearest_neighbour;
  int solid_bg;
  int list;
  unsigned long delay;
  int cycle;
  unsigned char bg_r;
  unsigned char bg_g;
  unsigned char bg_b;
  int overlay;
  const char *start_at;
  const char *font;
} g_options = {
  .fullscreen = 0,
  .stdin_list = 0,
  .recursive = 0,
  .scaling = FULL,
  .nearest_neighbour = 0,
  .solid_bg = 1,
  .list = 0,
  .delay = 0,
  .cycle = 1,
  .bg_r = 0,
  .bg_g = 0,
  .bg_b = 0,
  .overlay = 0,
  .start_at = NULL,
  .font = "Monospace:24",
};

static void print_usage(void)
{
  fprintf(stdout,
  "imv %s\n"
  "See manual for usage information.\n"
  "\n"
  "Legal:\n"
  "This program is free software; you can redistribute it and/or\n"
  "modify it under the terms of the GNU General Public License\n"
  "as published by the Free Software Foundation; either version 2\n"
  "of the License, or (at your option) any later version.\n"
  "\n"
  "This software uses the FreeImage open source image library.\n"
  "See http://freeimage.sourceforge.net for details.\n"
  "FreeImage is used under the GNU GPLv2.\n"
  , IMV_VERSION);
}

static void parse_args(int argc, char** argv)
{
  /* Do not print getopt errors */
  opterr = 0;

  char *argp, *ep = *argv;
  int o;

  while((o = getopt(argc, argv, "firasSudxhln:b:e:t:")) != -1) {
    switch(o) {
      case 'f': g_options.fullscreen = 1;   break;
      case 'i':
        g_options.stdin_list = 1;
{'fraction_non_alphanumeric': 0.11432786280656464, 'fraction_numerical': 0.01401438318274018, 'mean_word_length': 3.4752475247524752, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3127089', 'n_tokens_mistral': 2002, 'n_tokens_neox': 1894, 'n_words': 694}