commit - e618041168d77852ceec5060ec285127354cb6f5
commit + 5e929effcae7a273f55a0011632b86a0811cf35f
blob - 36e16e56a9dad85a477f4f089acb9d263089c276
blob + 846e5236d40b1d630c22405a9e1477aa81622a9b
--- src/ngircd/resolve.c
+++ src/ngircd/resolve.c
#include "portab.h"
-static char UNUSED id[] = "$Id: resolve.c,v 1.9 2004/05/11 00:01:11 alex Exp $";
+static char UNUSED id[] = "$Id: resolve.c,v 1.10 2005/03/05 12:57:14 alex Exp $";
#include "imp.h"
#include <assert.h>
LOCAL CHAR *Get_Error PARAMS(( INT H_Error ));
#endif
+LOCAL RES_STAT *New_Res_Stat PARAMS(( VOID ));
+
GLOBAL VOID
Resolve_Init( VOID )
{
RES_STAT *s;
INT pid;
- /* Allocate memory */
- s = (RES_STAT *)malloc( sizeof( RES_STAT ));
- if( ! s )
- {
- Log( LOG_EMERG, "Resolver: Can't allocate memory! [Resolve_Addr]" );
- return NULL;
- }
+ s = New_Res_Stat( );
+ if( ! s ) return NULL;
- /* Initialize pipe for result */
- if( pipe( s->pipe ) != 0 )
- {
- free( s );
- Log( LOG_ALERT, "Resolver: Can't create output pipe: %s!", strerror( errno ));
- return NULL;
- }
-
/* For sub-process */
pid = fork( );
if( pid > 0 )
FD_SET( s->pipe[0], &Resolver_FDs );
if( s->pipe[0] > Conn_MaxFD ) Conn_MaxFD = s->pipe[0];
s->pid = pid;
- s->stage = 0;
- s->bufpos = 0;
return s;
}
else if( pid == 0 )
RES_STAT *s;
INT pid;
- /* Allocate memory */
- s = (RES_STAT *)malloc( sizeof( RES_STAT ));
- if( ! s )
- {
- Log( LOG_EMERG, "Resolver: Can't allocate memory! [Resolve_Name]" );
- return NULL;
- }
-
- /* Initialize the pipe for the result */
- if( pipe( s->pipe ) != 0 )
- {
- free( s );
- Log( LOG_ALERT, "Resolver: Can't create output pipe: %s!", strerror( errno ));
- return NULL;
- }
+ s = New_Res_Stat( );
+ if( ! s ) return NULL;
/* Fork sub-process */
pid = fork( );
FD_SET( s->pipe[0], &Resolver_FDs );
if( s->pipe[0] > Conn_MaxFD ) Conn_MaxFD = s->pipe[0];
s->pid = pid;
- s->stage = 0;
- s->bufpos = 0;
return s;
}
else if( pid == 0 )
#else
Log_Resolver( LOG_WARNING, "Can't resolve \"%s\"!", Host );
#endif
- strcpy( ip, "" );
+ ip[0] = '\0';
}
if( ip[0] ) Log_Resolver( LOG_DEBUG, "Ok, translated \"%s\" to %s.", Host, ip );
#endif
+LOCAL RES_STAT *
+New_Res_Stat( VOID )
+{
+ RES_STAT *s;
+
+ /* Allocate memory */
+ s = (RES_STAT *)malloc( sizeof( RES_STAT ));
+ if( ! s )
+ {
+ Log( LOG_EMERG, "Resolver: Can't allocate memory! [Resolve_Addr]" );
+ return NULL;
+ }
+
+ /* Initialize pipe for result */
+ if( pipe( s->pipe ) != 0 )
+ {
+ free( s );
+ Log( LOG_ALERT, "Resolver: Can't create output pipe: %s!", strerror( errno ));
+ return NULL;
+ }
+
+ s->stage = 0;
+ s->bufpos = 0;
+ s->pid = -1;
+
+ return s;
+} /* New_Res_Stat */
+
+
/* -eof- */