1 /*
2     TiMidity++ -- MIDI to WAVE converter and player
3     Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>
4     Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>
5 
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10 
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 
20 
21    common.h
22 */
23 
24 #ifndef ___COMMON_H_
25 #define ___COMMON_H_
26 
27 #include "sysdep.h"
28 #include "url.h"
29 #include "mblock.h"
30 
31 extern char *program_name, current_filename[];
32 extern const char *note_name[];
33 
34 typedef struct {
35   char *path;
36   void *next;
37 } PathList;
38 
39 struct timidity_file
40 {
41     URL url;
42     char *tmpname;
43 };
44 
45 /* Noise modes for open_file */
46 #define OF_SILENT	0
47 #define OF_NORMAL	1
48 #define OF_VERBOSE	2
49 
50 
51 extern void add_to_pathlist(char *s);
52 extern void clean_up_pathlist(void);
53 extern int is_url_prefix(const char *name);
54 extern struct timidity_file *open_file(char *name, int decompress,
55 		int noise_mode);
56 extern struct timidity_file *open_file_r(char *name, int decompress,
57 		int noise_mode);
58 extern struct timidity_file *open_with_mem(char *mem, int32 memlen,
59 		int noise_mode);
60 extern void close_file(struct timidity_file *tf);
61 extern void skip(struct timidity_file *tf, size_t len);
62 extern char *tf_gets(char *buff, int n, struct timidity_file *tf);
63 #define tf_getc(tf) (url_getc((tf)->url))
64 extern long tf_read(void *buff, int32 size, int32 nitems,
65 		    struct timidity_file *tf);
66 extern long tf_seek(struct timidity_file *tf, long offset, int whence);
67 extern long tf_tell(struct timidity_file *tf);
68 extern int int_rand(int n);	/* random [0..n-1] */
69 extern int check_file_extension(char *filename, char *ext, int decompress);
70 
71 extern void *safe_malloc(size_t count);
72 extern void *safe_realloc(void *old_ptr, size_t new_size);
73 extern void *safe_large_malloc(size_t count);
74 extern char *safe_strdup(const char *s);
75 extern void free_ptr_list(void *ptr_list, int count);
76 extern int string_to_7bit_range(const char *s, int *start, int *end);
77 extern char **expand_file_archives(char **files, int *nfiles_in_out);
78 extern void randomize_string_list(char **strlist, int nstr);
79 extern int pathcmp(const char *path1, const char *path2, int ignore_case);
80 extern void sort_pathname(char **files, int nfiles);
81 extern int  load_table(char *file);
82 extern char *pathsep_strrchr(const char *path);
83 extern char *pathsep_strchr(const char *path);
84 extern int str2mID(char *str);
85 
86 
87 /* code:
88  * "EUC"	- Extended Unix Code
89  * NULL		- Auto conversion
90  * "JIS"	- Japanese Industrial Standard code
91  * "SJIS"	- shift-JIS code
92  */
93 extern void code_convert(char *in, char *out, int outsiz,
94 			 char *in_code, char *out_code);
95 
96 extern void safe_exit(int status);
97 
98 extern char *timidity_version;
99 extern MBlockList tmpbuffer;
100 extern char *output_text_code;
101 
102 #endif /* ___COMMON_H_ */
103