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

Number of difference sections found: 91
Number of difference records found: 636

DIFFERENCES /IGNORE=()/MERGED=1-
    DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;22-
    DELPHI$WWW:[DEV.WWW300PRE.WWW.DAEMON.IMPLEMENTATION]HTDAEMON.C;16
