]>
git.ipfire.org Git - thirdparty/squid.git/blob - helpers/basic_auth/fake/fake.cc
ecdcf1f4d0acc23ddf469c6dfad17e171974dcbb
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
10 * Copyright (c) 2009-2014, Treehouse Networks Ltd. New Zealand
11 * All rights reserved.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
39 * Fake Basic Authentication program for Squid.
41 * This code gets the user details and returns OK.
42 * It is intended for testing use and as a base for further implementation.
46 #include "helpers/defines.h"
52 * -d enable debugging.
55 char *program_name
= NULL
;
61 "Usage: %s [-d] [-v] [-h]\n"
62 " -d enable debugging.\n"
63 " -h this message\n\n",
68 process_options(int argc
, char *argv
[])
73 while (-1 != (opt
= getopt(argc
, argv
, "hd"))) {
82 fprintf(stderr
, "%s: FATAL: unknown option: -%c. Exiting\n", program_name
, opt
);
90 main(int argc
, char *argv
[])
92 char buf
[HELPER_INPUT_BUFFER
];
98 program_name
= argv
[0];
100 process_options(argc
, argv
);
102 debug("%s build " __DATE__
", " __TIME__
" starting up...\n", program_name
);
104 while (fgets(buf
, HELPER_INPUT_BUFFER
, stdin
) != NULL
) {
107 if ((p
= strchr(buf
, '\n')) != NULL
) {
108 *p
= '\0'; /* strip \n */
109 buflen
= p
- buf
; /* length is known already */
111 buflen
= strlen(buf
); /* keep this so we only scan the buffer for \0 once per loop */
113 debug("Got %d bytes '%s' from Squid\n", buflen
, buf
);
115 /* send 'OK' result back to Squid */
118 debug("%s build " __DATE__
", " __TIME__
" shutting down...\n", program_name
);