Crossfire Server, Trunk
microtar.h
Go to the documentation of this file.
1 
8 #ifndef MICROTAR_H
9 #define MICROTAR_H
10 
11 #ifdef __cplusplus
12 extern "C"
13 {
14 #endif
15 
16 #include <stdio.h>
17 #include <stdlib.h>
18 
19 #define MTAR_VERSION "0.1.0"
20 
21 enum {
31 };
32 
33 enum {
34  MTAR_TREG = '0',
35  MTAR_TLNK = '1',
36  MTAR_TSYM = '2',
37  MTAR_TCHR = '3',
38  MTAR_TBLK = '4',
39  MTAR_TDIR = '5',
40  MTAR_TFIFO = '6'
41 };
42 
43 typedef struct {
44  unsigned mode;
45  unsigned owner;
46  unsigned size;
47  unsigned mtime;
48  unsigned type;
49  char name[100];
50  char linkname[100];
52 
53 
54 typedef struct mtar_t mtar_t;
55 
56 struct mtar_t {
57  int (*read)(mtar_t *tar, void *data, unsigned size);
58  int (*write)(mtar_t *tar, const void *data, unsigned size);
59  int (*seek)(mtar_t *tar, unsigned pos);
60  int (*close)(mtar_t *tar);
61  void *stream;
62  unsigned pos;
63  unsigned remaining_data;
64  unsigned last_header;
65 };
66 
67 
68 const char* mtar_strerror(int err);
69 
70 int mtar_open(mtar_t *tar, const char *filename, const char *mode);
71 int mtar_close(mtar_t *tar);
72 
73 int mtar_seek(mtar_t *tar, unsigned pos);
74 int mtar_rewind(mtar_t *tar);
75 int mtar_next(mtar_t *tar);
76 int mtar_find(mtar_t *tar, const char *name, mtar_header_t *h);
78 int mtar_read_data(mtar_t *tar, void *ptr, unsigned size);
79 
80 int mtar_write_header(mtar_t *tar, const mtar_header_t *h);
81 int mtar_write_file_header(mtar_t *tar, const char *name, unsigned size);
82 int mtar_write_dir_header(mtar_t *tar, const char *name);
83 int mtar_write_data(mtar_t *tar, const void *data, unsigned size);
84 int mtar_finalize(mtar_t *tar);
85 
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 #endif
mtar_t::close
int(* close)(mtar_t *tar)
Definition: microtar.h:60
mtar_rewind
int mtar_rewind(mtar_t *tar)
Definition: microtar.c:223
mtar_strerror
const char * mtar_strerror(int err)
Definition: microtar.c:140
MTAR_TCHR
@ MTAR_TCHR
Definition: microtar.h:37
MTAR_EFAILURE
@ MTAR_EFAILURE
Definition: microtar.h:23
MTAR_TSYM
@ MTAR_TSYM
Definition: microtar.h:36
mtar_seek
int mtar_seek(mtar_t *tar, unsigned pos)
Definition: microtar.c:216
mtar_read_header
int mtar_read_header(mtar_t *tar, mtar_header_t *h)
Definition: microtar.c:270
mtar_header_t::type
unsigned type
Definition: microtar.h:48
MTAR_EWRITEFAIL
@ MTAR_EWRITEFAIL
Definition: microtar.h:26
mtar_t
Definition: microtar.h:56
mtar_header_t::size
unsigned size
Definition: microtar.h:46
mtar_read_data
int mtar_read_data(mtar_t *tar, void *ptr, unsigned size)
Definition: microtar.c:290
mtar_header_t::mtime
unsigned mtime
Definition: microtar.h:47
npc_dialog.filename
filename
Definition: npc_dialog.py:99
mtar_open
int mtar_open(mtar_t *tar, const char *filename, const char *mode)
Definition: microtar.c:177
mtar_write_file_header
int mtar_write_file_header(mtar_t *tar, const char *name, unsigned size)
Definition: microtar.c:332
MTAR_ENOTFOUND
@ MTAR_ENOTFOUND
Definition: microtar.h:30
mtar_write_header
int mtar_write_header(mtar_t *tar, const mtar_header_t *h)
Definition: microtar.c:323
mtar_next
int mtar_next(mtar_t *tar)
Definition: microtar.c:230
mtar_t::pos
unsigned pos
Definition: microtar.h:62
mtar_write_data
int mtar_write_data(mtar_t *tar, const void *data, unsigned size)
Definition: microtar.c:357
navar-midane_time.data
data
Definition: navar-midane_time.py:11
mtar_find
int mtar_find(mtar_t *tar, const char *name, mtar_header_t *h)
Definition: microtar.c:244
mtar_t::read
int(* read)(mtar_t *tar, void *data, unsigned size)
Definition: microtar.h:57
mtar_t::remaining_data
unsigned remaining_data
Definition: microtar.h:63
mtar_header_t
Definition: microtar.h:43
mtar_t::stream
void * stream
Definition: microtar.h:61
MTAR_TLNK
@ MTAR_TLNK
Definition: microtar.h:35
mtar_header_t::mode
unsigned mode
Definition: microtar.h:44
mtar_t::last_header
unsigned last_header
Definition: microtar.h:64
MTAR_TREG
@ MTAR_TREG
Definition: microtar.h:34
MTAR_EBADCHKSUM
@ MTAR_EBADCHKSUM
Definition: microtar.h:28
mtar_close
int mtar_close(mtar_t *tar)
Definition: microtar.c:211
MTAR_ESUCCESS
@ MTAR_ESUCCESS
Definition: microtar.h:22
MTAR_ESEEKFAIL
@ MTAR_ESEEKFAIL
Definition: microtar.h:27
MTAR_EOPENFAIL
@ MTAR_EOPENFAIL
Definition: microtar.h:24
make_face_from_files.int
int
Definition: make_face_from_files.py:26
MTAR_TDIR
@ MTAR_TDIR
Definition: microtar.h:39
mtar_finalize
int mtar_finalize(mtar_t *tar)
Definition: microtar.c:373
MTAR_EREADFAIL
@ MTAR_EREADFAIL
Definition: microtar.h:25
MTAR_ENULLRECORD
@ MTAR_ENULLRECORD
Definition: microtar.h:29
mtar_header_t::owner
unsigned owner
Definition: microtar.h:45
mtar_write_dir_header
int mtar_write_dir_header(mtar_t *tar, const char *name)
Definition: microtar.c:345
MTAR_TFIFO
@ MTAR_TFIFO
Definition: microtar.h:40
mtar_t::seek
int(* seek)(mtar_t *tar, unsigned pos)
Definition: microtar.h:59
MTAR_TBLK
@ MTAR_TBLK
Definition: microtar.h:38
give.name
name
Definition: give.py:27
mtar_t::write
int(* write)(mtar_t *tar, const void *data, unsigned size)
Definition: microtar.h:58