Previous 15994 Revisions Next

r13274 Wednesday 16th November, 2011 at 08:58:48 UTC by Miodrag Milanović
Removed tools not being used or able to compile for a time (no whatsnew)
[src/mess]tests
[src/mess/tools]dat2html messdocs messtest pile.c pile.h tools.mak
[src/mess/tools/imgtool/windows]pile.c* pile.h* wimgtool.mak

src/mess/tools/pile.h
r13273r13274
1/****************************************************************************
2
3    pile.h
4
5    Utility code to implement "piles"; blocks of data that are built up
6    and then detached
7
8****************************************************************************/
9
10#ifndef PILE_H
11#define PILE_H
12
13#include <stdlib.h>
14#include <stdarg.h>
15
16typedef struct
17{
18   void *ptr;
19   size_t physical_size;
20   size_t logical_size;
21} mess_pile;
22
23void pile_init(mess_pile *pile);
24void pile_delete(mess_pile *pile);
25void pile_clear(mess_pile *pile);
26void *pile_detach(mess_pile *pile);
27int pile_write(mess_pile *pile, const void *ptr, size_t size);
28int pile_writebyte(mess_pile *pile, char byte, size_t size);
29
30INLINE void *pile_getptr(mess_pile *pile)
31{
32   return pile->ptr;
33}
34
35INLINE size_t pile_size(mess_pile *pile)
36{
37   return pile->logical_size;
38}
39
40int pile_vprintf(mess_pile *pile, const char *fmt, va_list args);
41#ifdef __GNUC__
42int pile_printf(mess_pile *pile, const char *fmt, ...)/* ATTR_PRINTF(2,3)*/__attribute__((format(printf, 2, 3)));
43#else
44int pile_printf(mess_pile *pile, const char *fmt, ...)/* ATTR_PRINTF(2,3)*/;
45#endif
46int pile_putc(mess_pile *pile, char c);
47int pile_puts(mess_pile *pile, const char *s);
48
49#endif /* PILE_H */
50
51
src/mess/tools/pile.c
r13273r13274
1/****************************************************************************
2
3    pile.h
4
5    Utility code to implement "piles"; blocks of data that are built up
6    and then detached
7
8****************************************************************************/
9
10#include <string.h>
11#include <stdio.h>
12
13#include "osdcomm.h"
14#include "pile.h"
15
16void pile_init(mess_pile *pile)
17{
18   pile->ptr = NULL;
19   pile->physical_size = 0;
20   pile->logical_size = 0;
21}
22
23
24
25void pile_delete(mess_pile *pile)
26{
27   if (pile->ptr)
28   {
29      free(pile->ptr);
30      pile_init(pile);
31   }
32}
33
34
35
36void pile_clear(mess_pile *pile)
37{
38   pile_delete(pile);
39}
40
41
42
43void *pile_detach(mess_pile *pile)
44{
45   void *ptr;
46
47   ptr = realloc(pile->ptr, pile->logical_size);
48   if (!ptr)
49      ptr = pile->ptr;
50
51   pile_init(pile);
52   return ptr;
53}
54
55
56
57int pile_write(mess_pile *pile, const void *ptr, size_t size)
58{
59   size_t new_logical_size;
60   size_t new_physical_size;
61   size_t blocksize = 4096;
62   char *new_ptr;
63
64   new_logical_size = pile->logical_size + size;
65   if (new_logical_size > pile->physical_size)
66   {
67      new_physical_size = new_logical_size + blocksize;
68      new_physical_size -= new_physical_size % blocksize;
69
70      new_ptr = (char *) realloc(pile->ptr, new_physical_size);
71      if (!new_ptr)
72         return -1;
73
74      pile->ptr = new_ptr;
75      pile->physical_size = new_physical_size;
76   }
77   memcpy(((char *) pile->ptr) + pile->logical_size, ptr, size);
78   pile->logical_size = new_logical_size;
79   return 0;
80}
81
82
83
84int pile_writebyte(mess_pile *pile, char byte, size_t size)
85{
86   int rc = 0;
87
88   while(size--)
89   {
90      rc = pile_write(pile, &byte, 1);
91      if (rc)
92         return rc;
93   }
94   return rc;
95}
96
97
98
99int pile_vprintf(mess_pile *pile, const char *fmt, va_list args)
100{
101   int count;
102   char buf[1024];
103
104   count = vsnprintf(buf, ARRAY_LENGTH(buf), fmt, args);
105   if (pile_write(pile, buf, count * sizeof(*buf)))
106      return 0;
107   return count;
108}
109
110
111
112int pile_printf(mess_pile *pile, const char *fmt, ...)
113{
114   int count;
115   va_list va;
116
117   va_start(va, fmt);
118   count = pile_vprintf(pile, fmt, va);
119   va_end(va);
120   return count;
121}
122
123
124
125int pile_putc(mess_pile *pile, char c)
126{
127   return pile_write(pile, &c, sizeof(c));
128}
129
130
131
132int pile_puts(mess_pile *pile, const char *s)
133{
134   size_t size;
135   size = strlen(s);
136   return pile_write(pile, s, size);
137}
138
139
src/mess/tools/tools.mak
r13273r13274
2727include $(MESSSRC)/tools/floptool/floptool.mak
2828TOOLS += $(FLOPTOOL)
2929
30#ifdef BUILD_MESSTEST
31#include $(MESSSRC)/tools/messtest/messtest.mak
32#TOOLS += $(MESSTEST)
33#endif
34
35ifdef BUILD_DAT2HTML
36include $(MESSSRC)/tools/dat2html/dat2html.mak
37TOOLS += $(DAT2HTML)
38endif
39
4030# include OS-specific MESS stuff
4131# the following expression is true if OSD is windows or winui
4232ifeq ($(OSD),$(filter $(OSD),windows winui))
43include $(MESSSRC)/tools/messdocs/messdocs.mak
4433
4534ifdef BUILD_WIMGTOOL
4635include $(MESSSRC)/tools/imgtool/windows/wimgtool.mak
src/mess/tools/imgtool/windows/pile.h
r0r13274
1/****************************************************************************
2
3    pile.h
4
5    Utility code to implement "piles"; blocks of data that are built up
6    and then detached
7
8****************************************************************************/
9
10#ifndef PILE_H
11#define PILE_H
12
13#include <stdlib.h>
14#include <stdarg.h>
15
16typedef struct
17{
18   void *ptr;
19   size_t physical_size;
20   size_t logical_size;
21} mess_pile;
22
23void pile_init(mess_pile *pile);
24void pile_delete(mess_pile *pile);
25void pile_clear(mess_pile *pile);
26void *pile_detach(mess_pile *pile);
27int pile_write(mess_pile *pile, const void *ptr, size_t size);
28int pile_writebyte(mess_pile *pile, char byte, size_t size);
29
30INLINE void *pile_getptr(mess_pile *pile)
31{
32   return pile->ptr;
33}
34
35INLINE size_t pile_size(mess_pile *pile)
36{
37   return pile->logical_size;
38}
39
40int pile_vprintf(mess_pile *pile, const char *fmt, va_list args);
41#ifdef __GNUC__
42int pile_printf(mess_pile *pile, const char *fmt, ...)/* ATTR_PRINTF(2,3)*/__attribute__((format(printf, 2, 3)));
43#else
44int pile_printf(mess_pile *pile, const char *fmt, ...)/* ATTR_PRINTF(2,3)*/;
45#endif
46int pile_putc(mess_pile *pile, char c);
47int pile_puts(mess_pile *pile, const char *s);
48
49#endif /* PILE_H */
50
51
src/mess/tools/imgtool/windows/wimgtool.mak
r13273r13274
2323OBJDIRS += $(WIMGTOOLOBJ)
2424
2525WIMGTOOL_OBJS = \
26   $(MESS_TOOLS)/pile.o               \
26   $(MESS_TOOLS)/imgtool/windows/pile.o \
2727   $(MESS_TOOLS)/imgtool/windows/opcntrl.o   \
2828   $(MESS_TOOLS)/imgtool/windows/winutils.o   \
2929   $(MESS_TOOLS)/imgtool/windows/wmain.o      \
src/mess/tools/imgtool/windows/pile.c
r0r13274
1/****************************************************************************
2
3    pile.h
4
5    Utility code to implement "piles"; blocks of data that are built up
6    and then detached
7
8****************************************************************************/
9
10#include <string.h>
11#include <stdio.h>
12
13#include "osdcomm.h"
14#include "pile.h"
15
16void pile_init(mess_pile *pile)
17{
18   pile->ptr = NULL;
19   pile->physical_size = 0;
20   pile->logical_size = 0;
21}
22
23
24
25void pile_delete(mess_pile *pile)
26{
27   if (pile->ptr)
28   {
29      free(pile->ptr);
30      pile_init(pile);
31   }
32}
33
34
35
36void pile_clear(mess_pile *pile)
37{
38   pile_delete(pile);
39}
40
41
42
43void *pile_detach(mess_pile *pile)
44{
45   void *ptr;
46
47   ptr = realloc(pile->ptr, pile->logical_size);
48   if (!ptr)
49      ptr = pile->ptr;
50
51   pile_init(pile);
52   return ptr;
53}
54
55
56
57int pile_write(mess_pile *pile, const void *ptr, size_t size)
58{
59   size_t new_logical_size;
60   size_t new_physical_size;
61   size_t blocksize = 4096;
62   char *new_ptr;
63
64   new_logical_size = pile->logical_size + size;
65   if (new_logical_size > pile->physical_size)
66   {
67      new_physical_size = new_logical_size + blocksize;
68      new_physical_size -= new_physical_size % blocksize;
69
70      new_ptr = (char *) realloc(pile->ptr, new_physical_size);
71      if (!new_ptr)
72         return -1;
73
74      pile->ptr = new_ptr;
75      pile->physical_size = new_physical_size;
76   }
77   memcpy(((char *) pile->ptr) + pile->logical_size, ptr, size);
78   pile->logical_size = new_logical_size;
79   return 0;
80}
81
82
83
84int pile_writebyte(mess_pile *pile, char byte, size_t size)
85{
86   int rc = 0;
87
88   while(size--)
89   {
90      rc = pile_write(pile, &byte, 1);
91      if (rc)
92         return rc;
93   }
94   return rc;
95}
96
97
98
99int pile_vprintf(mess_pile *pile, const char *fmt, va_list args)
100{
101   int count;
102   char buf[1024];
103
104   count = vsnprintf(buf, ARRAY_LENGTH(buf), fmt, args);
105   if (pile_write(pile, buf, count * sizeof(*buf)))
106      return 0;
107   return count;
108}
109
110
111
112int pile_printf(mess_pile *pile, const char *fmt, ...)
113{
114   int count;
115   va_list va;
116
117   va_start(va, fmt);
118   count = pile_vprintf(pile, fmt, va);
119   va_end(va);
120   return count;
121}
122
123
124
125int pile_putc(mess_pile *pile, char c)
126{
127   return pile_write(pile, &c, sizeof(c));
128}
129
130
131
132int pile_puts(mess_pile *pile, const char *s)
133{
134   size_t size;
135   size = strlen(s);
136   return pile_write(pile, s, size);
137}
138
139

Previous 15994 Revisions Next


© 1998-2018 The MESS Team