2003-09-21 04:21:39 +00:00
|
|
|
/*
|
2004-02-07 02:40:20 +00:00
|
|
|
$Id: util.h,v 1.2 2004/02/07 02:40:20 rocky Exp $
|
2003-09-21 04:21:39 +00:00
|
|
|
|
|
|
|
|
Copyright (C) 2003 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>
|
|
|
|
|
#ifdef HAVE_STDLIB_H
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#endif
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
|
|
#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) \
|
|
|
|
|
fprintf(stderr, "%s: "s, __func__ , ##args)
|
|
|
|
|
#else
|
|
|
|
|
#define dbg_print(level, s, args...)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define err_exit(fmt, args...) \
|
|
|
|
|
fprintf(stderr, "%s: "fmt, program_name, ##args); \
|
|
|
|
|
myexit(cdio, EXIT_FAILURE)
|
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
IMAGE_AUTO,
|
|
|
|
|
IMAGE_DEVICE,
|
|
|
|
|
IMAGE_BIN,
|
|
|
|
|
IMAGE_CUE,
|
|
|
|
|
IMAGE_NRG,
|
|
|
|
|
IMAGE_UNKNOWN
|
|
|
|
|
} source_image_t;
|
|
|
|
|
|
|
|
|
|
extern char *source_name;
|
|
|
|
|
extern char *program_name;
|
|
|
|
|
extern cdio_log_handler_t gl_default_cdio_log_handler;
|
|
|
|
|
|
|
|
|
|
void myexit(CdIo *cdio, int rc);
|
|
|
|
|
|
2004-02-07 02:40:20 +00:00
|
|
|
void print_version (char *program_name, const char *version,
|
2003-09-21 04:21:39 +00:00
|
|
|
int no_header, bool version_only);
|
|
|
|
|
|
|
|
|
|
char *fillout_device_name(const char *device_name);
|
|
|
|
|
|
|
|
|
|
#endif /* UTIL_H */
|