Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[e74fc3]: src / util.h Maximize Restore History

Download this file

util.h    141 lines (115 with data), 3.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
$Id: util.h,v 1.12 2005/02/21 09:00:53 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Miscellaneous things common to standalone programs. */
#ifndef UTIL_H
#define UTIL_H
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <sys/types.h>
#include <cdio/cdio.h>
#include <cdio/logging.h>
#include <cdio/iso9660.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include <ctype.h>
#ifdef HAVE_STDARG_H
/* Get a definition for va_list. */
#include <stdarg.h>
#endif
#include <popt.h>
/* Accomodate to older popt that doesn't support the "optional" flag */
#ifndef POPT_ARGFLAG_OPTIONAL
#define POPT_ARGFLAG_OPTIONAL 0
#endif
#ifdef ENABLE_NLS
#include <locale.h>
# include <libintl.h>
# define _(String) dgettext ("cdinfo", String)
#else
/* Stubs that do something close enough. */
# define _(String) (String)
#endif
/* The following test is to work around the gross typo in
systems like Sony NEWS-OS Release 4.0C, whereby EXIT_FAILURE
is defined to 0, not 1. */
#if !EXIT_FAILURE
# undef EXIT_FAILURE
# define EXIT_FAILURE 1
#endif
#ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
#endif
#define DEBUG 1
#if DEBUG
#define dbg_print(level, s, args...) \
if (opts.debug_level >= level) \
report(stderr, "%s: "s, __func__ , ##args)
#else
#define dbg_print(level, s, args...)
#endif
#define err_exit(fmt, args...) \
report(stderr, "%s: "fmt, program_name, ##args); \
myexit(p_cdio, EXIT_FAILURE)
typedef enum
{
INPUT_AUTO,
INPUT_DEVICE,
INPUT_BIN,
INPUT_CUE,
INPUT_NRG,
INPUT_CDRDAO,
INPUT_UNKNOWN
} source_image_t;
extern char *source_name;
extern char *program_name;
extern cdio_log_handler_t gl_default_cdio_log_handler;
/*! Common error exit routine which frees p_cdio. rc is the
return code to pass to exit.
*/
void myexit(CdIo_t *p_cdio, int rc);
/*! Print our version string */
void print_version (char *psz_program, const char *psz_version,
int no_header, bool version_only);
/*! Device input routine. If successful we return an open CdIo_t
pointer. On error the program exits.
*/
CdIo_t *
open_input(const char *psz_source, source_image_t source_image,
const char *psz_access_mode);
/*! On Unixish OS's we fill out the device name, from a short name.
For example cdrom might become /dev/cdrom.
*/
char *fillout_device_name(const char *device_name);
/*! Prints out SCSI-MMC drive features */
void print_mmc_drive_features(CdIo *p_cdio);
/*! Prints out drive capabilities */
void print_drive_capabilities(cdio_drive_read_cap_t p_read_cap,
cdio_drive_write_cap_t p_write_cap,
cdio_drive_misc_cap_t p_misc_cap);
/*! Common place for output routine. In some environments, like XBOX,
it may not be desireable to send output to stdout and stderr. */
void report (FILE *stream, const char *psz_format, ...);
/* Prints "ls"-like file attributes */
void print_fs_attrs(iso9660_stat_t *p_statbuf, bool b_rock, bool b_xa,
const char *psz_name_untranslated,
const char *psz_name_translated);
#endif /* UTIL_H */