Fix: build error when --enable-debug was specified.
Fix: Removed loop control continue in ReadSidMap()
 that could force the parser to skip the first line in SIDMAPv1 format if there was no space or hash tag at the start of the file.
Fix: Forgotten select access for the schema table in the SCHEMA_ACCESS
file.

Thanks to Steve McLaughlin, for picking it up.
2-1.13 Release fixes,

Fix: fixed the presence of snort in a literal warning the users about
     the plugin beeing build without proper database support.

Fix: fixed endianess return value of some error cases in
     int CheckDBVersion(DatabaseData * data)

Esthetic: Rewrote a condition check in dbProcessSignatureInformation(),
          has no impact on evaluation of the if statement.

Fix: compile of spo_alert_fwsam with --enable-debug and --enable-ipv6

Fix: Issue where stream was not completly logged due to a mergeconf
     boolean error

Fix: Add handling for presence of #v1 tag in sid-msg.map file
     (pulledpork swine flu)

Fix: cache lookup (all metadata) could be wrongly interpreted
     due to substring being looked up (either already cached data
     or lookup data). Added a function to return allways the largest
     string lenght, superseed previous incomplete fix applied only for reference.

Bump: build version to 333.
Fix a potential segfault in spo_syslog when p->iph == NULL

Line 1033 tests IPH_IS_VALID(p), i.e. p != NULL. When this fails,
execution jumps to line 1073. Then on lines 1077 and 1093:

if(protocol_names[GET_IPH_PROTO(p)])

GET_IPH_PROTO(p) attempts to dereference p->iph: p->iph->ip_proto

However, it is possible that execution jumped here because p->iph was
NULL, so we need to test p->iph first.
Attempt to handle MySQL lock wait timeouts more gracefully

Log a message and rollback the transaction rather than just erroring out
entirely. This... should? keep everything in a consistent state.
Merge branch 'lock-wait-timeout' into uri
Merge branch 'bug-fix-release' into uri
fix: strtrim did not actually trim
fix: avoid double free in batch mode

When running in batch mode:
- spoolerOpen->RegisterSpooler() sets barnyard2_conf->spooler.
- After batch processing finishes, spoolerClose() free()s the spooler,
  but creates a dangling pointer by not calling UnRegisterSpooler() as
  well. Hitting CTRL+C during batch processing calls
  Barnyard2Cleanup->spoolerClose(), resulting in a double free.
... that annoyed me
cosmetic: because the mixed tab/spaces are driving me insane
lazy synchronize signatures

Previously, the sid-msg.map was synchronized with the database on
startup. This involved selecting every signature from the database (look
this up: did it limit to one per (sid,gid)???), adding it to a cache,
then adding everything in the sid-msg.map not present in the cache to
the database.

When two sensors were started concurrently, duplicate entries were
inserted.

This change makes signature synchronization happen on demand when alerts
are inserted into the database. When an alert is inserted, the database
cache is checked for any cached signatures. If there is a match, the
event is updated with the db_id from the cache...

If there is not a match, we check the database to see if that signature
has been inserted in the database. If it has, we pull that and update
the cache.

If there was not a match, we check the sid-msg.map for a match. If the
sid-msg.map contains a match, then the signature is inserted into the
database and database cache.

If nothing matches, the signature is inserted with the default name of
'Snort Alert [gid:sid:rev]'

This commit completely breaks reference caching, which was also
previously done on startup. This will need to be moved to a function
that Synchronizes a single signature.
remove more signature reference functionality.

... I'll add it back later
replace cacheSignatureObj with a hash table (khash)

cacheSignatureObj previously formed a linked list of dbSignatureObjs.
This replaces the linked list with a hash table using the khash library.
Now cacheSignatureHead is a khash of khashes. cacheSignatureHead uses
gid as the key while the hash tables within cacheSignatureHead use sid
as the key. [This basically forms a multidimensional hash table:
signature = cacheSignatureHead[gid][sid]).
convert bc->sigHead (sig-msg map) into a khash.

sigHead is a khash (key: gid) of khashes (key: sid) of SigNodes.
New types introduced: SidGidMsgMap and SidMsgMap.

The new interfaces automatically enforces uniqueness of the (gid,sid)
tuple. Any duplicates just get overwritten. There are no more brothers.

This involved a lot of fucking changes that I should probably write
about here, but it's late and I'm tired. It has only been tested on
*one* system and it may break output modules that I am not compiling. :D
cosmetic: standarize use of gid,sid,rev,class_id,priority_id
spo_database: reimplement reference insertion

Insert references, reference systems, sig_reference by synchorizing the
various tables only when a new signature is inserted (assumption: any
signature that is already in the database has reference information
present)