rem: cpl_orig_tz = getenv("TZ");
add: if ( (ptr=getenv("TZ"))!=0 ) { cpl_orig_tz.len = 3 + strlen(ptr) + 1; if ( (cpl_orig_tz.s=shm_malloc(cpl_orig_tz.len))==0 ) { LOG(L_ERR,"ERROR:cpl_init: no more shm mem. for saving TZ!\n"); goto error; } memcpy(cpl_orig_tz.s,"TZ=",3); strcpy(cpl_orig_tz.s+3,ptr); }
context: static int cpl_init(void){	load_tm_f  load_tm;	struct stat stat_t;	int val;	LOG(L_INFO,"CPL - initializing\n");	/* check the module params */	if (DB_URL==0) {		LOG(L_CRIT,"ERROR:cpl_init: mandatory parameter \"DB_URL\" "			"found empty\n");		goto error;	}	if (DB_TABLE==0) {		LOG(L_CRIT,"ERROR:cpl_init: mandatory parameter \"DB_TABLE\" "			"found empty\n");		goto error;	}	if (dtd_file==0) {		LOG(L_CRIT,"ERROR:cpl_init: mandatory parameter \"cpl_dtd_file\" "			"found empty\n");		goto error;	} else {		/* check if the dtd file exists */		if (stat( dtd_file, &stat_t)==-1) {			LOG(L_ERR,"ERROR:cpl_init: checking file \"%s\" status failed;"				" stat returned %s\n",dtd_file,strerror(errno));			goto error;		}		if ( !S_ISREG( stat_t.st_mode ) ) {			LOG(L_ERR,"ERROR:cpl_init: dir \"%s\" is not a regular file!\n",				dtd_file);			goto error;		}		if (access( dtd_file, R_OK )==-1) {			LOG(L_ERR,"ERROR:cpl_init: checking file \"%s\" for permissions "				"failed; access returned %s\n",dtd_file,strerror(errno));			goto error;		}	}	if (log_dir==0) {		LOG(L_WARN,"WARNING:cpl_init: log_dir param found void -> logging "			" disabled!\n");	} else {		if ( strlen(log_dir)>MAX_LOG_DIR_SIZE ) {			LOG(L_ERR,"ERROR:cpl_init: dir \"%s\" has a too long name :-(!\n",				log_dir);			goto error;		}		/* check if the dir exists */		if (stat( log_dir, &stat_t)==-1) {			LOG(L_ERR,"ERROR:cpl_init: checking dir \"%s\" status failed;"				" stat returned %s\n",log_dir,strerror(errno));			goto error;		}		if ( !S_ISDIR( stat_t.st_mode ) ) {			LOG(L_ERR,"ERROR:cpl_init: dir \"%s\" is not a directory!\n",				log_dir);			goto error;		}		if (access( log_dir, R_OK|W_OK )==-1) {			LOG(L_ERR,"ERROR:cpl_init: checking dir \"%s\" for permissions "				"failed; access returned %s\n",log_dir,strerror(errno));			goto error;		}	}	/* bind to the mysql module */	if (bind_dbmod()) {		LOG(L_CRIT,"ERROR:cpl_init: cannot bind to database module! "			"Did you forget to load a database module ?\n");		goto error;	}	/* import the TM auto-loading function */	if ( !(load_tm=(load_tm_f)find_export("load_tm", NO_SCRIPT, 0))) {		LOG(L_ERR, "ERROR:cpl_c:cpl_init: cannot import load_tm\n");		goto error;	}	/* let the auto-loading function load all TM stuff */	if (load_tm( &cpl_tmb )==-1)		goto error;	/* register the fifo commands */	if (register_fifo_cmd( cpl_load, "LOAD_CPL", 0)!=1) {		LOG(L_CRIT,"ERROR:cpl_init: cannot register LOAD_CPL fifo cmd!\n");		goto error;	}	if (register_fifo_cmd( cpl_remove, "REMOVE_CPL", 0)!=1) {		LOG(L_CRIT,"ERROR:cpl_init: cannot register REMOVE_CPL fifo cmd!\n");		goto error;	}	/* build a pipe for sending commands to aux proccess */	if ( pipe(cpl_cmd_pipe)==-1 ) {		LOG(L_CRIT,"ERROR:cpl_init: cannot create command pipe: %s!\n",			strerror(errno) );		goto error;	}	/* set the writing non blocking */	if ( (val=fcntl(cpl_cmd_pipe[1], F_GETFL, 0))<0 ) {		LOG(L_ERR,"ERROR:cpl_init: getting flags from pipe[1] failed: fcntl "			"said %s!\n",strerror(errno));		goto error;	}	if ( fcntl(cpl_cmd_pipe[1], F_SETFL, val|O_NONBLOCK) ) {		LOG(L_ERR,"ERROR:cpl_init: setting flags to pipe[1] failed: fcntl "			"said %s!\n",strerror(errno));		goto error;	}	/* init the CPL parser */	if (init_CPL_parser( dtd_file )!=1 ) {		LOG(L_ERR,"ERROR:cpl_init: init_CPL_parser failed!\n");		goto error;	}	/* get a pointer to the original TZ env. variable */	cpl_orig_tz = getenv("TZ");	return 0;error:	return -1;}