/*********************************************************************
This file is used as part of Siworin. Copyright © 2014,2015,2021
by Ruud Harmsen.
Siworin is a simple word indexer and local search engine. See
https://rudhar.com/sfreview/siworin/#siw04 and
https://rudhar.com/sfreview/siworin/toolsrc/siworin .
Siworin is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
Siworin is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Siworin. If not, see .
********************************************************************/
/* Copyright 2014-2015, R.Harmsen. This source file is made available
under the Creative Commons License Attribution-ShareAlike 4.0
International, see http://creativecommons.org/licenses/by-sa/4.0/ .
See also:
http://rudhar.com/lingtics/intrlnga/cgi-grep/derautia.htm and
http://rudhar.com/lingtics/intrlnga/cgi-grep/modempia.htm
for clarifications.
*/
/***********************************************************************
For use with Forms with METHOD=POST. Returns zero when first
displaying the form, when the user did not have a chance to
enter anything yet.
In the other situation, it returns the number of bytes to be read
from stdin, to get the user's encoded input.
**********************************************************************/
int userinput (void);
/***********************************************************************
Translate strings like
"An+equal+sign%3A+%3D%0D%0AA+procent+sign%3A+%25%0D%0A"
into:
"An equal sign: =\r\nA procent sign: %\r\n"
**********************************************************************/
char *decode_cgi_string (char *in);
/***********************************************************************
Compare two multi-line texts, and display only lines that don't
have the same length, one above the other.
**********************************************************************/
int repdiff (char *t1, char *t2);
/***********************************************************************
Input is a string like:
var1=value1&var2=value2
Output is a malloc'ed array of character pointers. Each pair of
pointers points into input, the first of the pair points to
the variable name, the other to the value.
decode_cgi_string is run on the value.
There is an extra pair of pointers which are both NULL, to signal
the end of the array.
In addition, if numvars is not NULL, the integer it points to is
set to the number of pairs (not counting the closing pair).
The function returns a pointer to the first pointer of the returned
array.
Note that delimiters = and & are replaced by null bytes, so Input
must point to writable memory, not a constant string.
**********************************************************************/
char **CgiConvVars (char *Input, int *NumVars);
/***********************************************************************
Same as CgiConvVars, but for a string that contains cookies,
seperated by semicolons (;).
**********************************************************************/
char **CgiConvCookies (char *Input, int *NumVars);
/**************************************************************************
Replace a number of characters, which do not belong in a URL,
with a %-encoding. For example, a plus sign (+) becomes %2B.
After that, any spaces are replaced by plus signs (+).
The contents of string_to_expand remain unchanged.
The function copies that string to a malloc'ed buffer,
and does the expansion in that buffer, resizing as
needed. Eventually it returns a pointer to that
malloc'ed buffer, or NULL in case of error.
*************************************************************************/
char *CgiToolsExpandit (char *string_to_expand);
/**********************************************************************
**********************************************************************/
#include
#define KILLROY \
{time_t now; killroy_log( \
"\nKILLROY %12s line %4d %s", \
__FILE__, __LINE__, ctime((time(&now), &now))); }
void killroy_log (char *format, ...);