1 /*  format-types.h - format module type definitions
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: format-types.h,v 1.17 2009/03/11 17:18:01 jason Exp $
21  */
22 
23 #ifndef __FORMAT_TYPES_H__
24 #define __FORMAT_TYPES_H__
25 
26 #include <stdio.h>
27 #include "module-types.h"
28 #include "wave.h"
29 
30 #define MAX_CHILD_ARGS 256
31 
32 /* child argument lists */
33 typedef struct _child_args {
34   int num_args;
35   char *args[MAX_CHILD_ARGS];
36 } child_args;
37 
38 typedef struct _format_module {
39   /* set at compile time */
40   char   *const name;                        /* format name, specified on command line in certain modes */
41   char   *const description;                 /* one line description of this format */
42   char   *const cvsid;                       /* CVS revision (used to prevent it from being stripped) */
43   bool    const supports_input;              /* does this format support input? */
44   bool    const supports_output;             /* does this format support output? */
45   bool    const is_translated;               /* is this file format a simple translation (e.g. byte-swap) of WAV? */
46   bool    const is_compressed;               /* is this file format a compression format? */
47   bool    const remove_output_file;          /* remove output file before opening it for output?  (prevents some encoders from complaining that the file already exists) */
48   bool    const kill_when_input_done;        /* kill() decoder when finished reading input?  (prevents delays introduced by decoders that don't exit when we close stdout) */
49   char   *const stdin_for_id3v2_kluge;       /* if not NULL, try to skip id3v2 tags on input files by passing data on decoder's stdin using this as the stdin argument */
50   char   *const magic;                       /* if not NULL, shntool will check for this string at position magic_offset in the input file */
51   int     const magic_offset;                /* offset within the file at which the magic string is expected to occur */
52 
53   /* can be changed at run time */
54   char   *extension;                         /* extension to append to files created by this module */
55   char   *decoder;                           /* name of external program to handle decoding of this format - set to NULL if not applicable */
56   char   *decoder_args;                      /* decoder arguments */
57   char   *encoder;                           /* name of external program to handle encoding of this format - set to NULL if not applicable */
58   char   *encoder_args;                      /* encoder arguments */
59 
60   /* optional functions - set to NULL if not applicable */
61   bool  (*is_our_file)(char *);              /* routine to determine whether the given file belongs to this format plugin */
62   FILE *(*input_func)(char *,proc_info *);   /* routine to open a file of this format for input - if NULL, shntool will launch the decoder */
63   FILE *(*output_func)(char *,proc_info *);  /* routine to open a file of this format for output - if NULL, shntool will launch the encoder */
64   void  (*extra_info)(char *);               /* routine to display extra information in info mode */
65   void  (*create_output_filename)(char *);   /* routine to create a custom output filename */
66   bool  (*input_header_kluge)(unsigned char *,struct _wave_info *);  /* routine to determine correct header info for when decoders are unable to do so themselves */
67 
68   /* internal argument lists (do not assign these in format modules) */
69   child_args input_args_template;           /* input argument template (filled out by shntool, based on default_decoder_args) */
70   child_args input_args;                    /* input arguments, filled out (used by shntool when launching decoder) */
71   child_args output_args_template;          /* output argument template (filled out by shntool, based on default_encoder_args) */
72   child_args output_args;                   /* output arguments, filled out (used by shntool when launching encoder) */
73 } format_module;
74 
75 /* child process types */
76 typedef enum {
77   CHILD_INPUT,
78   CHILD_OUTPUT
79 } child_types;
80 
81 /* closed child process return codes */
82 typedef enum {
83   CLOSE_SUCCESS,
84   CLOSE_CHILD_ERROR_INPUT,
85   CLOSE_CHILD_ERROR_OUTPUT
86 } close_retcodes;
87 
88 #endif
89