libusual.git
15 years agosocket: define INADDR_NONE
Marko Kreen [Wed, 13 Jan 2010 08:01:12 +0000 (10:01 +0200)]
socket: define INADDR_NONE

15 years agosocket: fix socket_setup() compat case
Marko Kreen [Wed, 13 Jan 2010 07:59:47 +0000 (09:59 +0200)]
socket: fix socket_setup() compat case

ifndef SO_NOSIGPIPE was broken

15 years agombuf: additional functions
Marko Kreen [Wed, 13 Jan 2010 07:58:05 +0000 (09:58 +0200)]
mbuf: additional functions

- mbuf_get_char
- mbuf_get_chars

same as _byte/_bytes but for char type

- mbuf_get_uint64be
- mbuf_slice
- mbuf_copy

15 years agofileutil.c: include string.h which is needed by compat getline
Marko Kreen [Wed, 13 Jan 2010 07:56:41 +0000 (09:56 +0200)]
fileutil.c: include string.h which is needed by compat getline

15 years agoerr: avoid defining progname if OS provides setprogname
Marko Kreen [Wed, 13 Jan 2010 07:55:54 +0000 (09:55 +0200)]
err: avoid defining progname if OS provides setprogname

15 years agobase: include stdio.h and inttypes.h
Marko Kreen [Wed, 13 Jan 2010 07:54:48 +0000 (09:54 +0200)]
base: include stdio.h and inttypes.h

stdio for s*printf*
inttypes for int fmts for printf

15 years agomempool: simple memory pool
Marko Kreen [Mon, 21 Dec 2009 10:58:31 +0000 (12:58 +0200)]
mempool: simple memory pool

Targeted at related variable-sized allocations,
to be freed all together.

Simple variant of gnu's obstack.

15 years agocbtree: support custom allocator, fix insert bug
Marko Kreen [Mon, 21 Dec 2009 10:58:52 +0000 (12:58 +0200)]
cbtree: support custom allocator, fix insert bug

15 years agohashtab: allow override max fill
Marko Kreen [Tue, 8 Dec 2009 12:02:27 +0000 (14:02 +0200)]
hashtab: allow override max fill

15 years agostring: strlist_append_ref() to avoid strdup(), constify _foreach
Marko Kreen [Fri, 23 Oct 2009 09:13:17 +0000 (12:13 +0300)]
string: strlist_append_ref() to avoid strdup(), constify _foreach

15 years agoslab: clarify init func input, make _destroy() accept NULL
Marko Kreen [Fri, 23 Oct 2009 09:11:57 +0000 (12:11 +0300)]
slab: clarify init func input, make _destroy() accept NULL

15 years agombuf: cmp funcs, make free() zero-fill
Marko Kreen [Fri, 23 Oct 2009 09:11:03 +0000 (12:11 +0300)]
mbuf: cmp funcs, make free() zero-fill

15 years agoutf8: api cleanup
Marko Kreen [Wed, 30 Sep 2009 12:07:34 +0000 (15:07 +0300)]
utf8: api cleanup

15 years agombuf: mbuf_cut() function
Marko Kreen [Thu, 24 Sep 2009 09:59:45 +0000 (12:59 +0300)]
mbuf: mbuf_cut() function

15 years agolist: list_last() function
Marko Kreen [Thu, 24 Sep 2009 09:59:07 +0000 (12:59 +0300)]
list: list_last() function

15 years agohashtab: constify some pointers
Marko Kreen [Thu, 24 Sep 2009 09:58:37 +0000 (12:58 +0300)]
hashtab: constify some pointers

15 years agocbtree: instead C-strings, use key + length
Marko Kreen [Thu, 24 Sep 2009 09:56:43 +0000 (12:56 +0300)]
cbtree: instead C-strings, use key + length

This allows to be more flexible on what data to use as key.

15 years agopgsocket: handle freeing PGresult
Marko Kreen [Sat, 5 Dec 2009 16:18:29 +0000 (18:18 +0200)]
pgsocket: handle freeing PGresult

this makes life easier in user callback.

16 years agobase: add few macros
Marko Kreen [Wed, 9 Sep 2009 19:08:10 +0000 (22:08 +0300)]
base: add few macros

STR - usual CPP stringifing

DLLEXPORT,DLLIMPORT for dlls on win32

16 years agoerr: more std behaviour, set/getprogname
Marko Kreen [Wed, 9 Sep 2009 19:06:37 +0000 (22:06 +0300)]
err: more std behaviour, set/getprogname

16 years agoFix strerror_r on win32
Marko Kreen [Wed, 9 Sep 2009 18:44:00 +0000 (21:44 +0300)]
Fix strerror_r on win32

16 years agodlerror should not use errno
Marko Kreen [Wed, 9 Sep 2009 18:42:21 +0000 (21:42 +0300)]
dlerror should not use errno

16 years agowin32: dlopen v1
Marko Kreen [Wed, 9 Sep 2009 18:20:05 +0000 (21:20 +0300)]
win32: dlopen v1

16 years agoconfigure: check for libevent
Marko Kreen [Wed, 9 Sep 2009 18:03:51 +0000 (21:03 +0300)]
configure: check for libevent

16 years agousual.m4: move port defines to config.h
Marko Kreen [Wed, 9 Sep 2009 17:54:19 +0000 (20:54 +0300)]
usual.m4: move port defines to config.h

16 years agoAC_GNU_SOURCE is broken, define _GNU_SOURCE unconditionally
Marko Kreen [Wed, 9 Sep 2009 17:34:59 +0000 (20:34 +0300)]
AC_GNU_SOURCE is broken, define _GNU_SOURCE unconditionally

16 years agousual.m4: fix localtime_r typo
Marko Kreen [Wed, 2 Sep 2009 18:03:46 +0000 (21:03 +0300)]
usual.m4: fix localtime_r typo

16 years agodefine rol/ror, remove duplicate code in md5/sha1
Marko Kreen [Wed, 2 Sep 2009 17:09:17 +0000 (20:09 +0300)]
define rol/ror, remove duplicate code in md5/sha1

16 years agoinclude few experimental modules.
Marko Kreen [Wed, 2 Sep 2009 15:10:21 +0000 (18:10 +0300)]
include few experimental modules.

crc32        - as the name says
sha1         - as the name says
endian       - standardise endianess macros
hashtab-impl - inline hash table
shlist       - list in shared mem
utf8         - low-level utf8 support
misc         - random unclassified stuff
pgsocket     - async postgres connection

They are "experimental" in the sense that their APIs,
layout and usefulness is uncertain.

16 years agoMakefile: asm targets for debugging
Marko Kreen [Wed, 2 Sep 2009 16:15:35 +0000 (19:15 +0300)]
Makefile: asm targets for debugging

16 years agoerr,logging,safeio: use strerror_r()
Marko Kreen [Wed, 2 Sep 2009 14:28:48 +0000 (17:28 +0300)]
err,logging,safeio: use strerror_r()

16 years agosafeio: remove unnecessary includes
Marko Kreen [Wed, 2 Sep 2009 14:25:11 +0000 (17:25 +0300)]
safeio: remove unnecessary includes

16 years agopthread: minimal compat for win32
Marko Kreen [Wed, 2 Sep 2009 13:45:32 +0000 (16:45 +0300)]
pthread: minimal compat for win32

16 years agoerr module
Marko Kreen [Wed, 2 Sep 2009 13:38:45 +0000 (16:38 +0300)]
err module

Wrapper and compat around <err.h>, also provides non-failing
xmalloc, xrealloc, xstrdup.

16 years agoReorg of compat code.
Marko Kreen [Wed, 2 Sep 2009 12:19:05 +0000 (15:19 +0300)]
Reorg of compat code.

Instead if usual/compat.[ch] and usual/win32.h, the compat code is
now merged with 'theme' modules:

  <usual/base.h>
  <usual/fileutil.h>
  <usual/signal.h>
  <usual/socket.h>
  <usual/string.h>
  <usual/time.h>

New 'theme include' concept mean those include bunch of related
system includes, provide compat funtions for missing system
functionality in addition to providing new APIs.

End result should be that user code does not need have several
'#ifdef HAVE..H' around system includes, instead it can just
include theme include to get all related functionality.

16 years agocfparser: allow * section that matches any name
Marko Kreen [Wed, 2 Sep 2009 12:18:30 +0000 (15:18 +0300)]
cfparser: allow * section that matches any name

16 years agoevent: allow use of real libevent
Marko Kreen [Wed, 2 Sep 2009 12:03:40 +0000 (15:03 +0300)]
event: allow use of real libevent

16 years agoheap: instead macro, use inline for elem comparision
Marko Kreen [Wed, 2 Sep 2009 12:02:42 +0000 (15:02 +0300)]
heap: instead macro, use inline for elem comparision

16 years agousual.m4: detect real libevent
Marko Kreen [Wed, 2 Sep 2009 12:00:47 +0000 (15:00 +0300)]
usual.m4: detect real libevent

16 years agofind_modules: automatic detection of used modules.
Marko Kreen [Wed, 2 Sep 2009 09:14:55 +0000 (12:14 +0300)]
find_modules: automatic detection of used modules.

It's a shell script to parse out used libusual modules
from user source files.  So instead:

  USUAL_DIR =
  USUAL_MODULES =

user can do

  USUAL_DIR =
  USUAL_LOCAL_SRCS =

where USUAL_LOCAL_SRCS contains source files, both .c and .h,
that include libusual files.  Then Setup.mk will launch find_modules
to get actually used list of modules.

16 years agosocket: Undefined variable when setting SO_NOSIGPIPE
Marko Kreen [Thu, 27 Aug 2009 08:19:43 +0000 (11:19 +0300)]
socket: Undefined variable when setting SO_NOSIGPIPE

Reshuffle code to have val defined only when SO_NOSIGPIPE
is available.

Reported-by: Khee Chin
16 years agoAdapt compat.c to newer debian sid glibc, per comment from Marko
Dimitri Fontaine [Wed, 8 Jul 2009 14:55:52 +0000 (16:55 +0200)]
Adapt compat.c to newer debian sid glibc, per comment from Marko

16 years agostring: strlist, parse_word_list
Marko Kreen [Wed, 13 May 2009 11:51:43 +0000 (14:51 +0300)]
string: strlist, parse_word_list

16 years agombuf: memory buffer
Marko Kreen [Wed, 15 Apr 2009 07:48:12 +0000 (10:48 +0300)]
mbuf: memory buffer

16 years agobase: unused, noinline attribs
Marko Kreen [Mon, 20 Apr 2009 03:56:21 +0000 (06:56 +0300)]
base: unused, noinline attribs

16 years agoevent: disable signals when executing handler
Marko Kreen [Mon, 20 Apr 2009 03:53:31 +0000 (06:53 +0300)]
event: disable signals when executing handler

16 years agocfparser: allow both abs and relative pointers
Marko Kreen [Sun, 19 Apr 2009 08:39:35 +0000 (11:39 +0300)]
cfparser: allow both abs and relative pointers

16 years agoPrepare libusual for pgbouncer: autoconf/win32
Marko Kreen [Sat, 18 Apr 2009 22:02:51 +0000 (01:02 +0300)]
Prepare libusual for pgbouncer: autoconf/win32

- Generate usual/config.h via autoconf.
- m4/usual.m4 for common autoconf macros
- include base.h in all headers
- base.h includes config.h
- Import win32 compat from pgbouncer: usual/compat.[ch] + usual/win32.h
- time.[ch] uses usec_t instead of timeval now
- md5 detects endianess via AC_BIGENDIAN
- Include <usual/compat.h> where needed.

16 years agoevent: use new heap
Marko Kreen [Wed, 15 Apr 2009 16:10:55 +0000 (19:10 +0300)]
event: use new heap

Heap is better structure for keeping track of timeouts than tree.

16 years agoheap: small binary heap implementation
Marko Kreen [Wed, 15 Apr 2009 12:43:11 +0000 (15:43 +0300)]
heap: small binary heap implementation

Useful for keeping track of timeouts.

16 years agoevent: simplify timeout handling by using usec_t internally
Marko Kreen [Tue, 14 Apr 2009 21:52:40 +0000 (00:52 +0300)]
event: simplify timeout handling by using usec_t internally

Using usec_t for internal timeout handling gets rid of
lot of complex code for managing 'struct timeval'.

Also use per-base cached time to get rid of useless
gettimeofday() calls.

16 years agoevent: Cleanups and more comments
Marko Kreen [Tue, 14 Apr 2009 20:59:40 +0000 (23:59 +0300)]
event: Cleanups and more comments

- more comments
- event_add: dont allow flags=0 and no timeout
- signal callback: dont do sig_close() there on random errors,
  seems too dangerous.
- signal callback: just in case, drain the socket in loop

16 years agocomplain once when unable to open log file.
Martin Pihlak [Tue, 14 Apr 2009 11:58:43 +0000 (14:58 +0300)]
complain once when unable to open log file.

16 years agofileutil: missing stdlib.h include
Marko Kreen [Mon, 13 Apr 2009 11:25:23 +0000 (14:25 +0300)]
fileutil: missing stdlib.h include

It was not needed when debugging as base.h
includes it then.

16 years agoYet another utility library
Marko Kreen [Mon, 13 Apr 2009 09:59:18 +0000 (12:59 +0300)]
Yet another utility library