home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
607.lha
/
AppServer_v3.01
/
ass.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-01-31
|
4KB
|
140 lines
/* AppServerServer 1.0 by Juha Tuominen 11-Jan-92
NOTE: If you're a fanatic noise module listener don't use
this program. The detecting part is quite simple and
it won't detect noise modules if you've changed modules' file
names. But who listens noise modules anyways? :-) */
#include <exec/types.h>
#include <libraries/dos.h>
#include <dos/dostags.h>
#include <libraries/dosextens.h>
#include <proto/dos.h>
#include <stdio.h>
#include <stdlib.h>
char picviewer[81]="c:show",
textviewer[81]="c:more",
sampleplayer[81]="c:play",
defa[81]="c:more",
itextviewer[81]="sys:system/notepad",
gifviewer[81]="c:virtgif",
modplayer[81]="c:modplayer",
lhunarc[81]="c:lhunarc",
unzip[81]="c:unzip",
unzoo[81]="c:unzoo",
animplayer[81]="c:rtap";
BOOL readconfig(void);
void lowercase(register char *dst,register char *src);
BOOL readconfig(void)
{ FILE *fp;
char thisline[81],nextline[81];
if(fp=fopen("s:ass-config","r"))
{ while(!feof(fp))
{ fgets(thisline,80,fp);
if(thisline[0]=='%')
{ fgets(nextline,80,fp);
nextline[strlen(nextline)-1]=0;
if(!strncmp("%picviewer:",thisline,11)) strcpy(picviewer,nextline);
if(!strncmp("%textviewer:",thisline,12)) strcpy(textviewer,nextline);
if(!strncmp("%itextviewer:",thisline,13)) strcpy(itextviewer,nextline);
if(!strncmp("%sampleplayer:",thisline,14)) strcpy(sampleplayer,nextline);
if(!strncmp("%gifviewer:",thisline,11)) strcpy(gifviewer,nextline);
if(!strncmp("%default:",thisline,9)) strcpy(defa,nextline);
if(!strncmp("%modplayer:",thisline,11)) strcpy(modplayer,nextline);
if(!strncmp("%lhunarc:",thisline,9)) strcpy(lhunarc,nextline);
if(!strncmp("%unzip:",thisline,7)) strcpy(unzip,nextline);
if(!strncmp("%unzoo:",thisline,7)) strcpy(unzoo,nextline);
if(!strncmp("%animplayer:",thisline,12)) strcpy(animplayer,nextline);
}
}
fclose(fp);
return TRUE;
}
return FALSE;
}
void lowercase(register char *dst,register char *src)
{ while(*dst++=tolower(*src++));
}
void main(int argc, char *argv[])
{ FILE *fp;
UBYTE buffer[81];
LONG err=0;
BOOL i=FALSE;
struct TagItem taglist[]={
{SYS_Input,NULL},
{SYS_Output,NULL},
{0,}
};
if(readconfig())
{ if(argc>1)
{ if(fp=fopen(argv[1],"rb"))
{ fgets(buffer,12,fp);
fclose(fp);
if(strncmp(buffer,"FORM",4))
{ if(!strncmp(buffer,"GIF87",5))
sprintf(buffer,"%s %s",gifviewer,argv[1]);
else
{ if(!strncmp(buffer+2,"-lh",3))
sprintf(buffer,"%s %s",lhunarc,argv[1]);
else
{ if(!strncmp(buffer,"ZOO",3))
sprintf(buffer,"%s %s",unzoo,argv[1]);
else
{ if(!strncmp(buffer,"PK",2))
sprintf(buffer,"%s %s",unzip,argv[1]);
else
{ while(err++<80 || !i)
{ if(buffer[err]>127)
i=TRUE;
}
if(!i)
sprintf(buffer,"%s %s",textviewer,argv[1]);
else
{ err=strlen(argv[1]);
lowercase(argv[1],argv[1]);
for(i=0;i<=err;i++)
buffer[i]=tolower(buffer[i]);
if(!strncmp(buffer,argv[1]+err-strlen(buffer),strlen(buffer)))
sprintf(buffer,"%s %s",modplayer,argv[1]);
else
sprintf(buffer,"%s %s",defa,argv[1]);
}
}
}
}
}
}
else
{ if(!strncmp(buffer+8,"ILBM",4))
sprintf(buffer,"%s %s",picviewer,argv[1]);
else
{ if(!strncmp(buffer+8,"WORD",4))
sprintf(buffer,"%s %s",itextviewer,argv[1]);
else
{ if(!strncmp(buffer+8,"8SVX",4))
sprintf(buffer,"%s %s",sampleplayer,argv[1]);
else
{ if(!strncmp(buffer+8,"ANIM",4))
sprintf(buffer,"%s %s",animplayer,argv[1]);
}
}
}
}
err=System(buffer,taglist);
}
}
}
}