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
e80abf79
Commit
e80abf79
authored
9 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
A simple SRIF FREQ processor for Synchronet... should work with binkd.
Not really tested yet.
parent
fab776d8
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
exec/freqit.js
+179
-0
179 additions, 0 deletions
exec/freqit.js
with
179 additions
and
0 deletions
exec/freqit.js
0 → 100644
+
179
−
0
View file @
e80abf79
// $Id$
/*
* Intentionally simple FREQ processor.
* Configure in binkd with the line:
* exec "/sbbs/exec/jsexec freqit *S" *.req *.REQ
*/
load
(
"
filebase.js
"
);
var
cfg
=
new
FREQITCfg
();
function
FREQITCfg
()
{
var
f
=
new
File
(
system
.
ctrl_dir
+
'
freqit.ini
'
);
var
val
;
if
(
!
f
.
open
(
'
r
'
))
{
log
(
LOG_ERROR
,
"
Unable to open '
"
+
f
.
name
+
"
'
"
);
return
;
}
// TODO: Support requiring passwords for specific files/dirs
this
.
dirs
=
[];
this
.
securedirs
=
[];
this
.
magic
=
{};
val
=
f
.
iniGetValue
(
null
,
'
Dirs
'
);
if
(
val
!=
undefined
)
this
.
dirs
=
val
.
toLowerCase
().
split
(
/,/
);
val
=
f
.
iniGetValue
(
null
,
'
SecureDirs
'
);
if
(
val
!=
undefined
)
this
.
securedirs
=
val
.
toLowerCase
().
split
(
/,/
);
this
.
maxfiles
=
f
.
iniGetValue
(
null
,
'
MaxFiles
'
,
10
);
f
.
iniGetSections
().
forEach
(
function
(
key
)
{
var
dir
=
f
.
iniGetValue
(
key
,
'
Dir
'
);
if
(
dir
==
undefined
)
{
log
(
LOG_ERROR
,
"
Magic value '
"
+
key
+
"
' without a dir configured
"
);
return
;
}
if
(
this
.
magic
===
undefined
)
this
.
magic
=
{};
this
.
magic
[
key
]
=
{};
this
.
magic
[
key
].
dir
=
dir
;
this
.
magic
[
key
].
match
=
f
.
iniGetValue
(
key
,
'
Match
'
,
'
*
'
);
this
.
magic
[
key
].
secure
=
f
.
iniGetValue
(
key
,
'
Secure
'
,
'
No
'
);
switch
(
this
.
magic
[
key
].
secure
.
toUpperCase
())
{
case
'
TRUE
'
:
case
'
YES
'
:
case
'
ON
'
:
this
.
magic
[
key
].
secure
=
true
;
break
;
default
:
if
(
parseInt
(
this
.
magic
[
key
].
secure
,
10
))
{
this
.
magic
[
key
].
secure
=
true
;
break
;
}
this
.
magic
[
key
].
secure
=
false
;
}
});
f
.
close
();
}
function
parse_srif
(
fname
)
{
var
f
=
new
File
(
fname
);
var
srif
=
{};
var
l
;
var
m
;
if
(
!
f
.
open
(
"
r
"
))
{
log
(
LOG_ERROR
,
"
Unable to find SRIF file '
"
+
f
.
name
+
"
'
"
);
return
undefined
;
}
while
(
l
=
f
.
readln
(
65535
))
{
if
((
m
=
l
.
match
(
/^
\s
*
([^
]
+
)\s
+
(
.*
)
$/
))
!==
null
)
srif
[
m
[
1
].
toLowerCase
()]
=
m
[
2
];
}
f
.
close
();
return
srif
;
}
var
dircache
=
{};
var
added
=
{};
var
files
=
0
;
function
add_file
(
filename
,
resp
)
{
if
(
filename
===
undefined
)
return
;
if
(
files
>=
cfg
.
maxfiles
)
return
;
if
(
added
[
filename
]
!==
undefined
)
return
;
resp
.
writeln
(
'
+
'
+
filename
);
files
++
;
added
[
filename
]
=
''
;
}
function
handle_magic
(
magic
,
resp
,
protected
,
pw
)
{
var
file
=
undefined
;
if
(
magic
.
secure
&&
!
protected
)
return
;
if
(
scan_magic
(
cfg
.
dirs
))
return
;
if
(
dircache
[
magic
.
dir
]
===
undefined
)
dircache
[
magic
.
dir
]
=
FileBase
(
magic
.
dir
);
dircache
[
magic
.
dir
].
forEach
(
function
(
fent
)
{
if
(
wildmatch
(
fent
.
name
,
magic
.
match
,
true
))
{
if
(
file
===
undefined
||
fent
.
uldate
>
file
.
uldate
)
file
=
fent
;
}
});
if
(
file
!==
undefined
)
{
add_file
(
file
.
path
,
resp
);
return
1
;
}
return
0
;
}
function
handle_regular
(
match
,
resp
,
protected
,
pw
)
{
var
file
=
undefined
;
var
count
=
0
;
function
handle_list
(
list
)
{
list
.
forEach
(
function
(
dir
)
{
if
(
dircache
[
dir
]
===
undefined
)
dircache
[
dir
]
=
FileBase
(
dir
);
dircache
[
dir
].
forEach
(
function
(
fent
)
{
if
(
wildmatch
(
fent
.
name
,
match
,
true
))
add_file
(
fent
.
path
,
resp
);
});
});
}
if
(
protected
)
handle_list
(
cfg
.
securedirs
);
handle_list
(
cfg
.
dirs
);
}
function
handle_srif
(
srif
)
{
var
req
=
new
File
(
srif
.
requestlist
);
var
resp
=
new
File
(
srif
.
responselist
);
var
m
;
var
fname
;
var
pw
;
if
(
!
req
.
open
(
"
r
"
))
return
;
if
(
!
resp
.
open
(
"
a
"
))
return
;
resp
.
position
=
resp
.
length
;
next_file
:
while
(
fname
=
req
.
readln
())
{
if
((
m
=
fname
.
match
(
/^
(
.*
)
!
(
.*
?)
$/
))
!==
null
)
{
pw
=
m
[
2
];
fname
=
m
[
1
];
}
// First, check for magic!
for
(
m
in
cfg
.
magic
)
{
if
(
m
==
fname
.
toLowerCase
())
{
handle_magic
(
cfg
.
magic
[
m
],
resp
,
srif
.
remotestatus
.
toLowerCase
()
===
'
protected
'
,
pw
);
continue
next_file
;
}
}
// Now, check for the file...
handle_regular
(
fname
,
resp
,
srif
.
remotestatus
.
toLowerCase
()
===
'
protected
'
,
pw
);
}
}
argv
.
forEach
(
function
(
fname
)
{
var
srif
=
parse_srif
(
fname
);
if
(
srif
!==
undefined
)
handle_srif
(
srif
);
});
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