Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
eb1689ac
Commit
eb1689ac
authored
Mar 16, 2018
by
rswindell
Browse files
Added some functions to read/write to the data/user/*.ini files.
I'm calling these "user properties", but that might change.
parent
74815125
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
0 deletions
+59
-0
src/sbbs3/userdat.c
src/sbbs3/userdat.c
+54
-0
src/sbbs3/userdat.h
src/sbbs3/userdat.h
+5
-0
No files found.
src/sbbs3/userdat.c
View file @
eb1689ac
...
...
@@ -3214,3 +3214,57 @@ BOOL DLLCALL set_sysop_availability(scfg_t* scfg, BOOL available)
return
ftouch
(
sysop_available_semfile
(
scfg
));
return
remove
(
sysop_available_semfile
(
scfg
))
==
0
;
}
/************************************/
/* user .ini file get/set functions */
/************************************/
static
FILE
*
user_ini_open
(
scfg_t
*
scfg
,
unsigned
user_number
,
BOOL
create
)
{
char
path
[
MAX_PATH
+
1
];
SAFEPRINTF2
(
path
,
"%suser/%04u.ini"
,
scfg
->
data_dir
,
user_number
);
return
iniOpenFile
(
path
,
create
);
}
BOOL
DLLCALL
user_get_property
(
scfg_t
*
scfg
,
unsigned
user_number
,
const
char
*
section
,
const
char
*
key
,
char
*
value
)
{
FILE
*
fp
;
fp
=
user_ini_open
(
scfg
,
user_number
,
/* create: */
FALSE
);
if
(
fp
==
NULL
)
return
FALSE
;
char
*
result
=
iniReadValue
(
fp
,
section
,
key
,
NULL
,
value
);
iniCloseFile
(
fp
);
return
result
!=
NULL
;
}
BOOL
DLLCALL
user_set_property
(
scfg_t
*
scfg
,
unsigned
user_number
,
const
char
*
section
,
const
char
*
key
,
const
char
*
value
)
{
FILE
*
fp
;
fp
=
user_ini_open
(
scfg
,
user_number
,
/* create: */
TRUE
);
if
(
fp
==
NULL
)
return
FALSE
;
str_list_t
ini
=
iniReadFile
(
fp
);
char
*
result
=
iniSetValue
(
&
ini
,
section
,
key
,
value
,
/* style */
NULL
);
iniWriteFile
(
fp
,
ini
);
iniFreeStringList
(
ini
);
iniCloseFile
(
fp
);
return
result
!=
NULL
;
}
BOOL
DLLCALL
user_set_time_property
(
scfg_t
*
scfg
,
unsigned
user_number
,
const
char
*
section
,
const
char
*
key
,
time_t
value
)
{
FILE
*
fp
;
fp
=
user_ini_open
(
scfg
,
user_number
,
/* create: */
TRUE
);
if
(
fp
==
NULL
)
return
FALSE
;
str_list_t
ini
=
iniReadFile
(
fp
);
char
*
result
=
iniSetDateTime
(
&
ini
,
section
,
key
,
/* include_time */
TRUE
,
value
,
/* style */
NULL
);
iniWriteFile
(
fp
,
ini
);
iniFreeStringList
(
ini
);
iniCloseFile
(
fp
);
return
result
!=
NULL
;
}
src/sbbs3/userdat.h
View file @
eb1689ac
...
...
@@ -126,6 +126,11 @@ DLLEXPORT BOOL DLLCALL is_host_exempt(scfg_t*, const char* ip_addr, const char*
DLLEXPORT
BOOL
DLLCALL
filter_ip
(
scfg_t
*
,
const
char
*
prot
,
const
char
*
reason
,
const
char
*
host
,
const
char
*
ip_addr
,
const
char
*
username
,
const
char
*
fname
);
/* user .ini file access */
DLLEXPORT
BOOL
DLLCALL
user_get_property
(
scfg_t
*
,
unsigned
user_number
,
const
char
*
section
,
const
char
*
key
,
char
*
value
);
DLLEXPORT
BOOL
DLLCALL
user_set_property
(
scfg_t
*
,
unsigned
user_number
,
const
char
*
section
,
const
char
*
key
,
const
char
*
value
);
DLLEXPORT
BOOL
DLLCALL
user_set_time_property
(
scfg_t
*
,
unsigned
user_number
,
const
char
*
section
,
const
char
*
key
,
time_t
);
/* New-message-scan pointer functions: */
DLLEXPORT
BOOL
DLLCALL
getmsgptrs
(
scfg_t
*
,
user_t
*
,
subscan_t
*
,
void
(
*
progress
)(
void
*
,
int
,
int
),
void
*
cbdata
);
DLLEXPORT
BOOL
DLLCALL
putmsgptrs
(
scfg_t
*
,
user_t
*
,
subscan_t
*
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment