File: xmix_io.h

package info (click to toggle)
mdk 1.2.11%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,988 kB
  • sloc: ansic: 22,708; sh: 5,461; lisp: 1,282; lex: 830; makefile: 580; yacc: 288; python: 123
file content (64 lines) | stat: -rw-r--r-- 1,942 bytes parent folder | download | duplicates (5)
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
/* -*-c-*- ------------------ xmix_io.h :
 * Implementation of mix_iochannel_t and mix_file_t
 * ------------------------------------------------------------------
 * Copyright (C) 2000, 2007 Free Software Foundation, Inc.
 *
 * 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */


#ifndef XMIX_IOCHANNEL_H
#define XMIX_IOCHANNEL_H

#include <stdio.h>
#include "mix_io.h"

/* the actual definition of mix_iochannel_t */
struct mix_iochannel_t
{
  FILE *file;
};


extern const char * io_OPENTYPE_[5];

#define fmode_to_type_(mode) ( (mode) < (sizeof(io_OPENTYPE_) / sizeof(io_OPENTYPE_[0])) ? io_OPENTYPE_[(mode)]:NULL )

/* initialisation */
extern gboolean
io_init_from_fdesc_(mix_iochannel_t *ioc, int fdesc);

#define io_init_from_file_(ioc,f) (ioc)->file = f

#define io_close_(ioc)  fclose((ioc)->file)

/* write/read data */
#define write_data_(ioc,data,no)  \
 ( (no) == fwrite((const void*)(data), sizeof(*(data)), (no), (ioc)->file) )

#define read_data_(ioc,data,no)  \
 ( (no) == fread((void*)(data), sizeof(*(data)), (no), (ioc)->file) )

/* state */
#define is_eof_(ioc)  ( feof((ioc)->file) != 0 )
#define is_ready_(ioc) ( ferror((ioc)->file) == 0 )

/* conversions */
#define io_get_FILE_(ioc)  (MIX_IOCHANNEL(ioc))->file


#endif /* XMIX_IOCHANNEL_H */