use standard snprintf() instead of GLib g_snprintf()

This commit is contained in:
Max Kellermann 2013-09-05 09:21:53 +02:00
parent 26d92c80ed
commit fccba1af2a
4 changed files with 28 additions and 26 deletions

View File

@ -91,10 +91,11 @@ mpd_despotify_tag_from_track(struct ds_track *track)
if (!track->has_meta_data)
return tag;
g_snprintf(tracknum, sizeof(tracknum), "%d", track->tracknumber);
g_snprintf(date, sizeof(date), "%d", track->year);
g_snprintf(comment, sizeof(comment), "Bitrate %d Kbps, %sgeo restricted",
track->file_bitrate / 1000, track->geo_restricted ? "" : "not ");
snprintf(tracknum, sizeof(tracknum), "%d", track->tracknumber);
snprintf(date, sizeof(date), "%d", track->year);
snprintf(comment, sizeof(comment), "Bitrate %d Kbps, %sgeo restricted",
track->file_bitrate / 1000,
track->geo_restricted ? "" : "not ");
tag->AddItem(TAG_TITLE, track->title);
tag->AddItem(TAG_ARTIST, track->artist->name);
tag->AddItem(TAG_TRACK, tracknum);

View File

@ -131,18 +131,18 @@ HttpdClient::SendResponse()
assert(state == RESPONSE);
if (dlna_streaming_requested) {
g_snprintf(buffer, sizeof(buffer),
"HTTP/1.1 206 OK\r\n"
"Content-Type: %s\r\n"
"Content-Length: 10000\r\n"
"Content-RangeX: 0-1000000/1000000\r\n"
"transferMode.dlna.org: Streaming\r\n"
"Accept-Ranges: bytes\r\n"
"Connection: close\r\n"
"realTimeInfo.dlna.org: DLNA.ORG_TLAG=*\r\n"
"contentFeatures.dlna.org: DLNA.ORG_OP=01;DLNA.ORG_CI=0\r\n"
"\r\n",
httpd->content_type);
snprintf(buffer, sizeof(buffer),
"HTTP/1.1 206 OK\r\n"
"Content-Type: %s\r\n"
"Content-Length: 10000\r\n"
"Content-RangeX: 0-1000000/1000000\r\n"
"transferMode.dlna.org: Streaming\r\n"
"Accept-Ranges: bytes\r\n"
"Connection: close\r\n"
"realTimeInfo.dlna.org: DLNA.ORG_TLAG=*\r\n"
"contentFeatures.dlna.org: DLNA.ORG_OP=01;DLNA.ORG_CI=0\r\n"
"\r\n",
httpd->content_type);
} else if (metadata_requested) {
gchar *metadata_header;
@ -158,14 +158,14 @@ HttpdClient::SendResponse()
g_free(metadata_header);
} else { /* revert to a normal HTTP request */
g_snprintf(buffer, sizeof(buffer),
"HTTP/1.1 200 OK\r\n"
"Content-Type: %s\r\n"
"Connection: close\r\n"
"Pragma: no-cache\r\n"
"Cache-Control: no-cache, no-store\r\n"
"\r\n",
httpd->content_type);
snprintf(buffer, sizeof(buffer),
"HTTP/1.1 200 OK\r\n"
"Content-Type: %s\r\n"
"Connection: close\r\n"
"Pragma: no-cache\r\n"
"Cache-Control: no-cache, no-store\r\n"
"\r\n",
httpd->content_type);
}
ssize_t nbytes = SocketMonitor::Write(buffer, strlen(buffer));

View File

@ -42,7 +42,7 @@ add_song(std::forward_list<SongPointer> &songs, struct ds_track *track)
char *ds_uri;
/* Create a spt://... URI for MPD */
g_snprintf(uri, sizeof(uri), "%s://", dsp_scheme);
snprintf(uri, sizeof(uri), "%s://", dsp_scheme);
ds_uri = uri + strlen(dsp_scheme) + 3;
if (despotify_track_to_uri(track, ds_uri) != ds_uri) {

View File

@ -33,6 +33,7 @@
#endif /* G_OS_WIN32 */
#include <string.h>
#include <stdio.h>
const Domain resolver_domain("resolver");
@ -118,7 +119,7 @@ resolve_host_port(const char *host_port, unsigned default_port,
char buffer[32];
if (port == NULL && default_port != 0) {
g_snprintf(buffer, sizeof(buffer), "%u", default_port);
snprintf(buffer, sizeof(buffer), "%u", default_port);
port = buffer;
}