 ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22K     7   **      POSIXWAIT       If defined, uses waitpid instead of wait3  ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16F     7   **	ACCESS_AUTH	If defined, include access authorization codeK     8   **      POSIXWAIT       If defined, uses waitpid instead of wait3  ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22%    15   **	FM	Foteos Macrides, WFEB     16   ** ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16    16   ** ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;227    55   **	31 Mar 94  FM	Added Inetd support for VMS. <    56   **			Added HTVMS_disableAllPrv for turning off all&    57   **			unnecessary privileges.G    58   **	04 Apr 94  FM	Fixed to set HTServerPort when running under     59   **			Inetd on VMS.    60   */ ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16    55   */ ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22   109   #include <descrip.h>   110   #include <ssdef.h>   111   #include <stdlib.h>    112   #include <unixlib.h>   113   #ifdef UCX"   114   #include <ucx$inetdef.h>   115   #endif /* UCX */   116   #undef FORKING ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16   104   #undef FORKING ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22   121   #include "HTWriter.h"    122   #include "HTAAServ.h" 
   123    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16=   109   #ifdef ACCESS_AUTH		/* Use Access Authorization? */    110   #include "HTWriter.h"    111   #include "HTAAServ.h"    112   #endif
   113    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22   135   #include "HTError.h"
   136    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16
   125    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22
   215   O   216   PUBLIC char * HTClientProtocol = 0;	/* Protocol and version number	*/  ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16M   204   PUBLIC char * log_file_name = NULL;	/* Log file name (WAIS code)	*/ O   205   PUBLIC char * HTClientProtocol = 0;	/* Protocol and version number	*/  ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22*   256   PUBLIC long		HTCacheUsage		= 0L;,   257   PUBLIC int		HTChildExitStatus	= 0; ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16)   245   PUBLIC long		HTCacheUsage		= 0; ,   246   PUBLIC int		HTChildExitStatus	= 0; ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22*   265   PUBLIC BOOL		proxy_access		= NO;
   266    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16
   254    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22   360   #if defined(Mips)    361   PRIVATE int	pgrp;    362   #else 3   363   #if defined(__hpux) || defined(POSIXWAIT)  ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16
   348   3   349   #if defined(__hpux) || defined(POSIXWAIT)  ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22   368   #endif
   369    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16
   354    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22D   388   	gc_info_file = (char*)malloc(strlen(cc.cache_root) + 20);?   389   	sprintf(gc_info_file, "%s/.gc_info", cc.cache_root);IB   390   	CTRACE(stderr, "BugFix...... gc info file wasn't set");   391       }D ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16H   373   	HTLog_error2("BUG: gc info file not set although caching to",    374   		     cc.cache_root);   375   	return;   376       }* ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22B   418   	    fprintf(stderr, "GC report... from pid %d\n", pid);E   419   	    fprintf(stderr, "............ %ldK used (%d files)\n",*-   420   		    bytes_used/1024, files_used);PJ   421   	    fprintf(stderr, "............ %ldK collected (%d files)\n",/   422   		    bytes_freed/1024, files_freed);VG   423   	    fprintf(stderr, "Parent fix.. %ldK used => %ldK used\n",e)   424   		    HTCacheUsage, corrected);  ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16B   403   	    fprintf(stderr, "GC REPORT... from pid %d\n", pid);E   404   	    fprintf(stderr, "GC REPORT... %ldK USED (%d files)\n",W-   405   		    bytes_used/1024, files_used);EJ   406   	    fprintf(stderr, "GC REPORT... %ldK COLLECTED (%d files)\n",/   407   		    bytes_freed/1024, files_freed);nG   408   	    fprintf(stderr, "PARENT FIX.. %ldK USED => %ldK USED\n",1)   409   		    HTCacheUsage, corrected);I ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22L   429   	    CTRACE(stderr, "Parent...... Correcting %ldK => %ldK used\n",+   430   		   corrected, bytes_used/1024);  ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16L   414   	    CTRACE(stderr, "PARENT...... Correcting %ldK => %ldK USED\n",+   415   		   corrected, bytes_used/1024);t ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22M   435   	CTRACE(stderr,"Parent...... %ldK of cache in use\n",HTCacheUsage);M   436       }E ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16M   420   	CTRACE(stderr,"PARENT...... %ldK of cache in use\n",HTCacheUsage);*   421       }  ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22
   459   3   460   #if defined(POSIXWAIT) || defined(__hpux)*   461   #if !defined(Mips)   462   #define USE_WAITPIDI   463   #endif   464   #endif
   465      466   #ifdef USE_WAITPID   467       pid_t pid; ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;163   444   #if defined(POSIXWAIT) || defined(__hpux)P   445       pid_t pid; ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22F   470       while ((pid = waitpid((pid_t)-1, &status, WNOHANG)) > 0)   471   #else    472       int		pid;e    473       union wait	status;
   474   O   475       while ((pid = wait3(&status, WNOHANG, (struct rusage*)NULL)) > 0)W   476   #endif   477         { N   478   	CTRACE(stderr,"Parent...... child pid %d has finished\n",(int)pid); ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16H   448       while ((pid = waitpid((pid_t)-1, &status, WNOHANG)) > 0) {N   449   	CTRACE(stderr,"Parent...... child pid %d has finished\n",(int)pid); ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22G   488   		   "Parent...... %dK taken up by child, total %ldK used\n",i ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16F   459   		   "Parent...... %dK taken up by child, total %dK used\n",*   460   		   child_usage, HTCacheUsage);   461   	}   462       }.   463   #elseD   464       int		pid;    465       union wait	status;
   466   Q   467       while ((pid = wait3(&status, WNOHANG, (struct rusage*)NULL)) > 0) { I   468   	CTRACE(stderr,"Parent...... child pid %d has finished\n",pid);,   469   	if (pid == gc_pid) { A   470   	    CTRACE(stderr, "Parent...... gc has completed\n"); !   471   	    read_gc_results();D   472   	    gc_pid = 0;   473   	}6   474   	if (cc.cache_root  &&  WIFEXITED(status)) {J   475   	    int child_usage = HTExitStatusToKilos(WEXITSTATUS(status));+   476   	    HTCacheUsage += child_usage;*   477   	    CTRACE(stderr,DG   478   		   "Parent...... %dK taken up by child, total %ldK used\n",  ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22   491         }\$   492   #endif /* SIGTSTP - BSD */
   493    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16   481       }_   482   #endif   483   #endif
   484    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22.   679   	    return 100 * (timeout + 86400);   680   	} ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;160   670   	    return 100 * (timeout + 24*3600);   671   	} ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22
   980    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16"   971   	if (req->error_stack) {/   972   	    HTList * cur = req->error_stack;r   973   	    char * str;<   974   	    while ((str = (char*)HTList_nextObject(cur)))#   975   		len += strlen(str) + 5;    976   	}
   977    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22O   987   	sprintf(buf + strlen(buf), "\n<P><HR>%s%s %s%s\n</BODY>\n</HTML>\n",R ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16"   984   	if (req->error_stack) {/   985   	    HTList * cur = req->error_stack;E   986   	    char * str;#   987   	    strcat(buf,"\n<B>");r>   988   	    while ((str = (char*)HTList_nextObject(cur))) {3   989   		CTRACE(stderr,"............ %s\n",str);W!   990   		strcat(buf,"\n<P> ");;   991   		strcat(buf,str);   992   	    }&   993   	    strcat(buf,"\n</B>\n");"   994   	    HTClearErrors(req);   995   	}O   996   	sprintf(buf + strlen(buf), "\n<P><HR>%s%s %s%s\n</BODY>\n</HTML>\n",  ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  1020   /*								HTErrorMsg  1021   **K  1022   **	Creates a HTML error message from using the whole error_stack. K  1023   **	Only if the global variable HTErrorInfoPath != NULL, an anchor 5  1024   **	will be created to an message help file.4  1025   */8  1026   PUBLIC void HTErrorMsg ARGS1(HTRequest *, req)  1027   {W-  1028       HTList *cur = req->error_stack; !  1029       BOOL highest = YES;-   1030       HTErrorInfo *pres;  1031       char body[4000];  1032       char * s = body;  1033       *s = 0; 
  1034   .  1035       if (!req->output_stream) return;
  1036   #  1037       if (req->error_block)   1038   	goto do_free;
  1039   $  1040       out.status_code = 500;%  1041       HTReasonLine = "Error";D
  1042   #  1043       /* Output messages */;G  1044       while ((pres = (HTErrorInfo *) HTList_nextObject(cur))) {)
  1045   :  1046   	/* Check if we are going to show the message */J  1047   	if ((!pres->ignore || HTErrorShowMask & HT_ERR_SHOW_IGNORE) && 4  1048   	    (HTErrorShowMask & pres->severity)) {
  1049   '  1050   	    /* Output code number */e?  1051   	    if (highest) {			    /* If first time through */L  1052   		if (TRACE)  1053   		    fprintf(stderr,K=  1054   			    "HTError..... Generating error message.\n");a  1055   		/* Output title */\  1056   		strcpy(s,"<HTML>\n<HEAD>\n<TITLE>Error Message</TITLE>\n</HEAD>\n<BODY>\n<H1>");  1057   		s += strlen(s); 
  1058   .  1059   		if (pres->severity == ERR_WARNING)&  1060   		    strcat(s, "Warning ");5  1061   		else if (pres->severity == ERR_NON_FATAL) .  1062   		    strcat(s, "Non Fatal Error ");1  1063   		else if (pres->severity == ERR_FATAL) *  1064   		    strcat(s, "Fatal Error ");  1065   		else {D  1066   		    strcat(s, "Unknown Classification of Error</H1>\n");#  1067   		    goto output_errors;T
  1068   		}T
  1069   B  1070   		/* Only output error code if it is a real HTTP code */7  1071   		if (pres->element < HTERR_HTTP_CODES_END) {c!  1072   		    char codestr[20];*G  1073   		    sprintf(codestr, "%d", error_info[pres->element].code);M#  1074   		    strcat(s, codestr); A  1075   		    out.status_code = error_info[pres->element].code;@  1076   		    HTReasonLine = get_http_reason(out.status_code);
  1077   		} !  1078   		strcat(s, "</H1>\n");   1079   		highest = NO;*  1080   	    } else {)  1081   		strcat(s, "<B>Reason:</B> ");M  1082   	    }
  1083   )  1084   	    /* Output error message */;3  1085   	    if (pres->element != HTERR_SYSTEM) {05  1086   		strcat(s, error_info[pres->element].msg);   1087   		strcat(s, ":");2  1088   	    }  1089   	    strcat(s, " ");
  1090   &  1091   	    /* Output parameters */E  1092   	    if (pres->par && HTErrorShowMask & HT_ERR_SHOW_PARS) {V  1093   		int cnt;  1094   		strcat(s, " "); 6  1095   		for (cnt=0; cnt<pres->par_length; cnt++) {8  1096   		    if (*((char *)(pres->par)+cnt) < 0x20 ||0  1097   			*((char *)(pres->par)+cnt) >= 0x7F)  1098   			strcat(s, "-");  1099   		    else {  1100   			s += strlen(s);-  1101   			*s = *((char *)(pres->par)+cnt);W  1102   			*++s = 0;  1103   		    }.
  1104   		}   1105   		strcat(s, ".\n");<  1106   	    }
  1107   $  1108   	    /* Output location */  1109   	    s += strlen(s);K  1110   	    if (pres->where && HTErrorShowMask & HT_ERR_SHOW_LOCATION) {L0  1111   		strcat(s, "<BR>\nThis occured in ");#  1112   		strcat(s, pres->where);\  1113   		strcat(s, "\n");  1114   	    }  1115   	    uB  1116   	    /* If we only are going to show the higest entry */7  1117   	    if (HTErrorShowMask & HT_ERR_SHOW_FIRST);  1118   		break;"  1119   	    strcat(s, "<P>\n");  1120   	}  1121       }s
  1122     1123     output_errors:  1124       s += strlen(s);sh  1125       strcat(s, "\n<P><HR>\n<ADDRESS><A HREF=\"http://info.cern.ch/httpd_3.0/\">\nCERN httpd ");&  1126       strcat(s, HTAppVersion);>  1127       strcat(s, "</A></ADDRESS>\n</BODY>\n</HTML>\n");
  1128   0  1129       out.content_length = strlen(body);*  1130       if (!out.http_header_sent) {0  1131   	char * headers = HTReplyHeaders(req);  1132   	if (headers) {4R  1133   	    (*req->output_stream->isa->put_string)(req->output_stream,headers);  1134   	    free(headers);   1135   	}&  1136   	out.http_header_sent = YES;  1137       }TN  1138       (*req->output_stream->isa->put_string)(req->output_stream,body);
  1139     1140     do_free:C  1141       (*req->output_stream->isa->free)(req->output_stream);3  1142   }e ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16@  1029   PUBLIC int HTLoadStrToStream ARGS2(HTStream *,	  sink,$  1030   				   CONST char *,  str)  1031   {l9  1032       if (!sink || !sink->isa || !str) return -1;12  1033       (*sink->isa->put_string)(sink, str);  1034       return 0;   1035   }i ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22
  1145   @  1146   PUBLIC int HTLoadStrToStream ARGS2(HTStream *,	  sink,$  1147   				   CONST char *,  str)  1148   { 9  1149       if (!sink || !sink->isa || !str) return -1;	2  1150       (*sink->isa->put_string)(sink, str);  1151       return 0;l  1152   }  ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16:  1038   PUBLIC int HTCloseStream ARGS1(HTStream *, sink)  1039   {y&  1040       if (sink && sink->isa) {$  1041   	(*sink->isa->free)(sink);  1042   	return 0;  1043       }1  1044       return -1;  1045   }" ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22:  1155   PUBLIC int HTCloseStream ARGS1(HTStream *, sink)  1156   {/&  1157       if (sink && sink->isa) {$  1158   	(*sink->isa->free)(sink);  1159   	return 0;  1160       }i  1161       return -1;  1162   }f
  1163   
  1164   
  1165    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16
  1048    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  1197   	return 0;
  1198   R  1199   #ifdef OLD_CODE /* Got the channel at the top of main() -- F.Macrides */@  1200   	{   unsigned short channel;	    /* VMS I/O channel */ ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16
  1080   @  1081   	{   unsigned short channel;	    /* VMS I/O channel */ ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  1213   #endif /* OLD_CODE */s  1214   #else /* not VMS */16  1215   	com_soc = 0;	    /* The channel is stdin */ ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1094   #else 6  1095   	com_soc = 0;	    /* The channel is stdin */ ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  1218   #endif /* not VMS */
  1219    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1098   #endif
  1099    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  1242   #endif /* Internet */F  1243   	dynamic_allocation = TRUE;	    /*  dynamically allocated */ ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1122   #endifF  1123   	dynamic_allocation = TRUE;	    /*  dynamically allocated */ ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  1260   #else  /* Internet */;  1261   		sin->sin_port =  ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1140   #else  1141   		sin->sin_port =  ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  1265   #endif /* Internet */i>  1266   		if (*q) return -2;  /* Junk follows port number */ ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1145   #endif>  1146   		if (*q) return -2;  /* Junk follows port number */ ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  1279   #else /* Internet */  1280   	if (*p == 0) {o ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1159   #elseq  1160   	if (*p == 0) {1 ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  1303   #endif /* Internet */W   1304       } /* scope of p */ ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1183   #endif   1184       } /* scope of p */ ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22   1310   	struct linger Linger; ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1190   #ifdef STDCN(  1191   	struct linger Linger = {0,0};  1192   #elseo   1193   	struct linger Linger; ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22
  1313    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1196   #endif
  1197    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  1317   #else /* Internet */B  1318   	master_soc = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);  1319   #endif /* Internet */   1320   	if (master_soc<0) { ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1201   #elseAB  1202   	master_soc = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);  1203   #endif  1204   	if (master_soc<0) { ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  1435   #ifdef Mips   1436       {  1437   	union wait status; #  1438   	wait3(&status, 0, NULL);D  1439       }I  1440   #else /* not Mips */+  1441       waitpid(script_pid, NULL, 0);W  1442   #endif /* not Mips */M  1443   #endif /* not Next */   1444   #endif /* not VMS */ ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16+  1319       waitpid(script_pid, NULL, 0);   1320   #endif  1321   #endif /* not VMS */ ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  1462   #else /* not VMS */*O  1463   #define START_TIMER(f,t) { signal(SIGALRM,(void(*)()) f); alarm(t); }EF  1464   #define CANCEL_TIMER	 { alarm(0); signal(SIGALRM,SIG_IGN); }  1465   #endif /* not VMS */
  1466    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1339   #elseO  1340   #define START_TIMER(f,t) { signal(SIGALRM,(void(*)()) f); alarm(t); }*F  1341   #define CANCEL_TIMER	 { alarm(0); signal(SIGALRM,SIG_IGN); }  1342   #endif
  1343    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22
  1579    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1456   #ifdef ACCESS_AUTH
  1457    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22
  1681    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16"  1559   #endif	/* ACCESS_AUTH */
  1560    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22M  1696   	proxy_access = YES;	/* Write to proxy log instead of access log */(  1697   	HTImServer = HTReqTranslated;
  1698    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16
  1575    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22
  1736   		}6 ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1613   		    free(cfn);
  1614   		}W ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22+  1739   		    /* Load from remote host */* ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1617   		    free(cfn);+  1618   		    /* Load from remote host */i ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22<  1744   			status = HTLoadToStream(HTReqArgPath, NO, req);  1745   		    }E ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16?  1623   			status = HTLoadToStream(HTReqTranslated, NO, req);D  1624   		    }N ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22&  1750   		    HTLoadError(req, 404,   1751   "Proxy is in standalone cache mode [no external connections enabled] and the document was <B>not found in the cache</B>.");E0  1752   		else /* task == CACHE_IF_MODIFIED */ ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1629   		    HTLoadError(req, 404, "Proxy is in standalone cache mode [no external connections enabled] and the document was <B>not0  1630   		else /* task == CACHE_IF_MODIFIED */ ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22
  1765   		}M>  1766   		else if (task == CACHE_IF_MODIFIED && cfn && cf) {G  1767   		    CTRACE(stderr,"Cache....... IMS-GET %s",ctime(&if_ms));d$  1768   		    req->output_stream = ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1643   		    free(cfn);
  1644   		}m>  1645   		else if (task == CACHE_IF_MODIFIED && cfn && cf) {  1646   		    CTRACE(stderr,A  1647   			   "Cache....... conditional GET if modif.since %s",W  1648   			   ctime(&if_ms));H$  1649   		    req->output_stream = ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22
  1772   		}  ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1653   #if 04%  1654   		    if (HTProxyHeaders) {eD  1655   			char * tmp = (char*)malloc(strlen(HTProxyHeaders)+100);8  1656   			sprintf(tmp, "If-Modified-Since: %s\r\n%s",1  1657   				http_time(&if_ms), HTProxyHeaders);e"  1658   			free(HTProxyHeaders);"  1659   			HTProxyHeaders = tmp;  1660   		    }E  1661   		    else {1  1662   			HTProxyHeaders = (char*)malloc(100); A  1663   			sprintf(HTProxyHeaders, "If-Modified-Since: %s\r\n", !  1664   				http_time(&if_ms));   1665   		    }S  1666   #endif
  1667   		}d ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22%  1775   		    ignore_sigpipes = NO;f ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1670   		    if (TRACE) {/  1671   			fprintf(stderr, "Dump........\n");4<  1672   			fprintf(stderr, "           . task=%d\n",task);B  1673   			fprintf(stderr, "           . cfn=%s\n",cfn?cfn:"-");8  1674   			fprintf(stderr, "           . cf=%p\n",cf);?  1675   			fprintf(stderr, "           . if_ms=%ld\n",if_ms);*  1676   		    }*%  1677   		    ignore_sigpipes = NO;E ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22;  1788   		status = HTLoadToStream(HTReqArgPath, NO, req);T  1789   	    }  1790   	    FREE(cfn);*  1791   	} ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16>  1690   		status = HTLoadToStream(HTReqTranslated, NO, req);  1691   	    }  1692   	} ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22>  1808   	    status = HTLoadToStream(HTReqArgPath, NO, req);  1809   	} ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16A  1709   	    status = HTLoadToStream(HTReqTranslated, NO, req);   1710   	} ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22(  1960       /* disable SYSPRV again */$  1961       HTVMS_disableSysPrv();  1962   #endif /* VMS */ ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1861   #ifdef ACCESS_AUTH(  1862       /* disable SYSPRV again */$  1863       HTVMS_disableSysPrv();"  1864   #endif /* ACCESS_AUTH */  1865   #endif /* VMS */ ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22N  2008       CTRACE(stderr,"Lowering.... process priority while doing gc\n");  2009       nice(6);  2010       do { ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1911       do { ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22>  2035       CTRACE(stderr,"ServerLoop.. Unix standalone\n");
  2036    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  1936       CTRACE(stderr,Q  1937   	   "ENTERING.... BRAND NEW SERVER LOOP FOR UNIX STANDALONE SERVER\n");o
  1938    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22E  2074   		CTRACE(stderr,"Time to do.. daily garbage collection\n");H  2075   		gc_pid = fork();&  2076   		if (!gc_pid) {	/* Child */!  2077   		    gc_and_exit(1,0);	
  2078   		}r  2079   		else {!  2080   		    if (gc_pid < 0) { <  2081   			HTLog_error("FORK FAILED when launching gc\n");  2082   			gc_pid = 0;  2083   		    };
  2084   		}	 ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16>  1976   		CTRACE(stderr,"Maybe....... time for daily gc\n");"  1977   		if (time_to_do_gc()) {K  1978   		    CTRACE(stderr, "Yep......... Let's do it -- forking...\n");e   1979   		    gc_pid = fork();*  1980   		    if (!gc_pid) {	/* Child */  1981   			gc_and_exit(1,0);  1982   		    }  1983   		    else {  1984   			if (gc_pid < 0) {@  1985   			    HTLog_error("FORK FAILED when launching gc\n");  1986   			    gc_pid = 0;  1987   			}  1988   		    }H
  1989   		}1  1990   		else {9  1991   		    CTRACE(stderr, "No.......... Not yet\n");t
  1992   		}, ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22A  2090   	CTRACE(tfp, "Daemon...... accepting connection...\n");m ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16   1998         do_again_accept:A  1999   	CTRACE(tfp, "Daemon...... accepting connection...\n");* ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22L  2096   	    goto do_again_select;	/* Have do select because we might   */6  2097   					/* need to turn timeout on this time *//  2098   					/* (if gc just returned)	     */n  2099   	} ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16$  2005   	    goto do_again_accept;  2006   	} ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22=  2111   	    CTRACE(stderr, "StandAlone.. Doing fork()\n");  ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16   2018   	    if (sc.do_rfc931)E  2019   		remote_ident = rfc931(&client_soc_addr,&server_soc_addr);1  2020   	    else*   2021   		remote_ident = NULL;
  2022   =  2023   	    CTRACE(stderr, "StandAlone.. Doing fork()\n");  ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22E  2138   		 * This no-linger stuff is borrowed from NCSA httpd code.HD  2139   		 * In Linux this causes problems -- is this necessary atE  2140   		 * all -- well, I've disabled for now, and if I was wrongEE  2141   		 * this can be turned on by "Linger On" config directive.m  2142   		 */   2143   		if (sc.do_linger) {*!  2144   		    struct linger sl;H ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16D  2050   		 * This no-linger stuff is borrowed from NCSA httpd code  2051   		 */
  2052   		{D!  2053   		    struct linger sl;. ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  2151   		else {J  2152   		    CTRACE(stderr, "Linger...... no longer set by default\n");
  2153   		}*
  2154    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16
  2060    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;226  2160   		    memset((char*)&addr, 0, sizeof(addr));H  2161   		    getpeername(com_soc, (struct sockaddr*)&addr, &namelen);/  2162   		    if (inet_ntoa(addr.sin_addr)) {OA  2163   			strncpy(ip_address, (char*)inet_ntoa(addr.sin_addr),L"  2164   				sizeof(ip_address));   2165   			ip_address[15] = 0;  2166   		    }E  2167   		    else {+  2168   			strcpy(ip_address, "0.0.0.0");3  2169   		    }.7  2170   		    StrAllocCopy(HTClientHost, ip_address);  ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16H  2066   		    getpeername(com_soc, (struct sockaddr*)&addr, &namelen);D  2067   		    strncpy(ip_address, (char*)inet_ntoa(addr.sin_addr),%  2068   			    sizeof(ip_address)); #  2069   		    ip_address[15] = 0; 7  2070   		    StrAllocCopy(HTClientHost, ip_address);  ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;229  2173   			HTClientHostName = HTGetHostBySock(com_soc);0
  2174   		}. ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;167  2073   			HTClientHostName = HTGetHostName(com_soc);	
  2074   		}r ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22   2179   		remote_ident = NULL;  2180   		if (sc.do_rfc931) { 0  2181   		    int l = sizeof(server_soc_addr);  2182   		    if (com_soc ||C  2183   			getsockname(fileno(stdout),&server_soc_addr,&l) != -1) D  2184   			remote_ident=rfc931(&client_soc_addr,&server_soc_addr);  2185   		    else {D  2186   			CTRACE(stderr,"Failed...... to get local sock addr\n");  2187   		    }*
  2188   		}$
  2189   +  2190   		tcp_status = HTHandle(com_soc);2 ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16+  2079   		tcp_status = HTHandle(com_soc);M ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22:  2305   		    CTRACE(stderr, "Time to do.. daily gc\n");   2306   		    gc_pid = fork();*  2307   		    if (!gc_pid) {	/* Child */  2308   			gc_and_exit(1,0);  2309   		    }w  2310   		    else {  2311   			if (gc_pid < 0) {@  2312   			    HTLog_error("FORK FAILED when launching gc\n");  2313   			    gc_pid = 0;  2314   			}  2315   		    }."  2316   		    goto retry_select; ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2194   		    CTRACE(stderr,B  2195   			   "I think..... it might be time to do daily gc\n");&  2196   		    if (time_to_do_gc()) {:  2197   			CTRACE(stderr, "Yep......... Let's do gc\n");  2198   			gc_pid = fork();i'  2199   			if (!gc_pid) {	/* Child */t"  2200   			    gc_and_exit(1,0);  2201   			}  2202   			else {2"  2203   			    if (gc_pid < 0) {=  2204   				HTLog_error("FORK FAILED when launching gc\n");n  2205   				gc_pid = 0;*  2206   			    }  2207   			}  2208   		    }M  2209   		    else {6  2210   			CTRACE(stderr, "No.......... Not yet\n");  2211   		    } 
  2212   "  2213   		    goto retry_select; ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22
  2348   /  2349   		    tcp_status = accept(master_soc, ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2245     retry_accept_1::/  2246   		    tcp_status = accept(master_soc,. ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  2355   			goto retry_select;   2356   		    }* ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16!  2252   			goto retry_accept_1;   2253   		    }r ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  2371   #ifdef DECNETM ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2268   	  retry_accept_2:  2269   #ifdef DECNET. ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  2380   		goto retry_select;  2381   	    } ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16   2278   		goto retry_accept_2;  2279   	    } ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22+  2386   #endif /* SELECT not supported */ 
  2387    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2284   #endif
  2285    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  2401   #ifdef FORKING ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16"  2299   	    if (sc.do_rfc931) {B  2300   		CTRACE(stderr, "RFC 931..... Getting remote ident\n");E  2301   		remote_ident = rfc931(&client_soc_addr,&server_soc_addr); /  2302   		CTRACE(stderr, "Ident....... %s\n",o;  2303   		       remote_ident ? remote_ident : "-none-");W  2304   	    }(  2305   	    else remote_ident = NULL;
  2306     2307   #ifdef FORKING ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22"  2410   #else  /* non FORKING */  2411   	    fork_status = 0;	"  2412   #endif /* non FORKING */
  2413    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2316   #elsee  2317   	    fork_status = 0;   2318   #endif /* FORKING */
  2319    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22
  2440    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2346   		struct linger sl;D
  2347    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  2453   		if (sc.do_linger) {D!  2454   		    struct linger sl;I  2455   		    sl.l_onoff = 1; A  2456   		    sl.l_linger = 600; /* currently ignored anyway */=J  2457   		    /* this should check error status, but it's not crucial */
  2458   :  2459   		    setsockopt(com_soc, SOL_SOCKET, SO_LINGER,,  2460   			       (char*)&sl, sizeof(sl));
  2461   		}l  2462   		else {J  2463   		    CTRACE(stderr, "Linger...... no longer set by default\n");
  2464   		}s
  2465    ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2360   		sl.l_onoff = 1;=  2361   		sl.l_linger = 600; /* currently ignored anyway */;F  2362   		/* this should check error status, but it's not crucial */
  2363   6  2364   		setsockopt(com_soc, SOL_SOCKET, SO_LINGER,(  2365   			   (char*)&sl, sizeof(sl));
  2366    ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22
  2470   6  2471   		    memset((char*)&addr, 0, sizeof(addr));  2472   #ifdef DECNET  ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2371   #ifdef DECNET  ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  2476   #else /* Internet */H  2477   		    getpeername(com_soc, (struct sockaddr*)&addr, &namelen);  2478   		    /  2479   		    if (inet_ntoa(addr.sin_addr)) {W   2480   			strncpy(ip_address,.  2481   				(char*)inet_ntoa(addr.sin_addr),"  2482   				sizeof(ip_address));   2483   			ip_address[15] = 0;  2484   		    }L  2485   		    else {+  2486   			strcpy(ip_address, "0.0.0.0");5  2487   		    }e7  2488   		    StrAllocCopy(HTClientHost, ip_address);D ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2375   #else	H  2376   		    getpeername(com_soc, (struct sockaddr*)&addr, &namelen);
  2377   #  2378   		    strncpy(ip_address, 1  2379   			    (char*)inet_ntoa(addr.sin_addr),W%  2380   			    sizeof(ip_address));O#  2381   		    ip_address[15] = 0; 7  2382   		    StrAllocCopy(HTClientHost, ip_address);  ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;229  2491   			HTClientHostName = HTGetHostBySock(com_soc);E  2492   #endif /* Internet */O
  2493   		}  ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;167  2385   			HTClientHostName = HTGetHostName(com_soc);O  2386   #endif
  2387   		}T ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22   2499   		remote_ident = NULL;  2500   		if (sc.do_rfc931) {*0  2501   		    int l = sizeof(server_soc_addr);  2502   		    if (com_soc ||C  2503   			getsockname(fileno(stdout),&server_soc_addr,&l) != -1)DD  2504   			remote_ident=rfc931(&client_soc_addr,&server_soc_addr);  2505   		    else {D  2506   			CTRACE(stderr,"Failed...... to get local sock addr\n");  2507   		    }o
  2508   		}s
  2509   +  2510   		tcp_status = HTHandle(com_soc);" ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16+  2393   		tcp_status = HTHandle(com_soc);2 ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  2528   #endif /* SELECT */24  2529   		    } else {  /* Not multiclient mode */ ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2411   #endif4  2412   		    } else {  /* Not multiclient mode */ ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  2532   #else /* not VM */   2533   			return -ECONNRESET;  2534   #endif /* not VM */4  2535   		    }i ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2415   #else    2416   			return -ECONNRESET;  2417   #endif  2418   		    }0 ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  2541   #endif /* SELECT */o
  2542   		}2 ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2424   #endif
  2425   		}t ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  2631       /* ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16V  2514   #ifdef OLD_CODE	/* For some reason this prevents NPH-scripts from working */  2515       /*S  2516       ** Close any open file descriptors except the socket we are listening6  2517       */+  2518       for (fd=0; fd<NOFILE; fd++) {6#  2519   	if (fd != master_soc  &&uF  2520   	    (access_log_fileno == -1 || fd != access_log_fileno) &&C  2521   	    (error_log_fileno == -1  || fd != error_log_fileno))2  2522   	    close(fd);*  2523       }eO  2524       errno = 0;	/* Probably got set to EBADF a few times by close() */  2525   #endif
  2526     2527       /* ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22
  2675     2676   #ifdef VMS  2677       /*N  2678       **  The first thing we should always do on VMS is find out if weO  2679       **  are running under Inetd/MULTINET_SERVER/AUX, and if so, get atS  2680       **  channel to the socket for MULTINET and Wollongong.  Then, becauserS  2681       **  we can't pass parameters to an Inetd process via switches, we get.I  2682       **  the rule file via an environment logical.	-- F.Macrides   2683       */-  2684       BOOLEAN HTRunFromInetd = FALSE;rJ  2685       char *VMSRuleFileLogical = (char *)malloc(sizeof(char)*256);C  2686       char *VMSRuleFile = (char *)malloc(sizeof(char)*256);0
  2687   
  2688   3  2689   #if defined(MULTINET) || defined(WIN_TCP) "  2690       unsigned short chan;2  2691       $DESCRIPTOR(chan_desc, "SYS$INPUT");  2692       /*B  2693       **  See if we're running under Inetd/MULTINET_SERVER9  2694       **  and if so, get a channel to the socket.=  2695       */9  2696       if (strstr(getenv("SYS$INPUT"), "_INET")) {*B  2697           status = sys$assign(&chan_desc, &chan, 0, 0, 0);$  2698           if (!(status & 1))#  2699               exit(status);_'  2700           com_soc = (int) chan; (  2701           HTRunFromInetd = TRUE;  2702       }W-  2703   #endif /* MultiNet or Wollongong */ 
  2704   1  2705   #if defined(UCX) && defined(UCX$C_AUXS)d  2706       /*H  2707       **  This socket call will try to get the client connectionF  2708       **  from the AUX Server.  If it succeeds, we are running.  2709       **  from the AUX server (Inetd).  2710       */>  2711       if ((com_soc = socket (UCX$C_AUXS, 0, 0)) != -1)(  2712           HTRunFromInetd = TRUE;  2713   #endif /* UCX v2+ */
  2714   #  2715       if (HTRunFromInetd) {  2716       /*Q  2717       **  We can't pass switches to a MultiNet Inetd process, so we use a Q  2718       **  system logical (HTTPD_CONFIG<port number> or just HTTPD_CONFIG) I  2719       **  pointing to the rule file, which should include all theOL  2720       **  information we'd otherwise pass via switches.  We'll do itE  2721       **  this way for UCX and Wollongong, too.	-- F.MacridesE  2722       **+  2723       **  Track down the rule file.e  2724       *//  2725           struct sockaddr_in serv_addr;W1  2726           int length = sizeof(serv_addr);2
  2727     2728           /* eG  2729   	**  In multiserver environments, the port number is appendedLH  2730   	**  to a system logical for each server's configuration file.
  2731   	*/ X  2732           if (getsockname(com_soc, (struct sockaddr *) &serv_addr,&length) == 0):  2733   	    HTServerPort = (ntohs(serv_addr.sin_port));  2734           else"  2735   	    exit(SS$_NOIOCHAN);G  2736   	sprintf(VMSRuleFileLogical, "HTTPD_CONFIG%d", HTServerPort);*4  2737   	if (getenv(VMSRuleFileLogical) != NULL) {?  2738   	    strcpy(VMSRuleFile, getenv(VMSRuleFileLogical));  2739   	} else {*  2740   	    /*:@  2741   	    **  If that's not defined, try the system logical,  2742   	    **  without a numeric suffix.  2743   	    */L:  2744   	    strcpy(VMSRuleFileLogical, "HTTPD_CONFIG");8  2745   	    if (getenv(VMSRuleFileLogical) != NULL) {C  2746   	        strcpy(VMSRuleFile, getenv(VMSRuleFileLogical));C  2747   	    } else {i  2748   	        /*fJ  2749   	        **  No environment logical, so use the program logical.  2750   	        */t2  2751   	        strcpy(VMSRuleFile, RULE_FILE);  2752   	    }  2753   	}$  2754   	free(VMSRuleFileLogical);  2755   	role = passive;  2756       }   2757   #endif /* VMS */
  2758   B  2759       WWW_TraceFlag = 0;		/* diagnostics off by default */D  2760       HTImProxy = YES;		/* Always be able to run as proxy */ ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16B  2571       WWW_TraceFlag = 0;		/* diagnostics off by default */K  2572       HTImServer = YES;		/* To prevent HTAccess from translating */VD  2573       HTImProxy = YES;		/* Always be able to run as proxy */ ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  2775   #ifdef VMS#  2776       if (HTRunFromInetd) {T3  2777           if (HTLoadRules(VMSRuleFile) < 0)e#  2778   	    exit(SS$_FILACCERR);o  2779   	rulefiles++;.  2780   	free(VMSRuleFile);l  2781       } else  2782   #endif /* VMS */
  2783     2784       {O ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2588       {2 ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22*  2966       if (restart_only || gc_only)  2967   	goto skip_inits;o ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2770       if (restart_only)g  2771   	goto skip_inits;  ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22=  2972       if (sc.server_type == SERVER_TYPE_STANDALONE) {a  2973   	if (!sc.port) {  2974   	    sc.port = 80;M  2975   	    CTRACE(stderr,"Default..... port 80 for standalone server\n");   2976   	}  2977       } =  2978       else if (sc.server_type == SERVER_TYPE_INETD) {   2979   	if (sc.port) {   2980   	    sc.port = 0;iM  2981   	    CTRACE(stderr,"Port........ ignored for inetd type server\n");e  2982   	}  2983       }n!  2984       else if (sc.port) {m3  2985   	sc.server_type = SERVER_TYPE_STANDALONE;2R  2986   	CTRACE(stderr, "Default..... server type StandAlone (Port defined)\n");  2987       }X  2988       else {	 .  2989   	sc.server_type = SERVER_TYPE_INETD;R  2990   	CTRACE(stderr, "Default..... server type Inetd (no Port specified)\n");  2991       } 
  2992   =  2993       if (sc.server_type == SERVER_TYPE_STANDALONE) {   2994   #ifdef FORKING ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2776       if (sc.port) {  2777   #ifdef FORKING ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22!  2997   #else /* not FORKING */EC  2998   	CTRACE(stderr, "ServerType.. standalone non-forking\n");2"  2999   #endif /* not FORKING */  3000       }r ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2780   #else2C  2781   	CTRACE(stderr, "ServerType.. standalone non-forking\n");   2782   #endif  2783       }f ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22L  3008   	  "Can't bind and listen on port (maybe httpd already running)");  3009   	HTLog_error(3 ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16J  2791   	  "Can't bind and listen on port (maybe one already running)");  2792   	HTLog_error(2 ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  3021       /*B  3022       **  Disable all privileges except TMPMBX and NETMBX.A  3023       **  We can then turn SYSPRV on and off selectively.M  3024       */$  3025       HTVMS_disableAllPrv();  3026   #endif /* not VMS */
  3027     3028   #ifndef VMSR  3029       /*/  3030        * Set parent process uid and gid  3031        */f3  3032       if (getuid() == 0 && sc.parent_uid) {s$  3033   	struct passwd *pw = NULL;#  3034   	struct group *gr = NULL;M  3035   	int gid = 0;
  3036   /  3037   	if (!(pw = getpwnam(sc.parent_uid)))cM  3038   	    HTLog_error2("Can't get passwd entry for user",sc.parent_uid); >  3039   	else if (initgroups(pw->pw_name, pw->pw_gid) == -1)F  3040   	    HTLog_error2("Can't init groups for user",pw->pw_name);
  3041     3042   	if (sc.parent_gid) {V,  3043   	    gr = getgrnam(sc.parent_gid);P  3044   	    if (!gr) HTLog_error2("Can't get group entry for",sc.parent_gid);  3045   	}
  3046     3047   	if (gr)   3048   	    gid = gr->gr_gid;  3049   	else if (pw)A   3050   	    gid = pw->pw_gid;
  3051     3052   	if (gid) {i@  3053   	    CTRACE(stderr, "Doing....... setgid(%d)\n", gid);%  3054   	    if (setgid(gid) == -1) B  3055   		HTLog_errorN("Failed to set parent group id to", gid);  3056   	}"  3057   	if (pw && pw->pw_uid) {G  3058   	    CTRACE(stderr, "Doing....... setuid(%d)\n", pw->pw_uid);l,  3059   	    if (setuid(pw->pw_uid) == -1)H  3060   		HTLog_errorN("Failed to set parent user id to", pw->pw_uid);  3061   	}  3062       }8  3063   #endif /* not VMS */  3064        ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16$  2804       HTVMS_disableSysPrv();  2805   #endif /* VMS */  2806        ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22:  3079       if (!gc_only && (sc.port || restart_only)) {  3080   	FILE * fp = NULL; ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16,  2821       if (sc.port || restart_only) {  2822   	FILE * fp = NULL; ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22  3123   #ifndef VMSi ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2865   #ifdef VMS#  2866      HTVMS_disableSysPrv();.  2867   #endif /* VMS */
  2868     2869   #ifndef VMS  ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22%  3142          if (role != passive)p"  3143              exit(status);  3144          else   3145              exit(0);e  3146       }R ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16  2888          exit(status);  2889       }9 ************ ************H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;220  3149       if (status<0 && role != passive) {  3150   	exit(status); ******H File DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16
  2892     2893       if (status<0) {A  2894   	exit(status); ************ ) Number of difference sections found: 91T) Number of difference records found: 636  " DIFFERENCES /IGNORE=()/MERGED=1-H     DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22-G     DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16 