Permalink
Browse files

WIN32/Cygwin fixes by Guido

- Better GetOSVersion function, more squid "aware", added support for
Windows XP and future Windows versions.
- Added trap in WIN32_Subsystem_Init() for unknown or unsupported (WIN32s)
Windows version.
- Fixed compile warning in comm.c
- Changed exit() WIN32 hook, now less intrusive

And some ident fixes
  • Loading branch information...
1 parent 57e470e commit abc6aaf5da925e90fcd00723d39edd6e024ae4d3 @hno hno committed Aug 16, 2001
@@ -11,7 +11,7 @@
* National Research Council
*
* Usage: squid_ldap_auth -b basedn [-s searchscope]
- * [-f searchfilter] [-D binddn -w bindpasswd]
+ * [-f searchfilter] [-D binddn -w bindpasswd]
* [-u attr] [-p] [-R] <ldap_server_name>
*
* Dependencies: You need to get the OpenLDAP libraries
@@ -25,7 +25,7 @@
* Changes:
* 2001-05-02: Henrik Nordstrom <hno@squid-cache.org>
* - Support newer OpenLDAP 2.x libraries using the
- * revised Internet Draft API which unfortunately
+ * revised Internet Draft API which unfortunately
* is not backwards compatible with RFC1823..
* 2001-04-15: Henrik Nordstrom <hno@squid-cache.org>
* - Added command line option for basedn
@@ -64,31 +64,38 @@ static int checkLDAP(LDAP * ld, char *userid, char *password);
/* Yuck.. we need to glue to different versions of the API */
#if defined(LDAP_API_VERSION) && LDAP_API_VERSION > 1823
-static int squid_ldap_errno(LDAP *ld)
+static int
+squid_ldap_errno(LDAP * ld)
{
int err = 0;
ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &err);
return err;
}
-static void squid_ldap_set_aliasderef(LDAP *ld, int deref)
+static void
+squid_ldap_set_aliasderef(LDAP * ld, int deref)
{
ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
}
-static void squid_ldap_set_referrals(LDAP *ld, int referrals)
+static void
+squid_ldap_set_referrals(LDAP * ld, int referrals)
{
int *value = referrals ? LDAP_OPT_ON : LDAP_OPT_OFF;
ldap_set_option(ld, LDAP_OPT_REFERRALS, value);
}
+
#else
-static int squid_ldap_errno(LDAP *ld)
+static int
+squid_ldap_errno(LDAP * ld)
{
return ld->ld_errno;
}
-static void squid_ldap_set_aliasderef(LDAP *ld, int deref)
+static void
+squid_ldap_set_aliasderef(LDAP * ld, int deref)
{
ld->ld_deref = deref;
}
-static void squid_ldap_set_referrals(LDAP *ld, int referrals)
+static void
+squid_ldap_set_referrals(LDAP * ld, int referrals)
{
if (referrals)
ld->ld_options |= ~LDAP_OPT_REFERRALS;
@@ -111,13 +118,13 @@ main(int argc, char **argv)
while (argc > 2 && argv[1][0] == '-') {
char *value = "";
char option = argv[1][1];
- switch(option) {
+ switch (option) {
case 'p':
case 'R':
break;
default:
if (strlen(argv[1]) > 2) {
- value = argv[1]+2;
+ value = argv[1] + 2;
} else {
value = argv[2];
argv++;
@@ -127,57 +134,57 @@ main(int argc, char **argv)
}
argv++;
argc--;
- switch(option) {
+ switch (option) {
case 'b':
- basedn = value;
- break;
+ basedn = value;
+ break;
case 'f':
- searchfilter = value;
- break;
+ searchfilter = value;
+ break;
case 'u':
- userattr = value;
- break;
+ userattr = value;
+ break;
case 's':
- if (strcmp(value, "base") == 0)
- searchscope = LDAP_SCOPE_BASE;
- else if (strcmp(value, "one") == 0)
- searchscope = LDAP_SCOPE_ONELEVEL;
- else if (strcmp(value, "sub") == 0)
- searchscope = LDAP_SCOPE_SUBTREE;
- else {
- fprintf(stderr, "squid_ldap_auth: ERROR: Unknown search scope '%s'\n", value);
- exit(1);
- }
- break;
+ if (strcmp(value, "base") == 0)
+ searchscope = LDAP_SCOPE_BASE;
+ else if (strcmp(value, "one") == 0)
+ searchscope = LDAP_SCOPE_ONELEVEL;
+ else if (strcmp(value, "sub") == 0)
+ searchscope = LDAP_SCOPE_SUBTREE;
+ else {
+ fprintf(stderr, "squid_ldap_auth: ERROR: Unknown search scope '%s'\n", value);
+ exit(1);
+ }
+ break;
case 'a':
- if (strcmp(value, "never") == 0)
- aliasderef = LDAP_DEREF_NEVER;
- else if (strcmp(value, "always") == 0)
- aliasderef = LDAP_DEREF_ALWAYS;
- else if (strcmp(value, "search") == 0)
- aliasderef = LDAP_DEREF_SEARCHING;
- else if (strcmp(value, "find") == 0)
- aliasderef = LDAP_DEREF_FINDING;
- else {
- fprintf(stderr, "squid_ldap_auth: ERROR: Unknown alias dereference method '%s'\n", value);
- exit(1);
- }
- break;
+ if (strcmp(value, "never") == 0)
+ aliasderef = LDAP_DEREF_NEVER;
+ else if (strcmp(value, "always") == 0)
+ aliasderef = LDAP_DEREF_ALWAYS;
+ else if (strcmp(value, "search") == 0)
+ aliasderef = LDAP_DEREF_SEARCHING;
+ else if (strcmp(value, "find") == 0)
+ aliasderef = LDAP_DEREF_FINDING;
+ else {
+ fprintf(stderr, "squid_ldap_auth: ERROR: Unknown alias dereference method '%s'\n", value);
+ exit(1);
+ }
+ break;
case 'D':
- binddn = value;
- break;
+ binddn = value;
+ break;
case 'w':
- bindpasswd = value;
- break;
+ bindpasswd = value;
+ break;
case 'p':
- persistent = !persistent;
- break;
+ persistent = !persistent;
+ break;
case 'R':
- noreferrals = !noreferrals;
- break;
+ noreferrals = !noreferrals;
+ break;
default:
- fprintf(stderr, "squid_ldap_auth: ERROR: Unknown command line option '%c'\n", option);
- exit(1);
+ fprintf(stderr, "squid_ldap_auth: ERROR: Unknown command line option '%c'\n", option);
+ exit(1);
}
}
@@ -212,7 +219,7 @@ main(int argc, char **argv)
}
*passwd++ = '\0'; /* Cut in username,password */
tryagain = 1;
-recover:
+ recover:
if (ld == NULL) {
if ((ld = ldap_init(ldapServer, LDAP_PORT)) == NULL) {
fprintf(stderr, "\nUnable to connect to LDAP server:%s port:%d\n",
@@ -258,7 +265,8 @@ checkLDAP(LDAP * ld, char *userid, char *password)
char filter[256];
LDAPMessage *res = NULL;
LDAPMessage *entry;
- char *searchattr[] = {NULL};
+ char *searchattr[] =
+ {NULL};
char *userdn;
int rc;
@@ -300,6 +308,6 @@ checkLDAP(LDAP * ld, char *userid, char *password)
if (ldap_simple_bind_s(ld, dn, password) != LDAP_SUCCESS)
return 1;
-
+
return 0;
}
@@ -57,7 +57,7 @@ static char *__foo;
#define debug(X...) /* */
#endif /* DEBUG */
#else /* __GNUC__ */
-static void
+static void
debug(char *format,...)
{
}
View
@@ -469,7 +469,7 @@ httpReplyBodySize(method_t method, HttpReply * reply)
* Calculates the maximum size allowed for an HTTP response
*/
void
-httpReplyBodyBuildSize(request_t *request, HttpReply * reply, dlink_list *bodylist)
+httpReplyBodyBuildSize(request_t * request, HttpReply * reply, dlink_list * bodylist)
{
body_size *bs;
aclCheck_t *checklist;
@@ -484,8 +484,8 @@ httpReplyBodyBuildSize(request_t *request, HttpReply * reply, dlink_list *bodyli
/* Allow - use this entry */
reply->maxBodySize = bs->maxsize;
bs = NULL;
- debug (58, 3) ("httpReplyBodyBuildSize: Setting maxBodySize to %d\n", reply->maxBodySize);
+ debug(58, 3) ("httpReplyBodyBuildSize: Setting maxBodySize to %d\n", reply->maxBodySize);
}
- aclChecklistFree(checklist);
+ aclChecklistFree(checklist);
}
}
Oops, something went wrong.

0 comments on commit abc6aaf

Please sign in to comment.