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
6ffce6e3
Commit
6ffce6e3
authored
9 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Split out FREQIT into a separate SRIF handler and FREQIT object to allow
embedding REQ handling into binkit.
parent
e41f7ff2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
exec/freqit.js
+18
-71
18 additions, 71 deletions
exec/freqit.js
exec/load/freqit_common.js
+58
-0
58 additions, 0 deletions
exec/load/freqit_common.js
with
76 additions
and
71 deletions
exec/freqit.js
+
18
−
71
View file @
6ffce6e3
...
...
@@ -5,10 +5,21 @@
* exec "/sbbs/exec/jsexec freqit *S" *.req *.REQ
*/
load
(
"
filebase.js
"
);
load
(
"
fidocfg.js
"
);
load
(
"
freqit_common.js
"
);
var
cfg
=
new
FREQITCfg
();
FREQIT
.
add_file
=
function
(
filename
,
resp
,
cfg
)
{
if
(
filename
===
undefined
)
return
;
if
(
FREQIT
.
files
>=
cfg
.
maxfiles
)
return
;
if
(
FREQIT
.
added
[
filename
]
!==
undefined
)
return
;
resp
.
writeln
(
'
+
'
+
filename
);
FREQIT
.
files
++
;
FREQIT
.
added
[
filename
]
=
''
;
};
function
parse_srif
(
fname
)
{
...
...
@@ -21,7 +32,7 @@ function parse_srif(fname)
log
(
LOG_ERROR
,
"
Unable to find SRIF file '
"
+
f
.
name
+
"
'
"
);
return
undefined
;
}
while
(
l
=
f
.
readln
(
65535
))
{
while
(
(
l
=
f
.
readln
(
65535
))
)
{
if
((
m
=
l
.
match
(
/^
\s
*
([^
]
+
)\s
+
(
.*
)
$/
))
!==
null
)
srif
[
m
[
1
].
toLowerCase
()]
=
m
[
2
];
}
...
...
@@ -29,71 +40,6 @@ function parse_srif(fname)
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
]
=
''
;
}
/*
* TODO: built-in magic names... FILES and NEW
* FILES lists all FREQable files and
* NEW lists ones newer than 10 days.
*/
function
handle_magic
(
magic
,
resp
,
protected
,
pw
)
{
var
file
=
undefined
;
if
(
magic
.
secure
&&
!
protected
)
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
);
...
...
@@ -101,6 +47,7 @@ function handle_srif(srif)
var
m
;
var
fname
;
var
pw
;
var
cfg
=
new
FREQITCfg
();
if
(
!
req
.
open
(
"
r
"
))
return
;
...
...
@@ -109,7 +56,7 @@ function handle_srif(srif)
resp
.
position
=
resp
.
length
;
next_file
:
while
(
fname
=
req
.
readln
())
{
while
(
(
fname
=
req
.
readln
())
)
{
if
((
m
=
fname
.
match
(
/^
(
.*
)
!
(
.*
?)
$/
))
!==
null
)
{
pw
=
m
[
2
];
fname
=
m
[
1
];
...
...
@@ -117,13 +64,13 @@ function handle_srif(srif)
// First, check for magic!
for
(
m
in
cfg
.
magic
)
{
if
(
m
==
fname
.
toLowerCase
())
{
handle_magic
(
cfg
.
magic
[
m
],
resp
,
srif
.
remotestatus
.
toLowerCase
()
===
'
protected
'
,
pw
);
FREQIT
.
handle_magic
(
cfg
.
magic
[
m
],
resp
,
srif
.
remotestatus
.
toLowerCase
()
===
'
protected
'
,
pw
,
cfg
);
continue
next_file
;
}
}
// Now, check for the file...
handle_regular
(
fname
,
resp
,
srif
.
remotestatus
.
toLowerCase
()
===
'
protected
'
,
pw
);
FREQIT
.
handle_regular
(
fname
,
resp
,
srif
.
remotestatus
.
toLowerCase
()
===
'
protected
'
,
pw
,
cfg
);
}
}
...
...
This diff is collapsed.
Click to expand it.
exec/load/freqit_common.js
0 → 100644
+
58
−
0
View file @
6ffce6e3
/*
* TODO: built-in magic names... FILES and NEW
* FILES lists all FREQable files and
* NEW lists ones newer than 10 days.
*/
load
(
"
filebase.js
"
);
var
FREQIT
=
{
dircache
:{},
added
:{},
files
:
0
,
reset
:
function
()
{
this
.
added
=
{};
this
.
files
=
0
;
},
handle_magic
:
function
(
magic
,
cb_data
,
protected
,
pw
,
cfg
)
{
var
file
=
undefined
;
if
(
magic
.
secure
&&
!
protected
)
return
;
if
(
this
.
dircache
[
magic
.
dir
]
===
undefined
)
this
.
dircache
[
magic
.
dir
]
=
new
FileBase
(
magic
.
dir
);
this
.
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
)
{
this
.
add_file
(
file
.
path
,
cb_data
,
cfg
);
return
1
;
}
return
0
;
},
handle_regular
:
function
(
match
,
cb_data
,
protected
,
pw
,
cfg
)
{
var
file
=
undefined
;
var
count
=
0
;
function
handle_list
(
list
)
{
list
.
forEach
(
function
(
dir
)
{
if
(
this
.
dircache
[
dir
]
===
undefined
)
this
.
dircache
[
dir
]
=
new
FileBase
(
dir
);
this
.
dircache
[
dir
].
forEach
(
function
(
fent
)
{
if
(
wildmatch
(
fent
.
name
,
match
,
true
))
this
.
add_file
(
fent
.
path
,
cb_data
);
});
});
}
if
(
protected
)
handle_list
(
cfg
.
securedirs
);
handle_list
(
cfg
.
dirs
);
}
};
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