ObjFW  Check-in [a580136c80]

Overview
Comment:Initial import.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | descendants | trunk
Files: files | file ages | folders
SHA3-256: a580136c809759191c7dfeb3bec9000ad21ce9ae19a124c34105c9c683e5b380
User & Date: js on 2008-09-12 13:25:42
Other Links: manifest | tags
Context
2008-09-12
17:56
Fix printf, add missing files. check-in: 958016704c user: js tags: trunk
13:25
Initial import. check-in: a580136c80 user: js tags: trunk
Changes

Added LICENSE version [ae3c272ee8].













































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
			     THE Q PUBLIC LICENSE
				  version 1.0

		   Copyright (C) 1999-2000 Trolltech AS, Norway.
		       Everyone is permitted to copy and
		       distribute this license document.

The intent of this license is to establish freedom to share and change the
software regulated by this license under the open source model.

This license applies to any software containing a notice placed by the
copyright holder saying that it may be distributed under the terms of
the Q Public License version 1.0.  Such software is herein referred to as
the Software.  This license covers modification and distribution of the
Software, use of third-party application programs based on the Software,
and development of free software which uses the Software.

				 Granted Rights

1. You are granted the non-exclusive rights set forth in this license
   provided you agree to and comply with any and all conditions in this
   license.  Whole or partial distribution of the Software, or software
   items that link with the Software, in any form signifies acceptance of
   this license.

2. You may copy and distribute the Software in unmodified form provided
   that the entire package, including - but not restricted to - copyright,
   trademark notices and disclaimers, as released by the initial developer
   of the Software, is distributed.

3. You may make modifications to the Software and distribute your
   modifications, in a form that is separate from the Software, such as
   patches. The following restrictions apply to modifications:

     a. Modifications must not alter or remove any copyright notices in
        the Software.

     b. When modifications to the Software are released under this
        license, a non-exclusive royalty-free right is granted to the
        initial developer of the Software to distribute your modification
        in future versions of the Software provided such versions remain
        available under these terms in addition to any other license(s) of
        the initial developer.

4. You may distribute machine-executable forms of the Software or
   machine-executable forms of modified versions of the Software, provided
   that you meet these restrictions:

     a. You must include this license document in the distribution.

     b. You must ensure that all recipients of the machine-executable forms
        are also able to receive the complete machine-readable source code
        to the distributed Software, including all modifications, without
        any charge beyond the costs of data transfer, and place prominent
        notices in the distribution explaining this.

     c. You must ensure that all modifications included in the
        machine-executable forms are available under the terms of this
        license.

5. You may use the original or modified versions of the Software to
   compile, link and run application programs legally developed by you
   or by others.

6. You may develop application programs, reusable components and other
   software items that link with the original or modified versions of the
   Software.  These items, when distributed, are subject to the following
   requirements:

     a. You must ensure that all recipients of machine-executable forms of
        these items are also able to receive and use the complete
        machine-readable source code to the items without any charge
        beyond the costs of data transfer.

     b. You must explicitly license all recipients of your items to use
        and re-distribute original and modified versions of the items in
        both machine-executable and source code forms. The recipients must
        be able to do so without any charges whatsoever, and they must be
        able to re-distribute to anyone they choose.

     c. If the items are not available to the general public, and the
        initial developer of the Software requests a copy of the items,
        then you must supply one.

			    Limitations of Liability

In no event shall the initial developers or copyright holders be liable
for any damages whatsoever, including - but not restricted to - lost
revenue or profits or other direct, indirect, special, incidental or
consequential damages, even if they have been advised of the possibility
of such damages, except to the extent invariable law, if any, provides
otherwise.

			          No Warranty

The Software and this license document are provided AS IS with NO WARRANTY
OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE.
                                 Choice of Law

This license is governed by the Laws of Norway. Disputes shall be settled
by Oslo City Court.

Added Makefile version [365ae7cf3c].









>
>
>
>
1
2
3
4
SUBDIRS = src tests
DISTCLEAN = autom4te.cache buildsys.mk config.log

include buildsys.mk

Added autogen.sh version [a642be08d3].









>
>
>
>
1
2
3
4
#!/bin/sh
aclocal -I m4 || exit 1
autoconf || exit 1
./configure $@

Added buildsys.mk.in version [3204adcbc4].































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
#
#  Copyright (c) 2007 - 2008, Jonathan Schleifer <js-buildsys@webkeks.org>
#
#  https://webkeks.org/hg/buildsys/
#
#  Permission to use, copy, modify, and/or distribute this software for any
#  purpose with or without fee is hereby granted, provided that the above
#  copyright notice and this permission notice is present in all copies.
#
#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
#  POSSIBILITY OF SUCH DAMAGE.
#

PACKAGE = @PACKAGE@
CC = @CC@
CXX = @CXX@
CPP = @CPP@
DC = @DC@
ERLC = @ERLC@
OBJC = @OBJC@
AR = @AR@
LD = ${CC}
PYTHON = @PYTHON@
CFLAGS = @CFLAGS@
CXXFLAGS = @CXXFLAGS@
CPPFLAGS = @CPPFLAGS@
DFLAGS = @DFLAGS@
ERLCFLAGS = @ERLCFLAGS@
OBJCFLAGS = @OBJCFLAGS@
LDFLAGS = @LDFLAGS@
PYTHON_FLAGS = @PYTHON_FLAGS@
LIBS = @LIBS@
PROG_IMPLIB_NEEDED = @PROG_IMPLIB_NEEDED@
PROG_IMPLIB_LDFLAGS = @PROG_IMPLIB_LDFLAGS@
PROG_SUFFIX = @EXEEXT@
LIB_CPPFLAGS = @LIB_CPPFLAGS@
LIB_CFLAGS = @LIB_CFLAGS@
LIB_LDFLAGS = @LIB_LDFLAGS@
LIB_PREFIX = @LIB_PREFIX@
LIB_SUFFIX = @LIB_SUFFIX@
PLUGIN_CPPFLAGS = @PLUGIN_CPPFLAGS@
PLUGIN_CFLAGS = @PLUGIN_CFLAGS@
PLUGIN_LDFLAGS = @PLUGIN_LDFLAGS@
PLUGIN_SUFFIX = @PLUGIN_SUFFIX@
INSTALL_LIB = @INSTALL_LIB@
UNINSTALL_LIB = @UNINSTALL_LIB@
CLEAN_LIB = @CLEAN_LIB@
LN_S = @LN_S@
MKDIR_P = mkdir -p
INSTALL = install
SHELL = @SHELL@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
plugindir ?= ${libdir}/${PACKAGE}
datarootdir = @datarootdir@
datadir = @datadir@
includedir = @includedir@
includesubdir ?= ${PACKAGE}
mandir = @mandir@
mansubdir ?= man1

OBJS1 = ${SRCS:.c=.o}
OBJS2 = ${OBJS1:.cc=.o}
OBJS3 = ${OBJS2:.cxx=.o}
OBJS4 = ${OBJS3:.d=.o}
OBJS5 = ${OBJS4:.erl=.beam}
OBJS6 = ${OBJS5:.m=.o}
OBJS7 = ${OBJS6:.py=.pyc}
OBJS += ${OBJS7:.xpm=.o}

.SILENT:
.SUFFIXES: .beam .c .cc .cxx .d .dep .erl .m .py .pyc .xpm
.PHONY: all subdirs pre-depend depend install install-extra uninstall uninstall-extra clean distclean

all:
	for i in subdirs depend ${STATIC_LIB} ${STATIC_LIB_NOINST} ${LIB} ${LIB_NOINST} ${PLUGIN} ${PLUGIN_NOINST} ${PROG} ${PROG_NOINST}; do \
		${MAKE} ${MFLAGS} $$i || exit 1; \
	done

subdirs:
	for i in ${SUBDIRS}; do \
		${DIR_ENTER}; \
		${MAKE} ${MFLAGS} || exit 1; \
		${DIR_LEAVE}; \
	done

depend: pre-depend ${SRCS}
	regen=0; \
	deps=""; \
	test -f .deps || regen=1; \
	for i in ${SRCS}; do \
		case $$i in \
			*.o) \
				test $$i -nt .deps && regen=1; \
				deps="$${deps%.o}.dep $$i"; \
				;; \
		esac; \
	done; \
	if test x"$$regen" = x"1" -a x"$$deps" != "x"; then \
		${DEPEND_STATUS}; \
		rm -f .deps; \
		if ${MAKE} ${MFLAGS} $$deps; then \
			cat $$deps >.deps; \
			rm -f $$deps; \
			${DEPEND_OK}; \
		else \
			rm -f .deps $$deps; \
			${DEPEND_FAILED}; \
		fi; \
	fi

.c.dep .cc.dep .cxx.dep .m.dep:
	${CPP} ${CPPFLAGS} -M $< >$@

.d.dep:
.xpm.dep:

pre-depend:

${PROG} ${PROG_NOINST}: ${EXT_DEPS} ${OBJS}
	${LINK_STATUS}
	if ${LD} -o $@ ${OBJS} ${LDFLAGS} ${LIBS}; then \
		${LINK_OK}; \
	else \
		${LINK_FAILED}; \
	fi

${LIB} ${LIB_NOINST}: ${EXT_DEPS} ${OBJS}
	${LINK_STATUS}
	if ${LD} -o $@ ${OBJS} ${LIB_LDFLAGS} ${LDFLAGS} ${LIBS}; then \
		${LINK_OK}; \
	else \
		${LINK_FAILED}; \
	fi

${PLUGIN} ${PLUGIN_NOINST}: ${EXT_DEPS} ${OBJS}
	${LINK_STATUS}
	if ${LD} -o $@ ${OBJS} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}; then \
		${LINK_OK}; \
	else \
		${LINK_FAILED}; \
	fi

${STATIC_LIB} ${STATIC_LIB_NOINST}: ${EXT_DEPS} ${OBJS}
	${LINK_STATUS}
	if ${AR} cr $@ ${OBJS}; then \
		${LINK_OK}; \
	else \
		${LINK_FAILED}; \
	fi

.c.o:
	${COMPILE_STATUS}
	if ${CC} ${CFLAGS} ${CPPFLAGS} -c -o $@ $<; then \
		${COMPILE_OK}; \
	else \
		${COMPILE_FAILED}; \
	fi

.cc.o .cxx.o:
	${COMPILE_STATUS}
	if ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c -o $@ $<; then \
		${COMPILE_OK}; \
	else \
		${COMPILE_FAILED}; \
	fi

.d.o:
	${COMPILE_STATUS}
	if test x"$(basename ${DC})" = x"dmd"; then \
		if ${DC} ${DFLAGS} -c -of$@ $<; then \
			${COMPILE_OK}; \
		else \
			${COMPILE_FAILED}; \
		fi \
	else \
		if ${DC} ${DFLAGS} -c -o $@ $<; then \
			${COMPILE_OK}; \
		else \
			${COMPILE_FAILED}; \
		fi \
	fi

.erl.beam:
	${COMPILE_STATUS}
	if ${ERLC} ${ERLCFLAGS} -o $@ $<; then \
		${COMPILE_OK}; \
	else \
		${COMPILE_FAILED}; \
	fi

.m.o:
	${COMPILE_STATUS}
	if ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c -o $@ $<; then \
		${COMPILE_OK}; \
	else \
		${COMPILE_FAILED}; \
	fi

.py.pyc:
	${COMPILE_STATUS}
	if ${PYTHON} ${PYTHON_FLAGS} -c "import py_compile; py_compile.compile('$<')"; then \
		${COMPILE_OK}; \
	else \
		${COMPILE_FAILED}; \
	fi

.xpm.o:
	${COMPILE_STATUS}
	if ${CC} ${CFLAGS} ${CPPFLAGS} -x c -c -o $@ $<; then \
		${COMPILE_OK}; \
	else \
		${COMPILE_FAILED}; \
	fi

install: ${LIB} ${STATIC_LIB} ${PLUGIN} ${PROG} install-extra
	for i in ${SUBDIRS}; do \
		${DIR_ENTER}; \
		${MAKE} ${MFLAGS} install || exit 1; \
		${DIR_LEAVE}; \
	done

	for i in ${LIB}; do \
		${INSTALL_STATUS}; \
		if ${MKDIR_P} ${DESTDIR}${libdir} && ${INSTALL_LIB}; then \
			${INSTALL_OK}; \
		else \
			${INSTALL_FAILED}; \
		fi \
	done

	for i in ${STATIC_LIB}; do \
		${INSTALL_STATUS}; \
		if ${MKDIR_P} ${DESTDIR}${libdir} && ${INSTALL} -m 644 $$i ${DESTDIR}${libdir}/$$i; then \
			${INSTALL_OK}; \
		else \
			${INSTALL_FAILED}; \
		fi \
	done

	for i in ${PLUGIN}; do \
		${INSTALL_STATUS}; \
		if ${MKDIR_P} ${DESTDIR}${plugindir} && ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i; then \
			${INSTALL_OK}; \
		else \
			${INSTALL_FAILED}; \
		fi \
	done

	for i in ${DATA}; do \
		${INSTALL_STATUS}; \
		if ${MKDIR_P} $$(dirname ${DESTDIR}${datadir}/${PACKAGE}/$$i) && ${INSTALL} -m 644 $$i ${DESTDIR}${datadir}/${PACKAGE}/$$i; then \
			${INSTALL_OK}; \
		else \
			${INSTALL_FAILED}; \
		fi \
	done

	for i in ${PROG}; do \
		${INSTALL_STATUS}; \
		if ${MKDIR_P} ${DESTDIR}${bindir} && ${INSTALL} -m 755 $$i ${DESTDIR}${bindir}/$$i; then \
			${INSTALL_OK}; \
		else \
			${INSTALL_FAILED}; \
		fi \
	done

	for i in ${INCLUDES}; do \
		${INSTALL_STATUS}; \
		if ${MKDIR_P} ${DESTDIR}${includedir}/${includesubdir} && ${INSTALL} -m 644 $$i ${DESTDIR}${includedir}/${includesubdir}/$$i; then \
			${INSTALL_OK}; \
		else \
			${INSTALL_FAILED}; \
		fi \
	done

	for i in ${MAN}; do \
		${INSTALL_STATUS}; \
		if ${MKDIR_P} ${DESTDIR}${mandir}/${mansubdir} && ${INSTALL} -m 644 $$i ${DESTDIR}${mandir}/${mansubdir}/$$i; then \
			${INSTALL_OK}; \
		else \
			${INSTALL_FAILED}; \
		fi \
	done

install-extra:

uninstall: uninstall-extra
	for i in ${SUBDIRS}; do \
		${DIR_ENTER}; \
		${MAKE} ${MFLAGS} uninstall || exit 1; \
		${DIR_LEAVE}; \
	done

	for i in ${LIB}; do \
		if test -f ${DESTDIR}${libdir}/$$i; then \
			if ${UNINSTALL_LIB}; then \
				${DELETE_OK}; \
			else \
				${DELETE_FAILED}; \
			fi \
		fi; \
	done

	for i in ${STATIC_LIB}; do \
		if test -f ${DESTDIR}${libdir}/$$i; then \
			if rm -f ${DESTDIR}${libdir}/$$i; then \
				${DELETE_OK}; \
			else \
				${DELETE_FAILED}; \
			fi \
		fi \
	done

	for i in ${PLUGIN}; do \
		if test -f ${DESTDIR}${plugindir}/$$i; then \
			if rm -f ${DESTDIR}${plugindir}/$$i; then \
				${DELETE_OK}; \
			else \
				${DELETE_FAILED}; \
			fi \
		fi \
	done
	-rmdir ${DESTDIR}${plugindir} >/dev/null 2>&1

	for i in ${DATA}; do \
		if test -f ${DESTDIR}${datadir}/${PACKAGE}/$$i; then \
			if rm -f ${DESTDIR}${datadir}/${PACKAGE}/$$i; then \
				${DELETE_OK}; \
			else \
				${DELETE_FAILED}; \
			fi \
		fi \
	done

	for i in ${PROG}; do \
		if test -f ${DESTDIR}${bindir}/$$i; then \
			if rm -f ${DESTDIR}${bindir}/$$i; then \
				${DELETE_OK}; \
			else \
				${DELETE_FAILED}; \
			fi \
		fi \
	done

	for i in ${INCLUDES}; do \
		if test -f ${DESTDIR}${includedir}/${includesubdir}/$$i; then \
			if rm -f ${DESTDIR}${includedir}/${includesubdir}/$$i; then \
				${DELETE_OK}; \
			else \
				${DELETE_FAILED}; \
			fi \
		fi \
	done
	-rmdir ${DESTDIR}${includedir}/${includesubdir} >/dev/null 2>&1

	for i in ${MAN}; do \
		if test -f ${DESTDIR}${mandir}/${mansubdir}/$$i; then \
			if rm -f ${DESTDIR}${mandir}/${mansubdir}/$$i; then \
				${DELETE_OK}; \
			else \
				${DELETE_FAILED}; \
			fi \
		fi \
	done

uninstall-extra:

clean:
	for i in ${SUBDIRS}; do \
		${DIR_ENTER}; \
		${MAKE} ${MFLAGS} clean || exit 1; \
		${DIR_LEAVE}; \
	done
	
	for i in ${OBJS} ${CLEAN} ${CLEAN_LIB} .deps ${DEPS}; do \
		if test -f $$i -o -d $$i; then \
			if rm -fr $$i; then \
				${DELETE_OK}; \
			else \
				${DELETE_FAILED}; \
			fi \
		fi \
	done

distclean: clean
	for i in ${SUBDIRS}; do \
		${DIR_ENTER}; \
		${MAKE} ${MFLAGS} distclean || exit 1; \
		${DIR_LEAVE}; \
	done
	
	for i in ${PROG} ${PROG_NOINST} ${LIB} ${LIB_NOINST} ${STATIC_LIB} ${STATIC_LIB_NOINST} ${PLUGIN} ${PLUGIN_NOINST} ${DISTCLEAN} *~; do \
		if test -f $$i -o -d $$i; then \
			if rm -fr $$i; then \
				${DELETE_OK}; \
			else \
				${DELETE_FAILED}; \
			fi \
		fi \
	done

DIR_ENTER = printf "\033[K\033[0;36mEntering directory \033[1;36m$$i\033[0;36m.\033[0m\n"; cd $$i || exit 1
DIR_LEAVE = printf "\033[K\033[0;36mLeaving directory \033[1;36m$$i\033[0;36m.\033[0m\n"; cd .. || exit 1
DEPEND_STATUS = printf "\033[K\033[0;33mGenerating dependencies...\033[0m\r"
DEPEND_OK = printf "\033[K\033[0;32mSuccessfully generated dependencies.\033[0m\n"
DEPEND_FAILED = printf "\033[K\033[0;31mFailed to generate dependencies!\033[0m\n"; exit 1
COMPILE_STATUS = printf "\033[K\033[0;33mCompiling \033[1;33m$<\033[0;33m...\033[0m\r"
COMPILE_OK = printf "\033[K\033[0;32mSuccessfully compiled \033[1;32m$<\033[0;32m.\033[0m\n"
COMPILE_FAILED = printf "\033[K\033[0;31mFailed to compile \033[1;31m$<\033[0;31m!\033[0m\n"; exit 1
LINK_STATUS = printf "\033[K\033[0;33mLinking \033[1;33m$@\033[0;33m...\033[0m\r"
LINK_OK = printf "\033[K\033[0;32mSuccessfully linked \033[1;32m$@\033[0;32m.\033[0m\n"
LINK_FAILED = printf "\033[K\033[0;31mFailed to link \033[1;31m$@\033[0;31m!\033[0m\n"; exit 1
INSTALL_STATUS = printf "\033[K\033[0;33mInstalling \033[1;33m$$i\033[0;33m...\033[0m\r"
INSTALL_OK = printf "\033[K\033[0;32mSuccessfully installed \033[1;32m$$i\033[0;32m.\033[0m\n"
INSTALL_FAILED = printf "\033[K\033[0;31mFailed to install \033[1;31m$$i\033[0;31m!\033[0m\n"; exit 1
DELETE_OK = printf "\033[K\033[0;34mDeleted \033[1;34m$$i\033[0;34m.\033[0m\n"
DELETE_FAILED = printf "\033[K\033[0;31mFailed to delete \033[1;31m$$i\033[0;31m!\033[0m\n"; exit 1

-include .deps

Added configure.ac version [06213be73d].













































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
AC_INIT(objfw, 0.1, js-objfw@webkeks.org)
AC_CONFIG_SRCDIR(src)

AC_CANONICAL_HOST
AC_CANONICAL_TARGET

AC_PROG_OBJC
AC_PROG_CPP
AC_PROG_LN_S
AC_PATH_PROG(AR, ar)

case "$CC" in
	gcc | *-gcc | gcc-* | *-gcc-*)
		OBJCFLAGS="$OBJSFLAGS -Wall -Werror -pipe"
		;;
esac

BUILDSYS_SHARED_LIB

AC_SUBST(PACKAGE, objfw)
AC_CONFIG_FILES(buildsys.mk)
AC_OUTPUT

Added m4/buildsys.m4 version [ad17e028ce].













































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
dnl
dnl Copyright (c) 2007 - 2008, Jonathan Schleifer <js-buildsys@webkeks.org>
dnl
dnl https://webkeks.org/hg/buildsys/
dnl
dnl Permission to use, copy, modify, and/or distribute this software for any
dnl purpose with or without fee is hereby granted, provided that the above
dnl copyright notice and this permission notice is present in all copies.
dnl
dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
dnl AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
dnl ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
dnl LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
dnl CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
dnl SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
dnl CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
dnl ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
dnl POSSIBILITY OF SUCH DAMAGE.
dnl

AC_DEFUN([BUILDSYS_PROG_IMPLIB], [
	AC_MSG_CHECKING(whether we need an implib)
	case "$target" in
		*-*-cygwin | *-*-mingw32)
			AC_MSG_RESULT(yes)
			PROG_IMPLIB_NEEDED='yes'
			PROG_IMPLIB_LDFLAGS='-Wl,-export-all-symbols,--out-implib,lib${PROG}.a'
			;;
		*)
			AC_MSG_RESULT(no)
			PROG_IMPLIB_NEEDED='no'
			PROG_IMPLIB_LDFLAGS=''
			;;
	esac
	
	AC_SUBST(PROG_IMPLIB_NEEDED)
	AC_SUBST(PROG_IMPLIB_LDFLAGS)
])

AC_DEFUN([BUILDSYS_SHARED_LIB], [
	AC_MSG_CHECKING(for shared library system)
	case "$target" in
		intel-apple-*)
			AC_MSG_RESULT([Mac OS X (Intel)])
			LIB_CPPFLAGS='-DPIC'
			LIB_CFLAGS='-fPIC'
			LIB_LDFLAGS='-dynamiclib -fPIC -install_name ${libdir}/${LIB}'
			LIB_PREFIX='lib'
			LIB_SUFFIX='.dylib'
			PLUGIN_CPPFLAGS=''
			PLUGIN_CFLAGS=''
			PLUGIN_LDFLAGS='-bundle -fno-common -flat_namespace -undefined suppress'
			PLUGIN_SUFFIX='.impl'
			INSTALL_LIB='${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$$i'
			UNINSTALL_LIB='rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib'
			CLEAN_LIB=''
			;;
		*-apple-*)
			AC_MSG_RESULT(Mac OS X)
			LIB_CPPFLAGS='-DPIC'
			LIB_CFLAGS=''
			LIB_LDFLAGS='-dynamiclib -fPIC -install_name ${libdir}/${LIB}'
			LIB_PREFIX='lib'
			LIB_SUFFIX='.dylib'
			PLUGIN_CPPFLAGS=''
			PLUGIN_CFLAGS=''
			PLUGIN_LDFLAGS='-bundle -fno-common -flat_namespace -undefined suppress'
			PLUGIN_SUFFIX='.impl'
			INSTALL_LIB='${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$$i'
			UNINSTALL_LIB='rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib'
			CLEAN_LIB=''
			;;
		*-*-solaris* | *-openbsd-* | *-mirbsd-*)
			AC_MSG_RESULT(Solaris)
			LIB_CPPFLAGS='-DPIC'
			LIB_CFLAGS='-fPIC'
			LIB_LDFLAGS='-shared -fPIC -Wl,-soname=${LIB}.${LIB_MAJOR}.${LIB_MINOR}'
			LIB_PREFIX='lib'
			LIB_SUFFIX='.so'
			PLUGIN_CPPFLAGS='-DPIC'
			PLUGIN_CFLAGS='-fPIC'
			PLUGIN_LDFLAGS='-shared -fPIC'
			PLUGIN_SUFFIX='.so'
			INSTALL_LIB='${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR} && rm -f ${DESTDIR}${libdir}/$$i && ${LN_S} $$i.${LIB_MAJOR}.${LIB_MINOR} ${DESTDIR}${libdir}/$$i'
			UNINSTALL_LIB='rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}'
			CLEAN_LIB=''
			;;
		*-*-cygwin | *-*-mingw32)
			AC_MSG_RESULT(Win32)
			LIB_CPPFLAGS='-DPIC'
			LIB_CFLAGS=''
			LIB_LDFLAGS='-shared -Wl,--out-implib,${LIB}.a'
			LIB_PREFIX='lib'
			LIB_SUFFIX='.dll'
			PLUGIN_CPPFLAGS=''
			PLUGIN_CFLAGS=''
			PLUGIN_LDFLAGS='-shared'
			PLUGIN_SUFFIX='.dll'
			INSTALL_LIB='${INSTALL} -m 755 $$i ${DESTDIR}${bindir}/$$i && ${INSTALL} -m 755 $$i.a ${DESTDIR}${libdir}/$$i.a'
			UNINSTALL_LIB='rm -f ${DESTDIR}${bindir}/$$i ${DESTDIR}${libdir}/$$i.a'
			CLEAN_LIB='${LIB}.a'
			;;
		*)
			AC_MSG_RESULT(POSIX)
			LIB_CPPFLAGS='-DPIC'
			LIB_CFLAGS='-fPIC'
			LIB_LDFLAGS='-shared -fPIC -Wl,-soname=${LIB}.${LIB_MAJOR}'
			LIB_PREFIX='lib'
			LIB_SUFFIX='.so'
			PLUGIN_CPPFLAGS='-DPIC'
			PLUGIN_CFLAGS='-fPIC'
			PLUGIN_LDFLAGS='-shared -fPIC'
			PLUGIN_SUFFIX='.so'
			INSTALL_LIB='${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0 && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i'
			UNINSTALL_LIB='rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0'
			CLEAN_LIB=''
			;;
	esac

	AC_SUBST(LIB_CPPFLAGS)
	AC_SUBST(LIB_CFLAGS)
	AC_SUBST(LIB_LDFLAGS)
	AC_SUBST(LIB_PREFIX)
	AC_SUBST(LIB_SUFFIX)
	AC_SUBST(PLUGIN_CPPFLAGS)
	AC_SUBST(PLUGIN_CFLAGS)
	AC_SUBST(PLUGIN_LDFLAGS)
	AC_SUBST(PLUGIN_SUFFIX)
	AC_SUBST(INSTALL_LIB)
	AC_SUBST(UNINSTALL_LIB)
	AC_SUBST(CLEAN_LIB)
])

Added src/Makefile version [53919dfb87].







































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
LIB = ${LIB_PREFIX}objfw${LIB_SUFFIX}
LIB_MAJOR = 1
LIB_MINOR = 0

SRCS = OFList.m		\
       OFListObject.m	\
       OFObject.m	\
       OFString.m

OBJCFLAGS += -fPIC -DPIC -fno-nil-recivers -fconstant-string-class=OFConstString
INCLUDES = OFList.h		\
	   OFListObject.h	\
	   OFObject.h		\
	   OFString.h

include ../buildsys.mk

LD = ${OBJC}
LIBS += -lobjc

Added src/OFList.h version [93a96d7531].





























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFObject.h"
#import "OFListObject.h"

@interface OFList: OFObject
{
	OFListObject	*first;
	OFListObject	*last;
}

- init;
- free;
- freeWithData;
- (OFListObject*)first;
- (OFListObject*)last;
- (void)add:(OFListObject*)ptr;
- (void)addNew:(void*)ptr;
@end

/* vim: se syn=objc: */

Added src/OFList.m version [84092951f3].

























































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFList.h"

@implementation OFList
- init
{
	if ((self = [super init])) {
		first = nil;
		last  = nil;
	}
	return self;
}

- free
{
	OFListObject *iter, *next;

	for (iter = first; iter != nil; iter = next) {
		next = [iter next];
		[iter free];
	}

	return [super free];
}

- freeWithData
{
	OFListObject *iter, *next;

	for (iter = first; iter != nil; iter = next) {
		next = [iter next];
		[iter freeWithData];
	}

	first = last = nil;
	return [super free];
}

- (OFListObject*)first
{
	return first;
}

- (OFListObject*)last
{
	return last;
}

- (void)add:(OFListObject*)ptr
{
	if (!first || !last) {
		first = last = ptr;
		return;
	}

	[ptr setPrev:last];
	[last setNext:ptr];

	last = ptr;
}

- (void)addNew:(void*)ptr
{
	return [self add:[OFListObject new:ptr]];
}
@end

Added src/OFListObject.h version [13cfd35f7b].































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFObject.h"

@interface OFListObject: OFObject
{
	void		*data;
	OFListObject	*next;
	OFListObject	*prev;
}

+ new:(void*)ptr;
- init:(void*)ptr;
- freeWithData;
- (void*)data;
- (OFListObject*)next;
- (OFListObject*)prev;
- (void)setNext:(OFListObject*)ptr;
- (void)setPrev:(OFListObject*)ptr;
@end

/* vim: se syn=objc: */

Added src/OFListObject.m version [0141a7e9b7].





























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import <stdlib.h>
#import "OFListObject.h"

@implementation OFListObject
+ new:(void*)ptr
{
	return [[OFListObject alloc] init:ptr];
}

- init:(void*)ptr
{
	if ((self = [super init])) {
		next = nil;
		prev = nil;
		data = ptr;
	}
	return self;
}

- freeWithData
{
	if (data != NULL)
		free(data);
	return [super free];
}

- (void*)data
{
	return data;
}

- (OFListObject*)next
{
	return next;
}

- (OFListObject*)prev
{
	return prev;
}

- (void)setNext:(OFListObject*)ptr
{
	next = ptr;
}

- (void)setPrev:(OFListObject*)ptr
{
	prev = ptr;
}
@end

Added src/OFObject.h version [3d2b1446a8].





























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import <objc/Object.h>

struct __ofobject_allocated_mem {
	void *ptr;
	struct __ofobject_allocated_mem *prev;
	struct __ofobject_allocated_mem *next;
};

@interface OFObject: Object
{
	struct __ofobject_allocated_mem *__mem_pool;
}

- init;
- (void*)getMem:(size_t)size;
- (void*)resizeMem:(void*)ptr toSize:(size_t)size;
- (void)freeMem:(void*)ptr;
- free;
@end

Added src/OFObject.m version [3a6fe1669c].













































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import <stdio.h>
#import <stdlib.h>

#import "OFObject.h"

@implementation OFObject
- init
{
	if ((self = [super init]) != nil)
		__mem_pool  = NULL;
	return self;
}

- (void*)getMem:(size_t)size
{
	struct __ofobject_allocated_mem *iter;

	if ((iter = malloc(sizeof(struct __ofobject_allocated_mem))) == NULL)
		return NULL;

	if ((iter->ptr = malloc(size)) == NULL) {
		free(iter);
		return NULL;
	}

	iter->next = NULL;
	iter->prev = __mem_pool;

	if (__mem_pool != NULL)
		__mem_pool->next = iter;

	__mem_pool = iter;

	return iter->ptr;
}

- (void*)resizeMem:(void*)ptr toSize:(size_t)size
{
	struct __ofobject_allocated_mem *iter;

	for (iter = __mem_pool; iter != NULL; iter = iter->prev) {
		if (iter->ptr == ptr) {
			if ((ptr = realloc(iter->ptr, size)) == NULL)
				return NULL;
			
			iter->ptr = ptr;
			return ptr;
		}
	}

	fprintf(stderr, "WARNING: Memory at %p was not allocated as part of "
	    "object %s!\n", ptr, [self name]);

	return NULL;
}

- (void)freeMem:(void*)ptr;
{
	struct __ofobject_allocated_mem *iter;

	for (iter = __mem_pool; iter != NULL; iter = iter->prev) {
		if (iter->ptr == ptr) {
			if (iter->prev != NULL)
				iter->prev->next = iter->next;
			if (iter->next != NULL)
				iter->next->prev = iter->prev;

			free(iter);
			free(ptr);

			return;
		}
	}

	fprintf(stderr, "WARNING: Memory at %p was not allocated as part of "
	    "object %s!\n", ptr, [self name]);
}

- free
{
	struct __ofobject_allocated_mem *iter, *iter2;

	for (iter = __mem_pool; iter != NULL; iter = iter2) {
		iter2 = iter->prev;
		free(iter->ptr);
		free(iter);
	}

	return [super free];
}
@end

Added src/OFString.h version [ceca91fa6c].

































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import <stddef.h>
#import "OFObject.h"

@interface OFString: OFObject
{
	char	*string;
	size_t	length;
}

+ new:(const char*)str;
- init;
- init:(const char*)str;
- free;
- (char*)cString;
- (size_t)length;
- (void)setTo:(const char*)str;
- (OFString*)clone;
- (void)append:(const char*)str;
@end

/* vim: se syn=objc: */

Added src/OFString.m version [53999e7524].











































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import <stdlib.h>
#import <string.h>
#import "OFString.h"

/* TODO: Use getMem / resizeMem */

@implementation OFString
+ new:(const char*)str
{
	return [[OFString alloc] init:str];
}

- init
{
	return [self init:NULL];
}

- init:(const char*)str
{
	if ((self = [super init])) {
		if (str == NULL) {
			string = NULL;
			length = 0;
		} else {
			string = strdup(str);
			length = strlen(string);
		}
	}
	return self;
}

- free
{
	if (string != NULL)
		free(string);
	return [super free];
}

- (char*)cString
{
	return string;
}

- (size_t)length
{
	return length;
}

- (void)setTo:(const char*)str
{
	if (string != NULL)
		free(string);

	string = strdup(str);
	length = strlen(str);
}

- (OFString*)clone
{
	if (string != NULL)
		return [OFString new:string];
	return [OFString new];
}

- (void)append: (const char*)str
{
	char	*new_string;
	size_t	new_length, str_length;

	if (str == NULL) {
		[self setTo:str];
		return;
	}

	str_length = strlen(str);
	new_length = length + str_length;

	if ((new_string = realloc(string, new_length + 1)) == NULL) {
		/* FIXME: Add error handling */
		return;
	}

	string = new_string;

	memcpy(string + length, str, str_length);
	string[new_length] = '\0';

	length = new_length;
}
@end

Added tests/Makefile version [da5756f9a4].







>
>
>
1
2
3
SUBDIRS = OFString OFList

include ../buildsys.mk

Added tests/OFList/Makefile version [587c8395fe].















>
>
>
>
>
>
>
1
2
3
4
5
6
7
PROG_NOINST = oflist
SRCS = OFList.m

include ../../buildsys.mk

CPPFLAGS += -I../../src
LIBS += -lobjc -L../../src -lobjfw

Added tests/OFList/OFList.m version [031f4c03f0].









































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import <stdio.h>

#import "OFString.h"
#import "OFList.h"
 
int
main()
{
	OFList		*list;
	OFListObject	*iter;

	list = [OFList new];
 
	[list addNew: [OFString new: "First String Object"]];
	[list addNew: [OFString new: "Second String Object"]];
	[list addNew: [OFString new: "Third String Object"]];
 
	for (iter = [list first]; iter != nil; iter = [iter next])
		printf("%s\n", [(OFString*)[iter data] cString]);
 
	[iter free];
	[list free];

	return 0;
}

Added tests/OFString/Makefile version [feeef7b901].















>
>
>
>
>
>
>
1
2
3
4
5
6
7
PROG_NOINST = ofstring
SRCS = OFString.m

include ../../buildsys.mk

CPPFLAGS += -I../../src
LIBS += -lobjc -L../../src -lobjfw

Added tests/OFString/OFString.m version [dbb63bdf83].



























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import <stdio.h>
#import <string.h>

#import "OFString.h"

int
main()
{
	OFString *s1 = [OFString new:"foo"];
	OFString *s2 = [[OFString alloc] init:""];
	OFString *s3;
	OFString *s4 = [OFString new];

	[s2 append:"bar"];
	s3 = [s1 clone];

	[s4 setTo:[s2 cString]];

	printf("s1 = %s\n", [s1 cString]);
	printf("s2 = %s\n", [s2 cString]);
	printf("s3 = %s\n", [s3 cString]);
	printf("s4 = %s\n", [s4 cString]);

	[s1 append: [s2 cString]];
	printf("s1 append s2 = %s\n", [s1 cString]);
	printf("strlen(s1) = %ld, [s1 length] = %ld\n",
	    strlen([s1 cString]), [s1 length]);
	[s1 free];
	[s2 free];
	[s3 free];
	[s4 free];

	return 0;
}