Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
003ee55c
Commit
003ee55c
authored
2 years ago
by
Eidolon
Browse files
Options
Downloads
Patches
Plain Diff
http-mserv: add SRB2-specific user agent string
parent
fdb6f2af
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1893
http-mserv: add SRB2-specific user agent string
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/http-mserv.c
+27
-0
27 additions, 0 deletions
src/http-mserv.c
with
27 additions
and
0 deletions
src/http-mserv.c
+
27
−
0
View file @
003ee55c
...
...
@@ -65,6 +65,8 @@ static I_mutex hms_api_mutex;
static
char
*
hms_server_token
;
static
char
hms_useragent
[
512
];
struct
HMS_buffer
{
CURL
*
curl
;
...
...
@@ -81,6 +83,27 @@ Contact_error (void)
);
}
static
void
get_user_agent
(
char
*
buf
,
size_t
len
)
{
#if defined(__STDC__) && __STDC_VERSION__ >= 201112L
if
(
sprintf_s
(
buf
,
len
,
"%s/%s (%s; %s; %i; %i) SRB2BASE/%i"
,
SRB2APPLICATION
,
VERSIONSTRING
,
compbranch
,
comprevision
,
MODID
,
MODVERSION
,
CODEBASE
)
<
1
)
I_Error
(
"http-mserv: get_user_agent failed"
);
#else
if
(
sprintf
(
buf
,
"%s/%s (%s; %s; %i; %i) SRB2BASE/%i"
,
SRB2APPLICATION
,
VERSIONSTRING
,
compbranch
,
comprevision
,
MODID
,
MODVERSION
,
CODEBASE
)
<
0
)
I_Error
(
"http-mserv: get_user_agent failed"
);
#endif
}
static
void
init_user_agent_once
(
void
)
{
if
(
hms_useragent
[
0
]
!=
'\0'
)
return
;
get_user_agent
(
hms_useragent
,
512
);
}
static
size_t
HMS_on_read
(
char
*
s
,
size_t
_1
,
size_t
n
,
void
*
userdata
)
{
...
...
@@ -156,6 +179,8 @@ HMS_connect (const char *format, ...)
I_lock_mutex
(
&
hms_api_mutex
);
#endif
init_user_agent_once
();
seek
=
strlen
(
hms_api
)
+
1
;
/* + '/' */
va_start
(
ap
,
format
);
...
...
@@ -202,6 +227,8 @@ HMS_connect (const char *format, ...)
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
HMS_on_read
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
buffer
);
curl_easy_setopt
(
curl
,
CURLOPT_USERAGENT
,
hms_useragent
);
curl_free
(
quack_token
);
free
(
url
);
...
...
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