1 /* core.h - private type definitions, defines and macros 2 * Copyright (C) 2000-2009 Jason Jordan <shnutils@freeshell.org> 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 /* 20 * $Id: core.h,v 1.96 2009/03/16 04:46:03 jason Exp $ 21 */ 22 23 #ifndef __CORE_H__ 24 #define __CORE_H__ 25 26 /* program info */ 27 #define RELEASE VERSION 28 #define COPYRIGHT "Copyright (C) 2000-2009" 29 #define AUTHOR "Jason Jordan <shnutils@freeshell.org>" 30 #define URL1 "http://www.etree.org/shnutils/" 31 #define URL2 "http://shnutils.freeshell.org/" 32 33 /* options for core (non-mode) use */ 34 #define GLOBAL_OPTS_CORE "afhjmv" 35 36 /* options reserved for global use - modes cannot use these */ 37 #define GLOBAL_OPTS "DF:HP:hi:qr:vw" 38 #define GLOBAL_OPTS_OUTPUT "O:a:d:o:z:" 39 40 /* set this environment variable to enable debugging. can also use -D, but this enables it earlier */ 41 #define SHNTOOL_DEBUG_ENV "ST_DEBUG" 42 43 /* various buffer sizes */ 44 #define PROGNAME_SIZE 256 45 #define MAX_FILENAMES 32768 46 47 #ifdef HAVE_VSNPRINTF 48 #define st_vsnprintf(a,b,c,d) vsnprintf(a,b,c,d) 49 #else 50 #define st_vsnprintf(a,b,c,d) vsprintf(a,c,d) 51 #endif 52 53 #ifndef HAVE_STRERROR 54 extern char *sys_errlist[]; 55 #define strerror(x) sys_errlist[x] 56 #endif 57 58 /* macro for natural filename sorting */ 59 #ifndef PARAMS 60 # if defined PROTOTYPES || (defined __STDC__ && __STDC__) 61 # define PARAMS(Args) Args 62 # else 63 # define PARAMS(Args) () 64 # endif 65 #endif 66 67 /* ID3v2 definitions */ 68 #define ID3V2_MAGIC "ID3" 69 70 /* id3v2 header */ 71 typedef struct _id3v2_header { 72 char magic[3]; 73 unsigned char version[2]; 74 unsigned char flags[1]; 75 unsigned char size[4]; 76 } id3v2_header; 77 78 /* file clobber actions */ 79 typedef enum { 80 CLOBBER_ACTION_ASK, 81 CLOBBER_ACTION_ALWAYS, 82 CLOBBER_ACTION_NEVER 83 } clobber_action_types; 84 85 /* progress indicator types */ 86 typedef enum { 87 PROGRESS_NONE, 88 PROGRESS_PERCENT, 89 PROGRESS_DOT, 90 PROGRESS_SPIN, 91 PROGRESS_FACE 92 } progress_types; 93 94 /* argument sources */ 95 typedef enum { 96 ARGSRC_FORMAT, 97 ARGSRC_CMDLINE, 98 ARGSRC_ENV 99 } argument_sources; 100 101 /* input file sources */ 102 typedef enum { 103 INPUT_CMDLINE, 104 INPUT_STDIN, 105 INPUT_FILE, 106 INPUT_INTERNAL 107 } input_sources; 108 109 /* mode and format module arrays */ 110 extern mode_module *st_modes[]; 111 extern format_module *st_formats[]; 112 113 /* private global options */ 114 typedef struct _private_opts { 115 char *progname; 116 char *progmode; 117 char fullprogname[PROGNAME_SIZE]; 118 int debug_level; 119 int clobber_action; 120 int reorder_type; 121 int progress_type; 122 bool is_aliased; 123 bool show_hmmss; 124 bool suppress_warnings; 125 bool suppress_stderr; 126 bool screen_dirty; 127 mode_module *mode; 128 } private_opts; 129 130 typedef struct _input_files { 131 int type; 132 char *filename_source; 133 FILE *fd; 134 int argn; 135 int argc; 136 char **argv; 137 int filecur; 138 int filemax; 139 char *filenames[MAX_FILENAMES]; 140 } input_files; 141 142 extern private_opts st_priv; 143 extern input_files st_input; 144 145 /* miscellaneous functions */ 146 147 /* generic version printing function */ 148 void st_version(void); 149 150 /* functions for building argument lists in format modules */ 151 void arg_init(format_module *); 152 153 #endif 154