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
5a27988c
Commit
5a27988c
authored
11 years ago
by
mcmlxxix
Browse files
Options
Downloads
Patches
Plain Diff
cnf file io library and definitions. (currently handles only msgs.cnf and xtrn.cnf)
parent
50ea3bc0
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/load/cnfdefs.js
+224
-0
224 additions, 0 deletions
exec/load/cnfdefs.js
exec/load/cnflib.js
+169
-0
169 additions, 0 deletions
exec/load/cnflib.js
with
393 additions
and
0 deletions
exec/load/cnfdefs.js
0 → 100644
+
224
−
0
View file @
5a27988c
/* CNF file reader/writer - mcmlxxix - 2013
$id: $
*/
/* miscellaneous constants required for cnf parsing
(if adding definitions to this file, make sure the required
constants are defined... if not, add them */
var
LEN_DIR
=
63
;
var
LEN_CMD
=
63
;
var
LEN_CODE
=
8
;
var
LEN_ARSTR
=
40
;
var
LEN_CODE
=
8
/* Maximum length of internal codes */
var
LEN_QWKID
=
8
/* Maximum length of QWK-ID */
var
LEN_MODNAME
=
8
/* Maximum length of readable module name */
var
LEN_SIFNAME
=
8
/* Maximum length of SIF filename */
var
LEN_EXTCODE
=
LEN_CODE
*
2
/* Code prefix + suffix */
var
LEN_GSNAME
=
15
/* Group/Lib short name */
var
LEN_GLNAME
=
40
/* Group/Lib long name */
var
LEN_SSNAME
=
25
/* Sub/Dir short name */
var
LEN_SLNAME
=
40
/* Sub/Dir long name */
var
UINT16_T
=
2
;
var
UINT32_T
=
4
;
var
UCHAR
=
1
;
/* CNF structure -
object properties must be in the same order as they are read from file
and any dependencies must be defined before a data structure that uses them */
var
struct
=
{};
/* external program record structures */
struct
.
swap_t
=
{
cmd
:
{
bytes
:
LEN_CMD
+
1
,
type
:
"
str
"
}
};
struct
.
xedit_t
=
{
name
:
{
bytes
:
41
,
type
:
"
str
"
},
code
:
{
bytes
:
LEN_CODE
+
1
,
type
:
"
str
"
},
lcmd
:
{
bytes
:
LEN_CMD
+
1
,
type
:
"
str
"
},
rcmd
:
{
bytes
:
LEN_CMD
+
1
,
type
:
"
str
"
},
misc
:
{
bytes
:
UINT32_T
,
type
:
"
int
"
},
arstr
:
{
bytes
:
LEN_ARSTR
+
1
,
type
:
"
str
"
},
type
:
{
bytes
:
UCHAR
,
type
:
"
int
"
},
__PADDING__
:
15
};
struct
.
xtrnsec_t
=
{
name
:
{
bytes
:
41
,
type
:
"
str
"
},
code
:
{
bytes
:
LEN_CODE
+
1
,
type
:
"
str
"
},
arstr
:
{
bytes
:
LEN_ARSTR
+
1
,
type
:
"
str
"
},
__PADDING__
:
16
};
struct
.
xtrn_t
=
{
sec
:
{
bytes
:
UINT16_T
,
type
:
"
int
"
},
name
:
{
bytes
:
41
,
type
:
"
str
"
},
code
:
{
bytes
:
LEN_CODE
+
1
,
type
:
"
str
"
},
arstr
:
{
bytes
:
LEN_ARSTR
+
1
,
type
:
"
str
"
},
run_arstr
:
{
bytes
:
LEN_ARSTR
+
1
,
type
:
"
str
"
},
type
:
{
bytes
:
UCHAR
,
type
:
"
int
"
},
misc
:
{
bytes
:
UINT32_T
,
type
:
"
int
"
},
event
:
{
bytes
:
UCHAR
,
type
:
"
int
"
},
cost
:
{
bytes
:
UINT32_T
,
type
:
"
int
"
},
cmd
:
{
bytes
:
LEN_CMD
+
1
,
type
:
"
str
"
},
clean
:
{
bytes
:
LEN_CMD
+
1
,
type
:
"
str
"
},
path
:
{
bytes
:
LEN_DIR
+
1
,
type
:
"
str
"
},
textra
:
{
bytes
:
UCHAR
,
type
:
"
int
"
},
maxtime
:
{
bytes
:
UCHAR
,
type
:
"
int
"
},
__PADDING__
:
14
};
struct
.
event_t
=
{
code
:
{
bytes
:
LEN_CODE
+
1
,
type
:
"
str
"
},
cmd
:
{
bytes
:
LEN_CMD
+
1
,
type
:
"
str
"
},
days
:
{
bytes
:
1
,
type
:
"
int
"
},
time
:
{
bytes
:
UINT16_T
,
type
:
"
int
"
},
node
:
{
bytes
:
UINT16_T
,
type
:
"
int
"
},
misc
:
{
bytes
:
UINT32_T
,
type
:
"
int
"
},
dir
:
{
bytes
:
LEN_DIR
+
1
,
type
:
"
str
"
},
freq
:
{
bytes
:
UINT16_T
,
type
:
"
int
"
},
mdays
:
{
bytes
:
UINT32_T
,
type
:
"
int
"
},
months
:
{
bytes
:
UINT16_T
,
type
:
"
int
"
},
__PADDING__
:
8
};
struct
.
natvpgm_t
=
{
name
:
{
bytes
:
13
,
type
:
"
str
"
},
misc
:
{
bytes
:
UINT32_T
,
type
:
"
int
"
}
};
struct
.
hotkey_t
=
{
key
:
{
bytes
:
UCHAR
,
type
:
"
int
"
},
cmd
:
{
bytes
:
LEN_CMD
+
1
,
type
:
"
str
"
},
__PADDING__
:
16
};
/* message group/sub record structures */
struct
.
faddr_t
=
{
faddr1
:
{
bytes
:
2
,
type
:
"
int
"
},
faddr2
:
{
bytes
:
2
,
type
:
"
int
"
},
faddr3
:
{
bytes
:
2
,
type
:
"
int
"
},
faddr4
:
{
bytes
:
2
,
type
:
"
int
"
}
};
struct
.
sub_t
=
{
grp
:
{
bytes
:
UINT16_T
,
type
:
"
int
"
},
lname
:
{
bytes
:
LEN_SLNAME
+
1
,
type
:
"
str
"
},
sname
:
{
bytes
:
LEN_SSNAME
+
1
,
type
:
"
str
"
},
qwkname
:
{
bytes
:
11
,
type
:
"
str
"
},
code_suffix
:{
bytes
:
LEN_CODE
+
1
,
type
:
"
str
"
},
data_dir
:
{
bytes
:
LEN_DIR
+
1
,
type
:
"
str
"
},
arstr
:
{
bytes
:
LEN_ARSTR
+
1
,
type
:
"
str
"
},
read_arstr
:
{
bytes
:
LEN_ARSTR
+
1
,
type
:
"
str
"
},
post_arstr
:
{
bytes
:
LEN_ARSTR
+
1
,
type
:
"
str
"
},
op_arstr
:
{
bytes
:
LEN_ARSTR
+
1
,
type
:
"
str
"
},
// uchar *ar,
// *read_ar,
// *post_ar,
// *op_ar,
misc
:
{
bytes
:
UINT32_T
,
type
:
"
int
"
},
tagline
:
{
bytes
:
81
,
type
:
"
str
"
},
origline
:
{
bytes
:
51
,
type
:
"
str
"
},
post_sem
:
{
bytes
:
LEN_DIR
+
1
,
type
:
"
str
"
},
newsgroup
:
{
bytes
:
LEN_DIR
+
1
,
type
:
"
str
"
},
faddr
:
{
bytes
:
struct
.
faddr_t
,
type
:
"
obj
"
},
maxmsgs
:
{
bytes
:
UINT32_T
,
type
:
"
int
"
},
maxcrcs
:
{
bytes
:
UINT32_T
,
type
:
"
int
"
},
maxage
:
{
bytes
:
UINT16_T
,
type
:
"
int
"
},
ptridx
:
{
bytes
:
UINT16_T
,
type
:
"
int
"
},
mod_arstr
:
{
bytes
:
LEN_ARSTR
+
1
,
type
:
"
str
"
},
// *mod_ar;
qwkconf
:
{
bytes
:
UINT16_T
,
type
:
"
int
"
},
__PADDING__
:
53
};
struct
.
grp_t
=
{
lname
:
{
bytes
:
LEN_GLNAME
+
1
,
type
:
"
str
"
},
sname
:
{
bytes
:
LEN_GSNAME
+
1
,
type
:
"
str
"
},
arstr
:
{
bytes
:
LEN_ARSTR
+
1
,
type
:
"
str
"
},
code_prefix
:{
bytes
:
LEN_CODE
+
1
,
type
:
"
str
"
},
// uchar *ar;
__PADDING__
:
87
};
struct
.
qhubsub_t
=
{
conf
:
{
bytes
:
UINT16_T
,
type
:
"
int
"
},
sub
:
{
bytes
:
UINT16_T
,
type
:
"
int
"
},
mode
:
{
bytes
:
UCHAR
,
type
:
"
int
"
}
};
struct
.
qhub_t
=
{
id
:
{
bytes
:
LEN_QWKID
+
1
,
type
:
"
str
"
},
time
:
{
bytes
:
UINT16_T
,
type
:
"
int
"
},
freq
:
{
bytes
:
UINT16_T
,
type
:
"
int
"
},
days
:
{
bytes
:
UCHAR
,
type
:
"
int
"
},
node
:
{
bytes
:
UINT16_T
,
type
:
"
int
"
},
call
:
{
bytes
:
LEN_CMD
+
1
,
type
:
"
str
"
},
pack
:
{
bytes
:
LEN_CMD
+
1
,
type
:
"
str
"
},
unpack
:
{
bytes
:
LEN_CMD
+
1
,
type
:
"
str
"
},
subs
:
{
bytes
:
struct
.
qhubsub_t
,
type
:
"
lst
"
},
// uint16_t *mode, /* Mode for Ctrl-A codes for ea. sub */
// *conf; /* Conference number of ea. */
// ulong *sub; /* Number of local sub-board for ea. */
// time32_t last; /* Last network attempt */
__PADDING__
:
64
};
struct
.
phub_t
=
{
days
:
{
bytes
:
1
,
type
:
"
str
"
},
name
:
{
bytes
:
11
,
type
:
"
str
"
},
call
:
{
bytes
:
LEN_CMD
+
1
,
type
:
"
str
"
},
time
:
{
bytes
:
UINT16_T
,
type
:
"
str
"
},
node
:
{
bytes
:
UINT16_T
,
type
:
"
str
"
},
freq
:
{
bytes
:
UINT16_T
,
type
:
"
str
"
},
// time32_t last; /* Last network attempt */
__PADDING__
:
64
};
/* NOTE: top-level data structures only below this point
as they may contain references to the data structures above
and will not work if they are defined first */
/* main external programs file structure (xtrn.cnf) */
struct
.
xtrn
=
{
swap
:
{
bytes
:
struct
.
swap_t
,
type
:
"
lst
"
},
xedit
:
{
bytes
:
struct
.
xedit_t
,
type
:
"
lst
"
},
xtrnsec
:
{
bytes
:
struct
.
xtrnsec_t
,
type
:
"
lst
"
},
xtrn
:
{
bytes
:
struct
.
xtrn_t
,
type
:
"
lst
"
},
event
:
{
bytes
:
struct
.
event_t
,
type
:
"
lst
"
},
natvpgm
:
{
bytes
:
struct
.
natvpgm_t
,
type
:
"
ntv
"
},
hotkey
:
{
bytes
:
struct
.
hotkey_t
,
type
:
"
lst
"
},
xtrn_misc
:
{
bytes
:
UINT32_T
,
type
:
"
int
"
}
};
/* main message group/sub file structure (msgs.cnf) */
struct
.
msg
=
{
max_qwkmsgs
:
{
bytes
:
UINT32_T
,
type
:
"
int
"
},
mail_maxcrcs
:
{
bytes
:
UINT32_T
,
type
:
"
int
"
},
mail_maxage
:
{
bytes
:
UINT16_T
,
type
:
"
int
"
},
preqwk_ar
:
{
bytes
:
LEN_ARSTR
+
1
,
type
:
"
str
"
},
smb_retry_time
:
{
bytes
:
UCHAR
,
type
:
"
int
"
},
max_qwkmsgage
:
{
bytes
:
UINT16_T
,
type
:
"
int
"
},
__PADDING1__
:
466
,
msg_misc
:
{
bytes
:
UINT32_T
,
type
:
"
int
"
},
__PADDING2__
:
510
,
grp
:
{
bytes
:
struct
.
grp_t
,
type
:
"
lst
"
},
sub
:
{
bytes
:
struct
.
sub_t
,
type
:
"
lst
"
},
faddr
:
{
bytes
:
struct
.
faddr_t
,
type
:
"
lst
"
},
origline
:
{
bytes
:
51
,
type
:
"
str
"
},
netmail_sem
:
{
bytes
:
LEN_DIR
+
1
,
type
:
"
str
"
},
echomail_sem
:
{
bytes
:
LEN_DIR
+
1
,
type
:
"
str
"
},
netmail_dir
:
{
bytes
:
LEN_DIR
+
1
,
type
:
"
str
"
},
echomail_dir
:
{
bytes
:
LEN_DIR
+
1
,
type
:
"
str
"
},
fidofile_dir
:
{
bytes
:
LEN_DIR
+
1
,
type
:
"
str
"
},
netmail_misc
:
{
bytes
:
UINT16_T
,
type
:
"
int
"
},
netmail_cost
:
{
bytes
:
UINT32_T
,
type
:
"
int
"
},
dflt_faddr
:
{
bytes
:
struct
.
faddr_t
,
type
:
"
obj
"
},
__PADDING3__
:
56
,
qnet_tagline
:
{
bytes
:
128
,
type
:
"
str
"
},
qhub
:
{
bytes
:
struct
.
qhub_t
,
type
:
"
lst
"
},
__PADDING4__
:
64
,
__PADDING5__
:
11
,
sys_psnum
:
{
bytes
:
UINT32_T
,
type
:
"
int
"
},
phub
:
{
bytes
:
struct
.
phub_t
,
type
:
"
lst
"
},
sys_psname
:
{
bytes
:
13
,
type
:
"
str
"
},
__PADDING6__
:
64
,
sys_inetaddr
:
{
bytes
:
128
,
type
:
"
str
"
},
inetmail_sem
:
{
bytes
:
LEN_DIR
+
1
,
type
:
"
str
"
},
inetmail_misc
:
{
bytes
:
UINT32_T
,
type
:
"
str
"
},
inetmail_cost
:
{
bytes
:
UINT32_T
,
type
:
"
str
"
},
smtpmail_sem
:
{
bytes
:
LEN_DIR
+
1
,
type
:
"
str
"
}
};
This diff is collapsed.
Click to expand it.
exec/load/cnflib.js
0 → 100644
+
169
−
0
View file @
5a27988c
js
.
global
.
load
(
js
.
global
,
"
cnfdefs.js
"
);
var
CNF
=
new
(
function
()
{
/* read an int from a cnf file */
function
getInt
(
file
,
bytes
)
{
var
i
=
file
.
readBin
(
bytes
);
return
i
;
}
/* read a string from a cnf file */
function
getStr
(
file
,
bytes
)
{
var
s
=
file
.
read
(
bytes
);
return
s
.
replace
(
/
\0
/g
,
''
);
}
/* write an int to a cnf file */
function
setInt
(
file
,
bytes
,
val
)
{
file
.
writeBin
(
val
,
bytes
);
}
/* write a null-padded string to a cnf file */
function
setStr
(
file
,
bytes
,
str
)
{
file
.
write
(
str
,
bytes
);
}
/* get record padding */
function
getPadding
(
file
,
bytes
)
{
file
.
position
+=
bytes
;
return
false
;
}
/* set record padding */
function
setPadding
(
file
,
bytes
)
{
setStr
(
file
,
bytes
,
""
);
}
/* read a set of records from xtrn.cnf */
function
readArray
(
file
,
struct
)
{
var
list
=
[];
var
records
=
getInt
(
file
,
UINT16_T
);
for
(
var
i
=
0
;
i
<
records
;
i
++
)
{
var
data
=
readRecord
(
file
,
struct
);
list
[
i
]
=
data
;
}
return
list
;
}
/* read an individual record */
function
readRecord
(
file
,
struct
)
{
var
data
=
{};
for
(
var
p
in
struct
)
{
if
(
file
.
eof
)
break
;
if
(
p
.
match
(
/__PADDING
\d
*__/
))
getPadding
(
file
,
struct
[
p
]);
else
{
switch
(
struct
[
p
].
type
)
{
case
"
int
"
:
data
[
p
]
=
getInt
(
file
,
struct
[
p
].
bytes
);
break
;
case
"
str
"
:
data
[
p
]
=
getStr
(
file
,
struct
[
p
].
bytes
);
break
;
case
"
obj
"
:
data
[
p
]
=
readRecord
(
file
,
struct
[
p
].
bytes
);
break
;
case
"
lst
"
:
data
[
p
]
=
readArray
(
file
,
struct
[
p
].
bytes
);
break
;
case
"
ntv
"
:
data
[
p
]
=
readNative
(
file
,
struct
[
p
].
bytes
);
break
;
}
}
}
return
data
;
}
/* read native programs list from xtrn.cnf (because digitalman broke the pattern) */
function
readNative
(
file
,
struct
)
{
var
list
=
[];
var
records
=
getInt
(
file
,
UINT16_T
);
for
(
var
i
=
0
;
i
<
records
;
i
++
)
{
var
data
=
{};
if
(
file
.
eof
)
break
;
data
.
name
=
getStr
(
file
,
struct
.
name
.
bytes
);
list
[
i
]
=
data
;
}
records
=
i
;
for
(
var
i
=
0
;
i
<
records
;
i
++
)
{
if
(
file
.
eof
)
break
;
list
[
i
].
misc
=
getInt
(
file
,
struct
.
misc
.
bytes
);
}
return
list
;
}
/* write a set of records to xtrn.cnf */
function
writeArray
(
file
,
struct
,
records
)
{
setInt
(
file
,
UINT16_T
,
records
.
length
);
for
(
var
i
=
0
;
i
<
records
.
length
;
i
++
)
{
writeRecord
(
file
,
struct
,
records
[
i
]);
}
}
/* write an individual record */
function
writeRecord
(
file
,
struct
,
record
)
{
for
(
var
p
in
struct
)
{
if
(
p
.
match
(
/__PADDING
\d
*__/
))
setPadding
(
file
,
struct
[
p
]);
else
{
switch
(
struct
[
p
].
type
)
{
case
"
int
"
:
setInt
(
file
,
struct
[
p
].
bytes
,
record
[
p
]);
break
;
case
"
str
"
:
setStr
(
file
,
struct
[
p
].
bytes
,
record
[
p
]);
break
;
case
"
obj
"
:
writeRecord
(
file
,
struct
[
p
].
bytes
,
record
[
p
]);
break
;
case
"
lst
"
:
writeArray
(
file
,
struct
[
p
].
bytes
,
record
[
p
]);
break
;
case
"
ntv
"
:
writeNative
(
file
,
struct
[
p
].
bytes
,
record
[
p
]);
break
;
}
}
}
}
/* write native programs list to xtrn.cnf */
function
writeNative
(
file
,
struct
,
records
)
{
setInt
(
file
,
UINT16_T
,
records
.
length
);
for
(
var
i
=
0
;
i
<
records
.
length
;
i
++
)
{
setStr
(
file
,
struct
.
name
.
bytes
,
records
[
i
].
name
);
}
for
(
var
i
=
0
;
i
<
records
;
i
++
)
{
setInt
(
file
,
struct
.
misc
.
bytes
,
records
[
i
].
misc
);
}
}
/* read records from .cnf file */
this
.
read
=
function
(
fileName
,
struct
)
{
var
f
=
new
File
(
fileName
);
f
.
open
(
'
rb
'
,
true
);
f
.
etx
=
3
;
var
data
=
readRecord
(
f
,
struct
);
f
.
close
();
return
data
;
}
/* write records to .cnf file */
this
.
write
=
function
(
fileName
,
struct
,
data
)
{
var
f
=
new
File
(
fileName
);
f
.
open
(
'
wb
'
,
true
);
writeRecord
(
f
,
struct
,
data
);
f
.
close
();
}
})();
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