lgfp = fopen(cfg.logfilename, "r");
time(&t); tm = *localtime(&t);   xlatlognam(currlogfilename,cfg.logfilename,cfg.host, &tm);  lgfp = fopen(currlogfilename, "r");
void logfopen(void){    char buf[256];    time_t t;    struct tm *tm;    char writemod[4];    if (!cfg.logtype)	return;    sprintf(writemod, "wb");	       /* default to rewrite */    lgfp = fopen(cfg.logfilename, "r");	/* file already present? */    if (lgfp) {	int i;	fclose(lgfp);	i = askappend(cfg.logfilename);	if (i == 1)	    writemod[0] = 'a';	       /* set append mode */	else if (i == 0) {	       /* cancelled */	    lgfp = NULL;	    cfg.logtype = 0;	       /* disable logging */	    return;	}    }    lgfp = fopen(cfg.logfilename, writemod);    if (lgfp) {			       /* enter into event log */	sprintf(buf, "%s session log (%s mode) to file : ",		(writemod[0] == 'a') ? "Appending" : "Writing new",		(cfg.logtype == LGTYP_ASCII ? "ASCII" :		 cfg.logtype == LGTYP_DEBUG ? "raw" : "<ukwn>"));	/* Make sure we do not exceed the output buffer size */	strncat(buf, cfg.logfilename, 128);	buf[strlen(buf)] = '\0';	logevent(buf);	/* --- write header line iinto log file */	fputs("=~=~=~=~=~=~=~=~=~=~=~= PuTTY log ", lgfp);	time(&t);	tm = localtime(&t);	strftime(buf, 24, "%Y.%m.%d %H:%M:%S", tm);	fputs(buf, lgfp);	fputs(" =~=~=~=~=~=~=~=~=~=~=~=\r\n", lgfp);    }}