<commit_before>/* $Id$ */

#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>

#ifndef WIN32
#include <signal.h>
#endif

#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif

#include "main.h"

#include "actions.h"
#include "foreach.h"
#include "interface.h"
#include "options.h"
#include "range.h"
#include "shell.h"
#include "test.h"

#ifdef ENABLE_NLS
#  include <libintl.h>
#endif

/* Initializes the globals */
int  init_globals();

/* Takes the current globals, and sets up the gPhoto lib with them */
int  set_globals();

/* Command-line option
   -----------------------------------------------------------------------
   this is funky and may look a little scary, but sounded cool to do.
   it makes sense since this is just a wrapper for a functional/flow-based
   library.
   AFTER NOTE: whoah. gnome does something like this. cool deal :)

   When the program starts it calls (in order):
        1) verify_options() to make sure all options are valid,
           and that any options needing an argument have one (or if they
           need an argument, they don't have one).
        2) (optional) option_is_present() to see if a particular option was
           typed in the command-line. This can be used to set up something
           before the next step.
        3) execute_options() to actually parse the command-line and execute
           the command-line options in order.

   This might sound a little complex, but makes adding options REALLY easy,
   and it is very flexible.

   How to add a command-line option:
*/

/* 1) Add a forward-declaration here                                    */
/*    ----------------------------------------------------------------- */
/*    Use the OPTION_CALLBACK(function) macro.                          */

OPTION_CALLBACK(abilities);
OPTION_CALLBACK(help);
OPTION_CALLBACK(test);
OPTION_CALLBACK(shell);
OPTION_CALLBACK(list_cameras);
OPTION_CALLBACK(auto_detect);
OPTION_CALLBACK(list_ports);
OPTION_CALLBACK(filename);
OPTION_CALLBACK(port);
OPTION_CALLBACK(speed);
OPTION_CALLBACK(model);
OPTION_CALLBACK(quiet);
OPTION_CALLBACK(debug);
OPTION_CALLBACK(use_folder);
OPTION_CALLBACK(recurse);
OPTION_CALLBACK(use_stdout);
OPTION_CALLBACK(use_stdout_size);
OPTION_CALLBACK(list_folders);
OPTION_CALLBACK(list_files);
OPTION_CALLBACK(num_pictures);
OPTION_CALLBACK(get_picture);
OPTION_CALLBACK(get_all_pictures);
OPTION_CALLBACK(get_thumbnail);
OPTION_CALLBACK(get_all_thumbnails);
OPTION_CALLBACK(delete_picture);
OPTION_CALLBACK(delete_all_pictures);
OPTION_CALLBACK(upload_picture);
OPTION_CALLBACK(capture_image);
OPTION_CALLBACK(capture_preview);
OPTION_CALLBACK(capture_movie);
OPTION_CALLBACK(capture_sound);
OPTION_CALLBACK(summary);
OPTION_CALLBACK(manual);
OPTION_CALLBACK(about);

/* 2) Add an entry in the option table                          */
/*    ----------------------------------------------------------------- */
/*    Format for option is:                                             */
/*     {"short", "long", "argument", "description", callback_function, required}, */
/*    if it is just a flag, set the argument to "".                     */
/*    Order is important! Options are exec'd in the order in the table! */

Option option[] = {

/* Settings needed for formatting output */
{"",  "debug",          "",             "Turn on debugging",            debug,          0},
{"q", "quiet",          "",             "Quiet output (default=verbose)",quiet,         0},

/* Display and die actions */

{"h", "help",           "",             "Displays this help screen",    help,           0},
{"",  "verify",         "",             "Verifies gPhoto installation", test,           0},
{"",  "list-cameras",   "",             "List supported camera models", list_cameras,   0},
{"",  "list-ports",     "",             "List supported port devices",  list_ports,     0},
{"",  "stdout",         "",             "Send file to stdout",          use_stdout,     0},
{"",  "stdout-size",    "",             "Print filesize before data",   use_stdout_size,0},
{"",  "auto-detect",    "",             "List auto-detected cameras",   auto_detect,    0},

/* Settings needed for camera functions */
{"" , "port",           "path",         "Specify port device",          port,           0},
{"" , "speed",          "speed",        "Specify serial transfer speed",speed,          0},
{"" , "camera",         "model",        "Specify camera model",         model,          0},
{"" , "filename",       "filename",     "Specify a filename",           filename,       0},

/* Actions that depend on settings */
{"a", "abilities",      "",             "Display camera abilities",     abilities,      0},
{"f", "folder",         "folder",       "Specify camera folder (default=\"/\")",use_folder,0},
{"R", "recurse",        "",             "Recursively descend through folders",recurse,  0},
{"l", "list-folders",   "",             "List folders in folder",       list_folders,   0},
{"L", "list-files",     "",             "List files in folder",         list_files,     0},
{"n", "num-pictures",   "",             "Display number of pictures",   num_pictures,   0},
{"p", "get-picture",    "range",        "Get pictures given in range",  get_picture,    0},
{"P", "get-all-pictures","",            "Get all pictures from folder", get_all_pictures,0},
{"t", "get-thumbnail",  "range",        "Get thumbnails given in range",get_thumbnail,  0},
{"T", "get-all-thumbnails","",          "Get all thumbnails from folder",get_all_thumbnails,0},
{"d", "delete-picture", "range",        "Delete pictures given in range", delete_picture, 0},
{"D", "delete-all-pictures","",         "Delete all pictures in folder",delete_all_pictures,0},
{"u", "upload-picture", "filename",     "Upload a picture to camera",   upload_picture, 0},
{"" , "capture-preview","",             "Capture a quick preview",      capture_preview, 0},
{"" , "capture-image",  "",             "Capture an image",             capture_image,  0},
{"" , "capture-movie",  "",             "Capture a movie ",             capture_movie,  0},
{"" , "capture-sound",  "",             "Capture an audio clip",        capture_sound,  0},
{"",  "summary",        "",             "Summary of camera status",     summary,        0},
{"",  "manual",         "",             "Camera driver manual",         manual,         0},
{"",  "about",          "",             "About the camera driver",      about,          0},
{"",  "shell",          "",             "gPhoto shell",                 shell,          0},

/* End of list                  */
{"" , "",               "",             "",                             NULL,           0}
};

/* 3) Add any necessary global variables                                */<commit_msg>Modified command line options to more consistently use the term 'image' instead of 'picture'. Previously, the two terms were used interchangably, which lead to some confusion.<commit_after>/* $Id$ */

#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>

#ifndef WIN32
#include <signal.h>
#endif

#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif

#include "main.h"

#include "actions.h"
#include "foreach.h"
#include "interface.h"
#include "options.h"
#include "range.h"
#include "shell.h"
#include "test.h"

#ifdef ENABLE_NLS
#  include <libintl.h>
#endif

/* Initializes the globals */
int  init_globals();

/* Takes the current globals, and sets up the gPhoto lib with them */
int  set_globals();

/* Command-line option
   -----------------------------------------------------------------------
   this is funky and may look a little scary, but sounded cool to do.
   it makes sense since this is just a wrapper for a functional/flow-based
   library.
   AFTER NOTE: whoah. gnome does something like this. cool deal :)

   When the program starts it calls (in order):
        1) verify_options() to make sure all options are valid,
           and that any options needing an argument have one (or if they
           need an argument, they don't have one).
        2) (optional) option_is_present() to see if a particular option was
           typed in the command-line. This can be used to set up something
           before the next step.
        3) execute_options() to actually parse the command-line and execute
           the command-line options in order.

   This might sound a little complex, but makes adding options REALLY easy,
   and it is very flexible.

   How to add a command-line option:
*/

/* 1) Add a forward-declaration here                                    */
/*    ----------------------------------------------------------------- */
/*    Use the OPTION_CALLBACK(function) macro.                          */

OPTION_CALLBACK(abilities);
OPTION_CALLBACK(help);
OPTION_CALLBACK(test);
OPTION_CALLBACK(shell);
OPTION_CALLBACK(list_cameras);
OPTION_CALLBACK(auto_detect);
OPTION_CALLBACK(list_ports);
OPTION_CALLBACK(filename);
OPTION_CALLBACK(port);
OPTION_CALLBACK(speed);
OPTION_CALLBACK(model);
OPTION_CALLBACK(quiet);
OPTION_CALLBACK(debug);
OPTION_CALLBACK(use_folder);
OPTION_CALLBACK(recurse);
OPTION_CALLBACK(use_stdout);
OPTION_CALLBACK(use_stdout_size);
OPTION_CALLBACK(list_folders);
OPTION_CALLBACK(list_files);
OPTION_CALLBACK(num_pictures);
OPTION_CALLBACK(get_picture);
OPTION_CALLBACK(get_all_pictures);
OPTION_CALLBACK(get_thumbnail);
OPTION_CALLBACK(get_all_thumbnails);
OPTION_CALLBACK(delete_picture);
OPTION_CALLBACK(delete_all_pictures);
OPTION_CALLBACK(upload_picture);
OPTION_CALLBACK(capture_image);
OPTION_CALLBACK(capture_preview);
OPTION_CALLBACK(capture_movie);
OPTION_CALLBACK(capture_sound);
OPTION_CALLBACK(summary);
OPTION_CALLBACK(manual);
OPTION_CALLBACK(about);

/* 2) Add an entry in the option table                          */
/*    ----------------------------------------------------------------- */
/*    Format for option is:                                             */
/*     {"short", "long", "argument", "description", callback_function, required}, */
/*    if it is just a flag, set the argument to "".                     */
/*    Order is important! Options are exec'd in the order in the table! */

Option option[] = {

/* Settings needed for formatting output */
{"",  "debug",          "",             "Turn on debugging",            debug,          0},
{"q", "quiet",          "",             "Quiet output (default=verbose)",quiet,         0},

/* Display and die actions */

{"h", "help",           "",             "Displays this help screen",    help,           0},
{"",  "verify",         "",             "Verifies gPhoto installation", test,           0},
{"",  "list-cameras",   "",             "List supported camera models", list_cameras,   0},
{"",  "list-ports",     "",             "List supported port devices",  list_ports,     0},
{"",  "stdout",         "",             "Send file to stdout",          use_stdout,     0},
{"",  "stdout-size",    "",             "Print filesize before data",   use_stdout_size,0},
{"",  "auto-detect",    "",             "List auto-detected cameras",   auto_detect,    0},

/* Settings needed for camera functions */
{"" , "port",           "path",         "Specify port device",          port,           0},
{"" , "speed",          "speed",        "Specify serial transfer speed",speed,          0},
{"" , "camera",         "model",        "Specify camera model",         model,          0},
{"" , "filename",       "filename",     "Specify a filename",           filename,       0},

/* Actions that depend on settings */
{"a", "abilities",      "",             "Display camera abilities",     abilities,      0},
{"f", "folder",         "folder",       "Specify camera folder (default=\"/\")",use_folder,0},
{"R", "recurse",        "",             "Recursively descend through folders",recurse,  0},
{"l", "list-folders",   "",             "List folders in folder",       list_folders,   0},
{"L", "list-files",     "",             "List files in folder",         list_files,     0},
{"n", "num-images",   "",             "Display number of pictures",   num_pictures,   0},
{"p", "get-image",    "range",        "Get pictures given in range",  get_picture,    0},
{"P", "get-all-images","",            "Get all pictures from folder", get_all_pictures,0},
{"t", "get-thumbnail",  "range",        "Get thumbnails given in range",get_thumbnail,  0},
{"T", "get-all-thumbnails","",          "Get all thumbnails from folder",get_all_thumbnails,0},
{"d", "delete-picture", "range",        "Delete pictures given in range", delete_picture, 0},
{"D", "delete-all-images","",         "Delete all pictures in folder",delete_all_pictures,0},
{"u", "upload-image", "filename",     "Upload a picture to camera",   upload_picture, 0},
{"" , "capture-preview","",             "Capture a quick preview",      capture_preview, 0},
{"" , "capture-image",  "",             "Capture an image",             capture_image,  0},
{"" , "capture-movie",  "",             "Capture a movie ",             capture_movie,  0},
{"" , "capture-sound",  "",             "Capture an audio clip",        capture_sound,  0},
{"",  "summary",        "",             "Summary of camera status",     summary,        0},
{"",  "manual",         "",             "Camera driver manual",         manual,         0},
{"",  "about",          "",             "About the camera driver",      about,          0},
{"",  "shell",          "",             "gPhoto shell",                 shell,          0},

/* End of list                  */
{"" , "",               "",             "",                             NULL,           0}
};

/* 3) Add any necessary global variables                                */
{'fraction_non_alphanumeric': 0.16540477577169482, 'fraction_numerical': 0.006260920209668026, 'mean_word_length': 2.1363013698630136, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5260194', 'n_tokens_mistral': 3872, 'n_tokens_neox': 3895, 'n_words': 1143}