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
bb6a9538
Commit
bb6a9538
authored
2 months ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Create/use ar_type() to eliminate some copy/pasta in AR/ARS parsing logic
parent
0c6913fb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#7757
failed
2 months ago
Stage: build
Stage: test
Stage: cleanup
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/sbbs3/ars.c
+10
-42
10 additions, 42 deletions
src/sbbs3/ars.c
src/sbbs3/ars_defs.h
+43
-0
43 additions, 0 deletions
src/sbbs3/ars_defs.h
src/sbbs3/chk_ar.cpp
+2
-27
2 additions, 27 deletions
src/sbbs3/chk_ar.cpp
src/sbbs3/userdat.c
+2
-27
2 additions, 27 deletions
src/sbbs3/userdat.c
with
57 additions
and
96 deletions
src/sbbs3/ars.c
+
10
−
42
View file @
bb6a9538
...
...
@@ -21,19 +21,9 @@
#include
"ars_defs.h"
static
BOOL
ar_string_arg
(
int
artype
)
static
inline
BOOL
ar_string_arg
(
int
artype
)
{
switch
(
artype
)
{
case
AR_SUBCODE
:
case
AR_DIRCODE
:
case
AR_SHELL
:
case
AR_PROT
:
case
AR_HOST
:
case
AR_IP
:
case
AR_USERNAME
:
return
TRUE
;
/* These ARS Keywords expect a string argument */
}
return
FALSE
;
return
ar_type
(
artype
)
==
AR_STRING
;
}
/* Converts ASCII ARS string into binary ARS buffer */
...
...
@@ -490,36 +480,14 @@ uchar* arstr(ushort* count, const char* str, scfg_t* cfg, uchar* ar_buf)
if
(
n
!=
i
)
/* one of the above */
{
arg_expected
=
TRUE
;
switch
(
artype
)
{
case
AR_RIP
:
case
AR_ANSI
:
case
AR_PETSCII
:
case
AR_ASCII
:
case
AR_UTF8
:
case
AR_CP437
:
case
AR_DOS
:
case
AR_OS2
:
case
AR_UNIX
:
case
AR_LINUX
:
case
AR_WIN32
:
case
AR_LOCAL
:
case
AR_ACTIVE
:
case
AR_INACTIVE
:
case
AR_DELETED
:
case
AR_EXPERT
:
case
AR_SYSOP
:
case
AR_GUEST
:
case
AR_QNODE
:
case
AR_QUIET
:
/* Boolean (No arguments) */
if
(
not
)
ar
[
j
++
]
=
AR_NOT
;
not
=
0
;
ar
[
j
++
]
=
artype
;
artype
=
AR_INVALID
;
arg_expected
=
FALSE
;
break
;
if
(
ar_type
(
artype
)
==
AR_BOOL
)
{
/* Boolean (No arguments) */
if
(
not
)
ar
[
j
++
]
=
AR_NOT
;
not
=
0
;
ar
[
j
++
]
=
artype
;
artype
=
AR_INVALID
;
arg_expected
=
FALSE
;
}
continue
;
}
...
...
This diff is collapsed.
Click to expand it.
src/sbbs3/ars_defs.h
+
43
−
0
View file @
bb6a9538
...
...
@@ -118,4 +118,47 @@ enum { /* Access requirement binaries */
,
AR_USERNAME
};
enum
ar_type
{
AR_BOOL
,
AR_NUM
,
AR_STRING
};
static
inline
enum
ar_type
ar_type
(
int
artype
)
{
switch
(
artype
)
{
case
AR_RIP
:
case
AR_WIP
:
case
AR_ANSI
:
case
AR_PETSCII
:
case
AR_ASCII
:
case
AR_UTF8
:
case
AR_CP437
:
case
AR_DOS
:
case
AR_OS2
:
case
AR_UNIX
:
case
AR_LINUX
:
case
AR_WIN32
:
case
AR_LOCAL
:
case
AR_ACTIVE
:
case
AR_INACTIVE
:
case
AR_DELETED
:
case
AR_EXPERT
:
case
AR_SYSOP
:
case
AR_GUEST
:
case
AR_QNODE
:
case
AR_QUIET
:
return
AR_BOOL
;
case
AR_SUBCODE
:
case
AR_DIRCODE
:
case
AR_SHELL
:
case
AR_PROT
:
case
AR_HOST
:
case
AR_IP
:
case
AR_USERNAME
:
return
AR_STRING
;
}
return
AR_NUM
;
}
#endif
/* Don't add anything after this line */
This diff is collapsed.
Click to expand it.
src/sbbs3/chk_ar.cpp
+
2
−
27
View file @
bb6a9538
...
...
@@ -70,33 +70,8 @@ bool sbbs_t::ar_exp(const uchar **ptrptr, user_t* user, client_t* client)
}
artype
=
(
**
ptrptr
);
switch
(
artype
)
{
case
AR_ANSI
:
/* No arguments */
case
AR_PETSCII
:
case
AR_ASCII
:
case
AR_UTF8
:
case
AR_CP437
:
case
AR_RIP
:
case
AR_WIP
:
case
AR_LOCAL
:
case
AR_EXPERT
:
case
AR_SYSOP
:
case
AR_GUEST
:
case
AR_QNODE
:
case
AR_QUIET
:
case
AR_OS2
:
case
AR_DOS
:
case
AR_WIN32
:
case
AR_UNIX
:
case
AR_LINUX
:
case
AR_ACTIVE
:
case
AR_INACTIVE
:
case
AR_DELETED
:
break
;
default:
(
*
ptrptr
)
++
;
break
;
}
if
(
ar_type
(
artype
)
!=
AR_BOOL
)
(
*
ptrptr
)
++
;
n
=
(
**
ptrptr
);
i
=
(
*
(
short
*
)
*
ptrptr
);
...
...
This diff is collapsed.
Click to expand it.
src/sbbs3/userdat.c
+
2
−
27
View file @
bb6a9538
...
...
@@ -1993,33 +1993,8 @@ static bool ar_exp(scfg_t* cfg, uchar **ptrptr, user_t* user, client_t* client)
}
artype
=
(
**
ptrptr
);
switch
(
artype
)
{
case
AR_ANSI
:
/* No arguments */
case
AR_PETSCII
:
case
AR_ASCII
:
case
AR_UTF8
:
case
AR_CP437
:
case
AR_RIP
:
case
AR_WIP
:
case
AR_LOCAL
:
case
AR_EXPERT
:
case
AR_SYSOP
:
case
AR_GUEST
:
case
AR_QNODE
:
case
AR_QUIET
:
case
AR_OS2
:
case
AR_DOS
:
case
AR_WIN32
:
case
AR_UNIX
:
case
AR_LINUX
:
case
AR_ACTIVE
:
case
AR_INACTIVE
:
case
AR_DELETED
:
break
;
default:
(
*
ptrptr
)
++
;
break
;
}
if
(
ar_type
(
artype
)
!=
AR_BOOL
)
(
*
ptrptr
)
++
;
n
=
(
**
ptrptr
);
i
=
(
*
(
short
*
)
*
ptrptr
);
...
...
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