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