Esempio n. 1
0
void
klog(
    char *format,
    ...
    )
{
    FILE *logfile;
    long now;
    struct tm *tm;
    char *month_sname();
    va_list ap;

    va_start(ap, format);
    if ((logfile = fopen(log_name,"a")) == NULL)
        return;

    time(&now);
    tm = localtime(&now);

    fprintf(logfile,"%2d-%s-%02d %02d:%02d:%02d ",tm->tm_mday,
            month_sname(tm->tm_mon + 1),tm->tm_year,
            tm->tm_hour, tm->tm_min, tm->tm_sec);
    vfprintf(logfile, format, ap);
    fprintf(logfile, "\n");
    fclose(logfile);
    return;
}
Esempio n. 2
0
/*
 * display_link : Prints the contents of the given virtual link. If
 *	listflag is 0, then this uses last{host,path} to save state
 *	between calls for a less verbose output. If listflag is non-zero
 *	then all information is printed every time.
 */
void display_link(VLINK l,int listflag)
{
    PATTRIB 	ap;
    char	linkpath[MAX_VPATH];
    int		dirflag = 0;
#ifdef MSDOS
    unsigned long size = 0L;
#else
    int		size = 0;
#endif
    char	*modes = "";
    char	archie_date[20];
    char	*gt_date = "";
    int		gt_year = 0;
    int		gt_mon = 0;
    int		gt_day = 0;
    int		gt_hour = 0;
    int		gt_min = 0;
    
    /* Initialize local buffers */
    *archie_date = '\0';

    /* Remember if we're looking at a directory */
    if (sindex(l->type,"DIRECTORY"))
	dirflag = 1;
    else
	dirflag = 0;
    
    /* Extract the linkpath from the filename */
    strcpy(linkpath,l->filename);
    *(linkpath + (strlen(linkpath) - strlen(l->name) - 1)) = '\0';
    
    /* Is this a new host? */
    if (strcmp(l->host,lasthost) != 0) {
	if (!listflag)
	    printf("\nHost %s\n\n",l->host);
	strcpy(lasthost,l->host);
	*lastpath = '\001';
    }
    
    /* Is this a new linkpath (location)? */
    if(strcmp(linkpath,lastpath) != 0) {
	if (!listflag)
	    printf("    Location: %s\n",(*linkpath ? linkpath : "/"));
	strcpy(lastpath,linkpath);
    }
    
    /* Parse the attibutes of this link */
    for (ap = l->lattrib; ap; ap = ap->next) {
	if (strcmp(ap->aname,"SIZE") == 0) {
#ifdef MSDOS
	    sscanf(ap->value.ascii,"%lu",&size);
#else
	    sscanf(ap->value.ascii,"%d",&size);
#endif
	} else if(strcmp(ap->aname,"UNIX-MODES") == 0) {
	    modes = ap->value.ascii;
	} else if(strcmp(ap->aname,"LAST-MODIFIED") == 0) {
	    gt_date = ap->value.ascii;
	    sscanf(gt_date,"%4d%2d%2d%2d%2d",&gt_year,
		   &gt_mon, &gt_day, &gt_hour, &gt_min);
	    if ((12 * (presenttime->tm_year + 1900 - gt_year) + 
					presenttime->tm_mon - gt_mon) > 6) 
		sprintf(archie_date,"%s %2d %4d",month_sname(gt_mon),
			gt_day, gt_year);
	    else
		sprintf(archie_date,"%s %2d %02d:%02d",month_sname(gt_mon),
			 gt_day, gt_hour, gt_min);
	}
    }
    
    /* Print this link's information */
    if (listflag)
#if defined(MSDOS)
	printf("%s %6lu %s %s%s\n",gt_date,size,l->host,l->filename,
	       (dirflag ? "/" : ""));
#else
	printf("%s %6d %s %s%s\n",gt_date,size,l->host,l->filename,
	       (dirflag ? "/" : ""));
#endif
    else