home *** CD-ROM | disk | FTP | other *** search
- /*
- * This source file is Copyright 1995 by Evan Scott.
- * All rights reserved.
- * Permission is granted to distribute this file provided no
- * fees beyond distribution costs are levied.
- */
-
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <exec/alerts.h>
-
- #include <devices/timer.h>
-
- #include <dos/dos.h>
- #include <dos/dosextens.h>
- #include <dos/dostags.h>
-
- #include <proto/exec.h>
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #include "evtypes.h"
- #include "verify.h"
- #include "tcp.h"
-
- #include "site.h"
- #include "ftp.h"
- #include "split.h"
- #include "ftpinfo.h"
- #include "connect.h"
-
- #include "globals.h"
-
- /*
- * ftpinfo routines
- */
-
- void add_ftpinfo(struct info_header *ih, b8 *name, struct DateStamp ds, b32 size, b32 blocks, b32 flags)
- {
- ftpinfo *fi;
- int len;
-
- verify(ih, V_info_header);
-
- len = strlen(name);
-
- fi = allocate(sizeof(*fi) + len + 1, V_ftpinfo);
- if (!fi) return;
-
- ensure(fi, V_ftpinfo);
-
- strcpy(fi->name, name);
-
- fi->modified = ds;
- fi->size = size;
- fi->blocks = blocks;
- fi->flags = flags;
-
- fi->next = ih->infos;
- ih->infos = fi;
-
- return;
- }
-
- void free_info_header(struct info_header *ih)
- {
- ftpinfo *fi, *fin;
-
- verify(ih, V_info_header);
-
- fi = ih->infos;
- while (fi) {
- verify(fi, V_ftpinfo);
- fin = fi->next;
-
- deallocate(fi, V_ftpinfo);
- fi = fin;
- }
-
- if (ih->next)
- ih->next->prev = ih->prev;
-
- *(ih->prev) = ih->next;
-
- deallocate(ih, V_info_header);
-
- return;
- }
-
- struct info_header *new_info_header(site *sp, b8 *name)
- {
- struct info_header *ih;
-
- verify(sp, V_site);
-
- ih = (struct info_header *)allocate(sizeof(*ih) + strlen(name) + 1, V_info_header);
- if (!ih) return nil;
-
- ensure(ih, V_info_header);
-
- ih->infos = nil;
-
- ih->next = sp->infos;
- if (sp->infos) sp->infos->prev = &(ih->next);
- sp->infos = ih;
- ih->prev = &(sp->infos);
-
- strcpy(ih->name, name);
-
- ih->case_sensitive = sp->case_sensitive;
-
- return ih;
- }
-
- struct info_header *find_info_header(site *sp, b8 *name)
- {
- struct info_header *ih;
-
- verify(sp, V_site);
-
- ih = sp->infos;
-
- if (sp->case_sensitive) {
- while (ih) {
- if (strcmp(ih->name, name) == 0) return ih;
- ih = ih->next;
- }
- } else {
- while (ih) {
- if (stricmp(ih->name, name) == 0) return ih;
- ih = ih->next;
- }
- }
-
- return nil;
- }
-
- ftpinfo *find_info(struct info_header *ih, b8 *name)
- {
- ftpinfo *fi;
-
- fi = ih->infos;
- if (ih->case_sensitive) {
- while (fi) {
- if (strcmp(fi->name, name) == 0 && !(fi->flags & MYFLAG_DELETED) ) return fi;
- fi = fi->next;
- }
- } else {
- while (fi) {
- if (stricmp(fi->name, name) == 0 && !(fi->flags & MYFLAG_DELETED) ) return fi;
- fi = fi->next;
- }
- }
-
- return nil;
- }
-