libusual.git
15 years agologging: fix die() arg passing
Marko Kreen [Sun, 12 Sep 2010 21:11:10 +0000 (00:11 +0300)]
logging: fix die() arg passing

15 years agodict: small dict type, mainly for urlencode/decode
Marko Kreen [Mon, 9 Aug 2010 22:27:01 +0000 (01:27 +0300)]
dict: small dict type, mainly for urlencode/decode

15 years agocxalloc: customizable allocator framework
Marko Kreen [Fri, 23 Jul 2010 10:06:24 +0000 (13:06 +0300)]
cxalloc: customizable allocator framework

There is a need to sometimes have different allocation policy
to some generic data structure than usual.

Instead of having each of them having allocator abstraction
on their own and both simple and customisable API, lets
have simple generic allocation API.

Initialized will take another CxMem *cx argument, and when
no customization is needed, put USUAL_ALLOC there.

15 years agoevent: remove usage of zmalloc
Marko Kreen [Fri, 23 Jul 2010 10:05:27 +0000 (13:05 +0300)]
event: remove usage of zmalloc

15 years agoaatree: make NIL node const.
Marko Kreen [Sat, 11 Sep 2010 07:44:15 +0000 (10:44 +0300)]
aatree: make NIL node const.

It really should not be modified.

15 years agostring: undef basename, dirname before defining
Marko Kreen [Sat, 11 Sep 2010 07:43:26 +0000 (10:43 +0300)]
string: undef basename, dirname before defining

Helps with testing, otherwise OS defs conflict with ours.

15 years agoDraft tgz generation
Marko Kreen [Fri, 10 Sep 2010 10:26:22 +0000 (13:26 +0300)]
Draft tgz generation

15 years agopgutil: trim the kwlookup code
Marko Kreen [Wed, 8 Sep 2010 17:08:29 +0000 (20:08 +0300)]
pgutil: trim the kwlookup code

No reason to care about unreserved keywords or their exact types.

Only keep the pg_is_reserved_word().

15 years agopgutil: cleaner gperf code
Marko Kreen [Mon, 6 Sep 2010 05:25:43 +0000 (08:25 +0300)]
pgutil: cleaner gperf code

- stop inlining
- remove '#line' directives

15 years agosocket: WSAIoctl was called with wrong params
Marko Kreen [Mon, 6 Sep 2010 05:20:42 +0000 (08:20 +0300)]
socket: WSAIoctl was called with wrong params

15 years agobase: don't define posix_memalign, if it cannot be emulated
Marko Kreen [Mon, 6 Sep 2010 05:19:57 +0000 (08:19 +0300)]
base: don't define posix_memalign, if it cannot be emulated

15 years agoregex: win32 can have STRICT defined
Marko Kreen [Mon, 6 Sep 2010 05:19:14 +0000 (08:19 +0300)]
regex: win32 can have STRICT defined

15 years agotime: win32 can have usleep
Marko Kreen [Mon, 6 Sep 2010 05:17:29 +0000 (08:17 +0300)]
time: win32 can have usleep

15 years agopgsocket: log db errors
Marko Kreen [Fri, 3 Sep 2010 14:05:49 +0000 (17:05 +0300)]
pgsocket: log db errors

also downgrade query logging to noise

15 years agologging: tab-indent multi-line error messages
Marko Kreen [Fri, 3 Sep 2010 14:04:49 +0000 (17:04 +0300)]
logging: tab-indent multi-line error messages

15 years agoevent: fix wrong error code
Marko Kreen [Fri, 3 Sep 2010 14:04:18 +0000 (17:04 +0300)]
event: fix wrong error code

15 years agotest: draft test module for regex
Marko Kreen [Fri, 3 Sep 2010 11:07:38 +0000 (14:07 +0300)]
test: draft test module for regex

15 years agopgutil: include gperf generated code in git.
Marko Kreen [Fri, 3 Sep 2010 10:04:06 +0000 (13:04 +0300)]
pgutil: include gperf generated code in git.

It depends on 8.4+, so users with 8.3 cannot generate it by themselves.

15 years agopgutil: add few missing features to pg_parse_array()
Marko Kreen [Thu, 2 Sep 2010 11:34:53 +0000 (14:34 +0300)]
pgutil: add few missing features to pg_parse_array()

- ignore whitespace around values
- support NULL
- rename to pg_parse_array
- skip dimension definitions
- add regtests

15 years agopgutil: support NULL for quote_literal
Marko Kreen [Thu, 2 Sep 2010 11:28:02 +0000 (14:28 +0300)]
pgutil: support NULL for quote_literal

15 years agostrlist: allow storing NULL
Marko Kreen [Thu, 2 Sep 2010 11:25:16 +0000 (14:25 +0300)]
strlist: allow storing NULL

15 years agopgutil: move common postgres helper functions here.
Marko Kreen [Wed, 1 Sep 2010 14:26:48 +0000 (17:26 +0300)]
pgutil: move common postgres helper functions here.

15 years agologging: exit process in case logfile is not writable.
Marko Kreen [Tue, 31 Aug 2010 08:32:42 +0000 (11:32 +0300)]
logging: exit process in case logfile is not writable.

Otherwise configuration mistakes can be hard to diagnose.

15 years agodaemon: write pidfile twice, to be able to show errors to user
Marko Kreen [Tue, 31 Aug 2010 08:32:10 +0000 (11:32 +0300)]
daemon: write pidfile twice, to be able to show errors to user

15 years agodaemon: signal_pidfile()
Marko Kreen [Mon, 9 Aug 2010 22:17:58 +0000 (01:17 +0300)]
daemon: signal_pidfile()

15 years agosocket: Fix fd_set allocation on win32
Marko Kreen [Mon, 19 Jul 2010 13:52:35 +0000 (16:52 +0300)]
socket: Fix fd_set allocation on win32

15 years agosocket: win32 keepalive defs for mingw32
Marko Kreen [Mon, 19 Jul 2010 13:38:07 +0000 (16:38 +0300)]
socket: win32 keepalive defs for mingw32

15 years agoMove more portability goo over from pgbouncer.
Marko Kreen [Wed, 16 Jun 2010 09:24:32 +0000 (12:24 +0300)]
Move more portability goo over from pgbouncer.

FLEX_ARRAY, __func__, event_loopbreak.

15 years agorename old 'check' target to 'sparse'
Marko Kreen [Tue, 4 May 2010 11:26:35 +0000 (14:26 +0300)]
rename old 'check' target to 'sparse'

15 years agotest: new regtest based on tinytest
Marko Kreen [Fri, 22 Jan 2010 08:35:01 +0000 (10:35 +0200)]
test: new regtest based on tinytest

15 years agoregex: small fallback regex implementation
Marko Kreen [Tue, 6 Oct 2009 21:49:53 +0000 (00:49 +0300)]
regex: small fallback regex implementation

15 years agostrpool: pool for shared strings
Marko Kreen [Sat, 1 May 2010 20:27:39 +0000 (23:27 +0300)]
strpool: pool for shared strings

15 years agobase: sync Assert() with logging changes
Marko Kreen [Fri, 30 Apr 2010 18:55:57 +0000 (21:55 +0300)]
base: sync Assert() with logging changes

15 years agologging: avoid changing errno.
Marko Kreen [Mon, 19 Apr 2010 07:14:58 +0000 (10:14 +0300)]
logging: avoid changing errno.

So user can safely log syscall results without worrying about errno changing.

15 years agoFix warning flags.
Marko Kreen [Sat, 24 Apr 2010 11:53:12 +0000 (14:53 +0300)]
Fix warning flags.

-Wformat=2 should turn an more useful flags.
-Wstrict-overflow is too noisy.  And =1 is already turned on by -Wall.

15 years agoMakefile: check target for sparse checking
Marko Kreen [Mon, 12 Apr 2010 09:16:28 +0000 (12:16 +0300)]
Makefile: check target for sparse checking

15 years agologging: fix signed vs. unsigned cmp warning
Marko Kreen [Mon, 12 Apr 2010 09:14:49 +0000 (12:14 +0300)]
logging: fix signed vs. unsigned cmp warning

15 years agomove <sys/param.h> include into <base.h>
Marko Kreen [Mon, 12 Apr 2010 09:13:00 +0000 (12:13 +0300)]
move <sys/param.h> include into <base.h>

then we can detect system defined macros (ALIGN)

15 years agosocket: remove unneeded logging.h include
Marko Kreen [Mon, 12 Apr 2010 09:10:38 +0000 (12:10 +0300)]
socket: remove unneeded logging.h include

15 years agopgsocket: catch and ignore notices
Marko Kreen [Fri, 9 Apr 2010 13:01:47 +0000 (16:01 +0300)]
pgsocket: catch and ignore notices

default notice handler prints them to stderr, disable it

15 years agologging: customizable prefix, context info
Marko Kreen [Thu, 1 Apr 2010 11:54:18 +0000 (14:54 +0300)]
logging: customizable prefix, context info

15 years agoautoconf: make sure 'restrict' keyword is always available
Marko Kreen [Wed, 31 Mar 2010 12:58:06 +0000 (15:58 +0300)]
autoconf: make sure 'restrict' keyword is always available

15 years agoautoconf: Some gcc versions require AC_PROG_CC_STDC to provide std c.
Marko Kreen [Wed, 31 Mar 2010 12:48:13 +0000 (15:48 +0300)]
autoconf: Some gcc versions require AC_PROG_CC_STDC to provide std c.

In particular 4.1.2, to define __STDC_VERSION__

15 years agoautoconf: separate warning flags from CFLAGS int WFLAGS
Marko Kreen [Wed, 31 Mar 2010 12:02:07 +0000 (15:02 +0300)]
autoconf: separate warning flags from CFLAGS int WFLAGS

this allows easier CFLAGS customization in user program.

15 years agoutf8: fix problems with longer seqs
Marko Kreen [Tue, 30 Mar 2010 09:55:13 +0000 (12:55 +0300)]
utf8: fix problems with longer seqs

15 years agoslab: avoid shared structures in case of threaded program
Marko Kreen [Fri, 19 Mar 2010 13:41:45 +0000 (15:41 +0200)]
slab: avoid shared structures in case of threaded program

- use malloc() for slab headers
- dont keep shared list if _REENTRANT is defined

15 years agocfparser: sync with load_file() change
Marko Kreen [Fri, 19 Mar 2010 13:39:14 +0000 (15:39 +0200)]
cfparser: sync with load_file() change

15 years agofileutil: optional size argument to load_file()
Marko Kreen [Mon, 15 Mar 2010 17:00:33 +0000 (19:00 +0200)]
fileutil: optional size argument to load_file()

15 years agopgsocket: allow to detect whether waiting for send or receive
Marko Kreen [Wed, 3 Mar 2010 12:07:08 +0000 (14:07 +0200)]
pgsocket: allow to detect whether waiting for send or receive

15 years agobase: ARRAY_NELEM() macro for static arrays
Marko Kreen [Mon, 21 Dec 2009 13:06:53 +0000 (15:06 +0200)]
base: ARRAY_NELEM() macro for static arrays

15 years agoaatree: add 'const' to aatree_is_nil_node()
Marko Kreen [Wed, 3 Mar 2010 07:03:30 +0000 (09:03 +0200)]
aatree: add 'const' to aatree_is_nil_node()

15 years agostring: few improvements
Marko Kreen [Wed, 3 Mar 2010 06:49:45 +0000 (08:49 +0200)]
string: few improvements

- new functions: memrchr, dirname

- dirname, basename: return either user path or static buffer,
  never modify user buffer.

- strerror_r: always define our own version, to avoid problems
  it system def changes (_GNU_SOURCE)

15 years agostring: fls fixes
Marko Kreen [Wed, 27 Jan 2010 17:56:00 +0000 (18:56 +0100)]
string: fls fixes

- need to check for 0 also for optimized case
- wrong ifdef for flsll
- no need for temp var in inline function

15 years agobase: compat posix_memalign()
Marko Kreen [Tue, 2 Mar 2010 14:43:40 +0000 (16:43 +0200)]
base: compat posix_memalign()

15 years agosocket: socket_keepalive()
Marko Kreen [Tue, 2 Mar 2010 14:37:37 +0000 (16:37 +0200)]
socket: socket_keepalive()

15 years agolist: sort() function
Marko Kreen [Mon, 25 Jan 2010 22:11:25 +0000 (00:11 +0200)]
list: sort() function

15 years agoslab: bypass slab logic
Marko Kreen [Tue, 2 Mar 2010 12:16:54 +0000 (12:16 +0000)]
slab: bypass slab logic

15 years agomempool: avoid read from freed area
Marko Kreen [Tue, 2 Mar 2010 12:15:02 +0000 (12:15 +0000)]
mempool: avoid read from freed area

15 years agopgsocket: cleanups, make reconnect actually connect
Marko Kreen [Sun, 27 Dec 2009 10:40:40 +0000 (12:40 +0200)]
pgsocket: cleanups, make reconnect actually connect

15 years agocbtree: add walker function
Marko Kreen [Sun, 27 Dec 2009 10:40:12 +0000 (12:40 +0200)]
cbtree: add walker function

15 years agoMakefile: drop hardwired warning flags, configure sets them itself
Marko Kreen [Wed, 13 Jan 2010 08:06:12 +0000 (10:06 +0200)]
Makefile: drop hardwired warning flags, configure sets them itself

15 years agostring: proper posix basename()
Marko Kreen [Wed, 13 Jan 2010 08:02:55 +0000 (10:02 +0200)]
string: proper posix basename()

also include <libgen.h> automatically

the posixness can be done 2 ways:
1. static buffer
2. modify arg

here is 2. used, as user code needs to deal with it anyway.

15 years agostatlist: put_before/put_after functions
Marko Kreen [Wed, 13 Jan 2010 08:02:13 +0000 (10:02 +0200)]
statlist: put_before/put_after functions

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