www: utils: Re-work array query variable handling
www: utils: Re-work array query variable handling

The functions add_avar and add_multipart_avar are for dealing with
POST/GET variables of the form avarN[name]=value see docs/post_get.

Previously these functions took a finalize parameter that was set to 0
when adding variables then a final call with it set to 1 to have the
hash table of variable/value pairs added to the avars GList. The main
reason for this was there was no way to know when we'd finished adding a
set of related variables to the hash table to then add to the GList.

These functions have been re-worked to make use of a simplified versions
of GQuarks to associate variable index's with an integer value that can
be used as an index into the avars GList, we can then use this index to
pull out the hash table for a particular array variable and amend it
with more values. Or create a new hash table and add it to the GList at
the same time.

The reason why we don't use GQuarks is that they seem to have some
global state that can't be cleared, it needs to be reset on each new
request. It also seemed to be starting at 51 for some reason.

This negates the need to call these functions an extra time with the
finalize paramerter set to 1. It will also now handle cases where the
array variables may be out of order. e.g previously

    avar0[colour]=blue
    avar0[code]=0000ff
    avar1[colour]=red
    avar2[color]=green
    avar1[code]=ff0000
    avar2[code]=00ff00

would have resulted in 5 GHashTables being created (avar0, avar1, avar2,
avar1, avar2) and added to the avars GList instead of the correct 3
(avar0, avar1, avar2). The new code will handle this and ensure
everything is correctly grouped together.

Signed-off-by: Andrew Clayton <02e0a999c50b1f88df7a8f5a04e1b76b35ea6a88@digital-domain.net>

ac000/receiptomatic