]>
git.ipfire.org Git - thirdparty/squid.git/blob - helpers/basic_auth/fake/fake.cc
2 * AUTHOR: Amos Jeffries <squid3@treenet.co.nz>
4 * Fake Basic Authentication program for Squid.
6 * This code gets the user details and returns OK.
7 * It is intended for testing use and as a base for further implementation.
10 * This code is copyright (C) 2009 by Treehouse Networks Ltd
11 * of New Zealand. It is published and Licensed as an extension of
12 * squid under the same conditions as the main squid application.
16 #include "helpers/defines.h"
27 * -d enable debugging.
30 char *program_name
= NULL
;
36 "Usage: %s [-d] [-v] [-h]\n"
37 " -d enable debugging.\n"
38 " -h this message\n\n",
43 process_options(int argc
, char *argv
[])
48 while (-1 != (opt
= getopt(argc
, argv
, "hd"))) {
57 fprintf(stderr
, "%s: FATAL: unknown option: -%c. Exiting\n", program_name
, opt
);
65 main(int argc
, char *argv
[])
67 char buf
[HELPER_INPUT_BUFFER
];
73 program_name
= argv
[0];
75 process_options(argc
, argv
);
77 debug("%s build " __DATE__
", " __TIME__
" starting up...\n", program_name
);
79 while (fgets(buf
, HELPER_INPUT_BUFFER
, stdin
) != NULL
) {
82 if ((p
= strchr(buf
, '\n')) != NULL
) {
83 *p
= '\0'; /* strip \n */
84 buflen
= p
- buf
; /* length is known already */
86 buflen
= strlen(buf
); /* keep this so we only scan the buffer for \0 once per loop */
88 debug("Got %d bytes '%s' from Squid\n", buflen
, buf
);
90 /* send 'OK' result back to Squid */
93 debug("%s build " __DATE__
", " __TIME__
" shutting down...\n", program_name
);