Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
83d84a36
Commit
83d84a36
authored
23 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Added FILE_ID.DIZ/DESC.SDI support (yea!).
parent
295bd7a5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/ftpsrvr.c
+187
-4
187 additions, 4 deletions
src/sbbs3/ftpsrvr.c
with
187 additions
and
4 deletions
src/sbbs3/ftpsrvr.c
+
187
−
4
View file @
83d84a36
...
@@ -1121,6 +1121,137 @@ int sockreadline(SOCKET socket, char* buf, int len, time_t* lastactive)
...
@@ -1121,6 +1121,137 @@ int sockreadline(SOCKET socket, char* buf, int len, time_t* lastactive)
return
(
rd
);
return
(
rd
);
}
}
/*****************************************************************************/
/* Returns command line generated from instr with %c replacments */
/*****************************************************************************/
char
*
cmdstr
(
user_t
*
user
,
char
*
instr
,
char
*
fpath
,
char
*
fspec
,
char
*
cmd
)
{
char
str
[
256
];
int
i
,
j
,
len
;
#ifdef _WIN32
char
sfpath
[
MAX_PATH
];
#endif
len
=
strlen
(
instr
);
for
(
i
=
j
=
0
;
i
<
len
;
i
++
)
{
if
(
instr
[
i
]
==
'%'
)
{
i
++
;
cmd
[
j
]
=
0
;
switch
(
toupper
(
instr
[
i
]))
{
case
'A'
:
/* User alias */
strcat
(
cmd
,
user
->
alias
);
break
;
case
'B'
:
/* Baud (DTE) Rate */
case
'C'
:
/* Connect Description */
case
'D'
:
/* Connect (DCE) Rate */
case
'E'
:
/* Estimated Rate */
case
'H'
:
/* Port Handle or Hardware Flow Control */
case
'P'
:
/* COM Port */
case
'R'
:
/* Rows */
case
'T'
:
/* Time left in seconds */
case
'&'
:
/* Address of msr */
case
'Y'
:
/* COMSPEC */
/* UNSUPPORTED */
break
;
case
'F'
:
/* File path */
strcat
(
cmd
,
fpath
);
break
;
case
'G'
:
/* Temp directory */
strcat
(
cmd
,
scfg
.
temp_dir
);
break
;
case
'I'
:
/* UART IRQ Line */
strcat
(
cmd
,
ultoa
(
scfg
.
com_irq
,
str
,
10
));
break
;
case
'J'
:
strcat
(
cmd
,
scfg
.
data_dir
);
break
;
case
'K'
:
strcat
(
cmd
,
scfg
.
ctrl_dir
);
break
;
case
'L'
:
/* Lines per message */
strcat
(
cmd
,
ultoa
(
scfg
.
level_linespermsg
[
user
->
level
],
str
,
10
));
break
;
case
'M'
:
/* Minutes (credits) for user */
strcat
(
cmd
,
ultoa
(
user
->
min
,
str
,
10
));
break
;
case
'N'
:
/* Node Directory (same as SBBSNODE environment var) */
strcat
(
cmd
,
scfg
.
node_dir
);
break
;
case
'O'
:
/* SysOp */
strcat
(
cmd
,
scfg
.
sys_op
);
break
;
case
'Q'
:
/* QWK ID */
strcat
(
cmd
,
scfg
.
sys_id
);
break
;
case
'S'
:
/* File Spec */
strcat
(
cmd
,
fspec
);
break
;
case
'U'
:
/* UART I/O Address (in hex) */
strcat
(
cmd
,
ultoa
(
scfg
.
com_base
,
str
,
16
));
break
;
case
'V'
:
/* Synchronet Version */
sprintf
(
str
,
"%s%c"
,
VERSION
,
REVISION
);
break
;
case
'W'
:
/* Time-slice API type (mswtype) */
#if 0 //ndef __FLAT__
strcat(cmd,ultoa(mswtyp,str,10));
#endif
break
;
case
'X'
:
strcat
(
cmd
,
scfg
.
shell
[
user
->
shell
]
->
code
);
break
;
case
'Z'
:
strcat
(
cmd
,
scfg
.
text_dir
);
break
;
case
'~'
:
/* DOS-compatible (8.3) filename */
#ifdef _WIN32
strcpy
(
sfpath
,
fpath
);
GetShortPathName
(
fpath
,
sfpath
,
sizeof
(
sfpath
));
strcat
(
cmd
,
sfpath
);
#else
strcat
(
cmd
,
fpath
);
#endif
break
;
case
'!'
:
/* EXEC Directory */
strcat
(
cmd
,
scfg
.
exec_dir
);
break
;
case
'#'
:
/* Node number (same as SBBSNNUM environment var) */
sprintf
(
str
,
"%d"
,
scfg
.
node_num
);
strcat
(
cmd
,
str
);
break
;
case
'*'
:
sprintf
(
str
,
"%03d"
,
scfg
.
node_num
);
strcat
(
cmd
,
str
);
break
;
case
'$'
:
/* Credits */
strcat
(
cmd
,
ultoa
(
user
->
cdt
+
user
->
freecdt
,
str
,
10
));
break
;
case
'%'
:
/* %% for percent sign */
strcat
(
cmd
,
"%"
);
break
;
case
'?'
:
/* Platform */
#ifdef __OS2__
strcpy
(
str
,
"OS2"
);
#else
strcpy
(
str
,
PLATFORM_DESC
);
#endif
strlwr
(
str
);
strcat
(
cmd
,
str
);
break
;
default:
/* unknown specification */
if
(
isdigit
(
instr
[
i
]))
{
sprintf
(
str
,
"%0*d"
,
instr
[
i
]
&
0xf
,
user
->
number
);
strcat
(
cmd
,
str
);
}
break
;
}
j
=
strlen
(
cmd
);
}
else
cmd
[
j
++
]
=
instr
[
i
];
}
cmd
[
j
]
=
0
;
return
(
cmd
);
}
void
DLLCALL
ftp_terminate
(
void
)
void
DLLCALL
ftp_terminate
(
void
)
{
{
if
(
server_socket
!=
INVALID_SOCKET
)
{
if
(
server_socket
!=
INVALID_SOCKET
)
{
...
@@ -1313,7 +1444,12 @@ static void send_thread(void* arg)
...
@@ -1313,7 +1444,12 @@ static void send_thread(void* arg)
static
void
receive_thread
(
void
*
arg
)
static
void
receive_thread
(
void
*
arg
)
{
{
char
buf
[
8192
];
char
buf
[
8192
];
char
ext
[
F_EXBSIZE
+
1
];
char
desc
[
F_EXBSIZE
+
1
];
char
cmd
[
MAX_PATH
*
2
];
char
tmp
[
MAX_PATH
+
1
];
char
fname
[
MAX_PATH
+
1
];
char
fname
[
MAX_PATH
+
1
];
int
i
;
int
rd
;
int
rd
;
int
file
;
int
file
;
ulong
total
=
0
;
ulong
total
=
0
;
...
@@ -1439,14 +1575,58 @@ static void receive_thread(void* arg)
...
@@ -1439,14 +1575,58 @@ static void receive_thread(void* arg)
f
.
timesdled
=
0
;
f
.
timesdled
=
0
;
f
.
datedled
=
0L
;
f
.
datedled
=
0L
;
f
.
opencount
=
0
;
f
.
opencount
=
0
;
if
(
xfer
.
desc
==
NULL
||
*
xfer
.
desc
==
0
)
{
sprintf
(
f
.
desc
,
"%.*s"
,(
int
)
sizeof
(
f
.
desc
)
-
1
,
getfname
(
xfer
.
filename
));
/* Desciption specified with DESC command? */
/* old way strcpy(f.desc,"Received via FTP: No description given"); */
if
(
xfer
.
desc
!=
NULL
&&
*
xfer
.
desc
!=
0
)
}
else
sprintf
(
f
.
desc
,
"%.*s"
,(
int
)
sizeof
(
f
.
desc
)
-
1
,
xfer
.
desc
);
sprintf
(
f
.
desc
,
"%.*s"
,(
int
)
sizeof
(
f
.
desc
)
-
1
,
xfer
.
desc
);
/* FILE_ID.DIZ support */
if
(
scfg
.
dir
[
f
.
dir
]
->
misc
&
DIR_DIZ
)
{
for
(
i
=
0
;
i
<
scfg
.
total_fextrs
;
i
++
)
if
(
!
stricmp
(
scfg
.
fextr
[
i
]
->
ext
,
f
.
name
+
9
)
&&
chk_ar
(
&
scfg
,
scfg
.
fextr
[
i
]
->
ar
,
xfer
.
user
))
break
;
if
(
i
<
scfg
.
total_fextrs
)
{
sprintf
(
tmp
,
"%sFILE_ID.DIZ"
,
scfg
.
temp_dir
);
remove
(
tmp
);
system
(
cmdstr
(
xfer
.
user
,
scfg
.
fextr
[
i
]
->
cmd
,
fname
,
"FILE_ID.DIZ"
,
cmd
));
if
(
!
fexist
(
tmp
))
{
sprintf
(
tmp
,
"%sDESC.SDI"
,
scfg
.
temp_dir
);
remove
(
tmp
);
system
(
cmdstr
(
xfer
.
user
,
scfg
.
fextr
[
i
]
->
cmd
,
fname
,
"DESC.SDI"
,
cmd
));
}
if
((
file
=
nopen
(
tmp
,
O_RDONLY
))
!=-
1
)
{
memset
(
ext
,
0
,
sizeof
(
ext
));
read
(
file
,
ext
,
sizeof
(
ext
)
-
1
);
for
(
i
=
sizeof
(
ext
)
-
1
;
i
;
i
--
)
if
(
ext
[
i
-
1
]
>
SP
)
break
;
ext
[
i
]
=
0
;
if
(
!
f
.
desc
[
0
])
{
strcpy
(
desc
,
ext
);
strip_exascii
(
desc
);
strip_ctrl
(
desc
);
for
(
i
=
0
;
desc
[
i
];
i
++
)
if
(
isalnum
(
desc
[
i
]))
break
;
sprintf
(
f
.
desc
,
"%.*s"
,
LEN_FDESC
,
desc
+
i
);
}
close
(
file
);
remove
(
tmp
);
f
.
misc
|=
FM_EXTDESC
;
}
}
}
/* FILE_ID.DIZ support */
if
(
f
.
desc
[
0
]
==
0
)
/* no description given, use (long) filename */
sprintf
(
f
.
desc
,
"%.*s"
,(
int
)
sizeof
(
f
.
desc
)
-
1
,
getfname
(
xfer
.
filename
));
strcpy
(
f
.
uler
,
xfer
.
user
->
alias
);
strcpy
(
f
.
uler
,
xfer
.
user
->
alias
);
if
(
!
addfiledat
(
&
scfg
,
&
f
))
if
(
!
addfiledat
(
&
scfg
,
&
f
))
lprintf
(
"%04d !ERROR adding file (%s) to database"
,
xfer
.
ctrl_sock
,
f
.
name
);
lprintf
(
"%04d !ERROR adding file (%s) to database"
,
xfer
.
ctrl_sock
,
f
.
name
);
if
(
f
.
misc
&
FM_EXTDESC
)
putextdesc
(
&
scfg
,
f
.
dir
,
f
.
datoffset
,
ext
);
if
(
scfg
.
dir
[
f
.
dir
]
->
upload_sem
[
0
])
if
(
scfg
.
dir
[
f
.
dir
]
->
upload_sem
[
0
])
if
((
file
=
sopen
(
scfg
.
dir
[
f
.
dir
]
->
upload_sem
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
SH_DENYNO
))
!=-
1
)
if
((
file
=
sopen
(
scfg
.
dir
[
f
.
dir
]
->
upload_sem
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
SH_DENYNO
))
!=-
1
)
close
(
file
);
close
(
file
);
...
@@ -3932,6 +4112,9 @@ void DLLCALL ftp_server(void* arg)
...
@@ -3932,6 +4112,9 @@ void DLLCALL ftp_server(void* arg)
return
;
return
;
}
}
/* Use DATA/TEMP for temp dir - should ch'd to be FTP/HOST specific */
prep_dir
(
scfg
.
data_dir
,
scfg
.
temp_dir
);
if
(
!
startup
->
max_clients
)
{
if
(
!
startup
->
max_clients
)
{
startup
->
max_clients
=
scfg
.
sys_nodes
;
startup
->
max_clients
=
scfg
.
sys_nodes
;
if
(
startup
->
max_clients
<
10
)
if
(
startup
->
max_clients
<
10
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment