3 * Copyright (C) 2002 Jaroslav Rohel <rohel@kn.vutbr.cz>
4 * inspired by ftpsys_unix writen by Florian Malita <mali@go.ro>
6 * This file is part of LUFS, a free userspace filesystem implementation.
7 * See http://lufs.sourceforge.net/ for updates.
9 * LUFS is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * LUFS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #include <sys/types.h>
38 #include <lufs/proto.h>
42 #include "ftpsys_netware.h"
46 while( (*c != ' ') && (*c != 0))
57 nth_word(char *line, int n){
61 for(c = line, i = 0; (c != NULL) && (i < n); i++)
67 ftpsys_netware::ftpsys_netware(){
68 CMD_LIST = "LIST -al";
71 ftpsys_netware::~ftpsys_netware(){
76 ftpsys_netware::parse_line(char *buf, char *file, struct lufs_fattr *fattr, char *link, struct credentials *cred){
77 unsigned long nlink, size;
81 char user[32], month[5], day[5], year[6], date[20];
84 *file = *link = user[0] = month[0] = day[0] = year[0] = 0;
87 if((res = sscanf(buf, "%*2s %*12s %32s %lu %3s %2s %5s %1024s", user, &size, month, day, year, file)) < 6){
88 WARN("could only match "<<res<<" attributes!");
93 sprintf(date,"%s,%s,%s", year, month, day);
95 memcpy(&tm, gmtime(&tt), sizeof(struct tm));
96 tm.tm_sec = tm.tm_min = tm.tm_hour = 0;
98 strptime(date, "%H:%M,%b,%d", &tm);
100 strptime(date, "%Y,%b,%d", &tm);
102 if(!strcmp(cred->user, user))
105 memset(fattr, 0, sizeof(struct lufs_fattr));
106 fattr->f_nlink = nlink;
107 fattr->f_size = size;
108 fattr->f_ctime = fattr->f_mtime = fattr->f_atime = mktime(&tm);
110 if(tolower(buf[0]) == 'd') fattr->f_mode = S_IFDIR;
111 else fattr->f_mode = S_IFREG;
113 fattr->f_mode |= S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP | S_IWOTH;
114 if (fattr->f_mode & S_IFDIR) fattr->f_mode |= S_IXUSR | S_IXGRP | S_IXOTH;
116 for(c = buf; *c; c++){
117 if((*c == 0x0a) || (*c == 0x0d)){
123 if((c = nth_word(buf, 8))){
125 TRACE("left: " << c);
130 strcpy(link, (cc + 3));
135 TRACE("file: " << file<<", link: " << link);