home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
GIFINFO1.ZIP
/
GIFINFO.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-11-25
|
5KB
|
180 lines
/* Aaron Walton 1990 */
#define INCL_DOS
#include <os2.h>
USHORT cbWritten, cbRead;
char achFailName[128];
HDIR hdir = 0xFFFF;
FILEFINDBUF findbuf;
USHORT usSearchCount = 1;
int code;
int find_result;
char *path;
char *temp_path;
char *error_log;
char *error_message;
ULONG ulFilePointer = 0;
HFILE open_fh;
USHORT usAction;
int open_result;
char *gif_file;
char msg_buf[100];
int dos_close;
int dos_read;
USHORT usAttribute;
int mode_result;
char szFoundFile[128];
int search_result = 0;
int error_check = 0;
struct GIF_INFO {
char Signature[6];
int Width;
int Height;
BYTE Color_Pixels;
BYTE background;
BYTE Reserved1;
} GIF_Info;
main(argc, argv)
int argc;
char *argv[];
{
/* DosWrite(1,"\r\nGIFINFO - version 1.00 - OS/2\r\n",32,&cbWritten);*/
path = (char *) malloc(128);
memset(path,0,128);
strcpy(path, argv[1]);
temp_path = (char *) malloc(128);
memset(temp_path,0,128);
strcpy(temp_path, strupr(path));
error_log = (char *) malloc(128);
memset(error_log,0,128);
error_message = (char *) malloc(128);
memset(error_message,0,128);
gif_file = (char *) malloc(128);
memset(gif_file,0,128);
findfirstgif();
if (find_result == 0)
findrestgif();
else
usage();
if (error_check != 0)
{
memset(error_message, 0, 128);
strcpy(error_message, "\r\n ");
strcat(error_message, szFoundFile);
DosWrite(1,error_message,strlen(error_message),&cbWritten);
}
DosExit(EXIT_THREAD,0);
}
findfirstgif()
{
find_result = DosFindFirst(path,&hdir,0x00,&findbuf,sizeof(findbuf),
&usSearchCount,0L);
if (find_result == 0)
{
justpathname(temp_path);
strcpy(gif_file, temp_path);
strcat(gif_file, findbuf.achName);
mode_result = DosQFileMode(gif_file,&usAttribute,0L);
open_result = DosOpen(gif_file, &open_fh, &usAction, 0L, 0x00, FILE_OPEN,
OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, 0L);
if (open_result == 0)
{
/* Read Header and Output Data */
dos_read = DosRead(open_fh, &GIF_Info, 13, &cbRead);
memset(error_message, 0, 128);
memset(error_log, 0, 128);
strcpy(error_message, findbuf.achName);
sprintf(error_log, " [%ux%ux%u]", GIF_Info.Width, GIF_Info.Height, 2^(GIF_Info.Color_Pixels & 0x90));
strcat(error_message, error_log);
strcat(error_message, "\n");
DosWrite(1,error_message,strlen(error_message),&cbWritten);
dos_close = DosClose(open_fh);
}
}
}
findrestgif()
{
while (DosFindNext(hdir,&findbuf,sizeof(findbuf),&usSearchCount) == 0)
{
strcpy(gif_file, temp_path);
strcat(gif_file, findbuf.achName);
mode_result = DosQFileMode(gif_file,&usAttribute,0L);
open_result = DosOpen(gif_file, &open_fh, &usAction, 0L, 0x00, FILE_OPEN,
OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, 0L);
if (open_result == 0)
{
dos_read = DosRead(open_fh, &GIF_Info, 13, &cbRead);
memset(error_message, 0, 128);
memset(error_log, 0, 128);
strcpy(error_message, findbuf.achName);
sprintf(error_log, " [%ux%ux%u]", GIF_Info.Width, GIF_Info.Height, 2^(GIF_Info.Color_Pixels & 0x90));
strcat(error_message, error_log);
strcat(error_message, "\n");
DosWrite(1,error_message,strlen(error_message),&cbWritten);
dos_close = DosClose(open_fh);
}
}
}
usage()
{
DosWrite(1,"\r\n",2,&cbWritten);
DosWrite(1,"Usage:",6,&cbWritten);
DosWrite(1,"\r\n\r\n",4,&cbWritten);
DosWrite(1,"GIFINFO n",9,&cbWritten);
DosWrite(1,"\r\n\r\n",4,&cbWritten);
DosWrite(1,"Where n is full path to GIF file/s to check",43,&cbWritten);
DosWrite(1,"\r\n\r\n",4,&cbWritten);
DosWrite(1,"Ex: GIFINFO C:\\FILES\\SOME*.GIF",32,&cbWritten);
DosWrite(1,"\r\n\r\n",4,&cbWritten);
DosWrite(1,"Ex: GIFINFO D:\\SOME*.GIF",24,&cbWritten);
DosWrite(1,"\r\n",2,&cbWritten);
}
justpathname(temp_path)
char temp_path[];
{
char *path;
char *drive;
char *dir;
char *fname;
char *ext;
path = (char *) malloc(128);
drive = (char *) malloc(128);
dir = (char *) malloc(128);
fname = (char *) malloc(128);
ext = (char *) malloc(128);
memset(path,0,128);
memset(drive,0,128);
memset(dir,0,128);
memset(fname,0,128);
memset(ext,0,128);
strcpy(path,temp_path);
_splitpath(temp_path,drive,dir,fname,ext);
strcpy(path,drive);
strcat(path,dir);
strcpy(temp_path,path);
free(path);
free(drive);
free(dir);
free(fname);
free(ext);
}