mirror of
https://github.com/ksherlock/gopher.git
synced 2024-12-21 06:29:39 +00:00
set the filetype based on the extension.
This commit is contained in:
parent
8c5c7e43c6
commit
b4242ec271
9
ftype.c
9
ftype.c
@ -1,13 +1,20 @@
|
||||
#pragma optimize 79
|
||||
|
||||
#include <Types.h>
|
||||
|
||||
int parse_ftype(const char *cp, Word size, Word *ftype, Word *atype)
|
||||
{
|
||||
Word *wp = (Word *)cp;
|
||||
Word h;
|
||||
|
||||
*ftype = 0;
|
||||
*atype = 0;
|
||||
|
||||
switch ((*cp | 0x20) ^ size)
|
||||
if (!cp || !size) return 0;
|
||||
|
||||
h = ((*cp | 0x20) ^ size) & 0x0f;
|
||||
|
||||
switch (h)
|
||||
{
|
||||
case 0x00:
|
||||
// shk
|
||||
|
@ -6,11 +6,16 @@
|
||||
int parse_ftype(const char *cp, Word size, Word *ftype, Word *atype)
|
||||
{
|
||||
Word *wp = (Word *)cp;
|
||||
|
||||
Word h;
|
||||
|
||||
*ftype = 0;
|
||||
*atype = 0;
|
||||
|
||||
switch ((*cp | 0x20) ^ size)
|
||||
if (!cp || !size) return 0;
|
||||
|
||||
h = ((*cp | 0x20) ^ size) & 0x0f;
|
||||
|
||||
switch (h)
|
||||
{
|
||||
%%
|
||||
}
|
||||
|
5
gopher.c
5
gopher.c
@ -16,6 +16,8 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
extern int setfiletype(const char *filename);
|
||||
|
||||
/*
|
||||
* connect gopher.floodgap.com:70
|
||||
* send path
|
||||
@ -566,6 +568,7 @@ int main(int argc, char **argv)
|
||||
filename, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
setfiletype(filename);
|
||||
}
|
||||
else if (flagO)
|
||||
{
|
||||
@ -586,6 +589,8 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
setfiletype(filename);
|
||||
|
||||
free(filename);
|
||||
filename = NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user