home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1992 Michael Davidson.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software
- * and its documentation for any purpose and without fee is hereby
- * granted, provided that the above copyright notice appear in all
- * copies and that both that copyright notice and this permission
- * notice appear in supporting documentation.
- *
- * This software is provided "as is" without express or implied warranty.
- */
-
- #include <stdio.h>
- #include <errno.h>
-
- #include "vg.h"
-
- extern char *gifInfo(FILE *fp);
- extern char *jpegInfo(FILE *fp);
- extern char *pcdInfo(FILE *fp);
-
- void
- fileInfo(
- char *fname,
- char *info,
- int infolen
- )
- {
- FILE *fp;
- int f;
- long offset;
- char *p;
-
- errno = 0;
- if ((fp = fopen(fname, "r")) == NULL)
- {
- strncpy(info, strerror(errno), infolen);
- return;
- }
-
- f = getFileType(fname, fp);
- offset = ftell(fp);
-
- switch (f)
- {
- case F_GIF:
- p = gifInfo(fp);
- break;
-
- case F_JPEG:
- p = jpegInfo(fp);
- break;
-
- case F_PCD_O:
- case F_PCD_I:
- p = pcdInfo(fp);
- break;
-
- default:
- p = NULL;
- break;
- }
-
- if (p == NULL)
- p = "unknown file type";
-
- strncpy(info, p, infolen);
- if (offset == 128L)
- strcat(info, " (with MAC header)");
-
- fclose(fp);
- }
-