cosmetic: remove old tvh_strlcatf() and rename tvh_strlcatf2() as tvh_strlcatf()

This commit is contained in:
Jaroslav Kysela 2015-04-01 10:27:15 +02:00
parent 4eeecb2a0f
commit 9a8242a082
9 changed files with 61 additions and 66 deletions

View file

@ -356,7 +356,7 @@ access_dump_a(access_t *a)
char buf[1024];
int first;
tvh_strlcatf2(buf, sizeof(buf), l,
tvh_strlcatf(buf, sizeof(buf), l,
"%s:%s [%c%c%c%c%c%c%c%c%c], conn=%u, chmin=%llu, chmax=%llu%s",
a->aa_representative ?: "<no-id>",
a->aa_username ?: "<no-user>",
@ -379,14 +379,14 @@ access_dump_a(access_t *a)
profile_t *pro = profile_find_by_uuid(htsmsg_field_get_str(f) ?: "");
if (pro) {
if (first)
tvh_strlcatf2(buf, sizeof(buf), l, ", profile=");
tvh_strlcatf2(buf, sizeof(buf), l, "%s'%s'",
tvh_strlcatf(buf, sizeof(buf), l, ", profile=");
tvh_strlcatf(buf, sizeof(buf), l, "%s'%s'",
first ? "" : ",", pro->pro_name ?: "");
first = 0;
}
}
} else {
tvh_strlcatf2(buf, sizeof(buf), l, ", profile=ANY");
tvh_strlcatf(buf, sizeof(buf), l, ", profile=ANY");
}
if (a->aa_dvrcfgs) {
@ -395,14 +395,14 @@ access_dump_a(access_t *a)
dvr_config_t *cfg = dvr_config_find_by_uuid(htsmsg_field_get_str(f) ?: "");
if (cfg) {
if (first)
tvh_strlcatf2(buf, sizeof(buf), l, ", dvr=");
tvh_strlcatf2(buf, sizeof(buf), l, "%s'%s'",
tvh_strlcatf(buf, sizeof(buf), l, ", dvr=");
tvh_strlcatf(buf, sizeof(buf), l, "%s'%s'",
first ? "" : ",", cfg->dvr_config_name ?: "");
first = 0;
}
}
} else {
tvh_strlcatf2(buf, sizeof(buf), l, ", dvr=ANY");
tvh_strlcatf(buf, sizeof(buf), l, ", dvr=ANY");
}
if (a->aa_chtags) {
@ -411,14 +411,14 @@ access_dump_a(access_t *a)
channel_tag_t *ct = channel_tag_find_by_uuid(htsmsg_field_get_str(f) ?: "");
if (ct) {
if (first)
tvh_strlcatf2(buf, sizeof(buf), l, ", tags=");
tvh_strlcatf2(buf, sizeof(buf), l, "%s'%s'",
tvh_strlcatf(buf, sizeof(buf), l, ", tags=");
tvh_strlcatf(buf, sizeof(buf), l, "%s'%s'",
first ? "" : ",", ct->ct_name ?: "");
first = 0;
}
}
} else {
tvh_strlcatf2(buf, sizeof(buf), l, ", tag=ANY");
tvh_strlcatf(buf, sizeof(buf), l, ", tag=ANY");
}
tvhtrace("access", "%s", buf);
@ -1075,7 +1075,7 @@ access_entry_class_prefix_get(void *o)
s_addr = htonl(ai->ai_network);
inet_ntop(AF_INET, &s_addr, addrbuf, sizeof(addrbuf));
}
tvh_strlcatf2(buf, sizeof(buf), pos, ",%s/%d", addrbuf, ai->ai_prefixlen);
tvh_strlcatf(buf, sizeof(buf), pos, ",%s/%d", addrbuf, ai->ai_prefixlen);
}
return &ret;
}

View file

@ -1101,19 +1101,19 @@ size_t epg_episode_number_format
epg_episode_num_t num;
epg_episode_get_epnum(episode, &num);
if ( num.e_num ) {
if (pre) tvh_strlcatf2(buf, len, i, "%s", pre);
if (pre) tvh_strlcatf(buf, len, i, "%s", pre);
if ( sfmt && num.s_num ) {
tvh_strlcatf2(buf, len, i, sfmt, num.s_num);
tvh_strlcatf(buf, len, i, sfmt, num.s_num);
if ( cfmt && num.s_cnt )
tvh_strlcatf2(buf, len, i, cfmt, num.s_cnt);
if (sep) tvh_strlcatf2(buf, len, i, "%s", sep);
tvh_strlcatf(buf, len, i, cfmt, num.s_cnt);
if (sep) tvh_strlcatf(buf, len, i, "%s", sep);
}
tvh_strlcatf2(buf, len, i, efmt, num.e_num);
tvh_strlcatf(buf, len, i, efmt, num.e_num);
if ( cfmt && num.e_cnt )
tvh_strlcatf2(buf, len, i, cfmt, num.e_cnt);
tvh_strlcatf(buf, len, i, cfmt, num.e_cnt);
} else if ( num.text ) {
if (pre) tvh_strlcatf2(buf, len, i, "%s", pre);
tvh_strlcatf2(buf, len, i, "%s", num.text);
if (pre) tvh_strlcatf(buf, len, i, "%s", pre);
tvh_strlcatf(buf, len, i, "%s", num.text);
}
return i;
}
@ -2118,11 +2118,11 @@ size_t epg_genre_get_str ( const epg_genre_t *genre, int major_only,
if (!_epg_genre_names[maj][0]) return 0;
min = major_only ? 0 : (genre->code & 0xf);
if (!min || major_prefix ) {
tvh_strlcatf2(buf, len, ret, "%s", _epg_genre_names[maj][0]);
if (min) tvh_strlcatf2(buf, len, ret, " : ");
tvh_strlcatf(buf, len, ret, "%s", _epg_genre_names[maj][0]);
if (min) tvh_strlcatf(buf, len, ret, " : ");
}
if (min && _epg_genre_names[maj][min])
tvh_strlcatf2(buf, len, ret, "%s", _epg_genre_names[maj][min]);
tvh_strlcatf(buf, len, ret, "%s", _epg_genre_names[maj][min]);
return ret;
}

View file

@ -534,17 +534,17 @@ dump_request(http_connection_t *hc)
first = 1;
TAILQ_FOREACH(ra, &hc->hc_req_args, link) {
tvh_strlcatf2(buf, sizeof(buf), ptr, first ? "?%s=%s" : "&%s=%s", ra->key, ra->val);
tvh_strlcatf(buf, sizeof(buf), ptr, first ? "?%s=%s" : "&%s=%s", ra->key, ra->val);
first = 0;
}
first = 1;
TAILQ_FOREACH(ra, &hc->hc_args, link) {
tvh_strlcatf2(buf, sizeof(buf), ptr, first ? "{{%s=%s" : ",%s=%s", ra->key, ra->val);
tvh_strlcatf(buf, sizeof(buf), ptr, first ? "{{%s=%s" : ",%s=%s", ra->key, ra->val);
first = 0;
}
if (!first)
tvh_strlcatf2(buf, sizeof(buf), ptr, "}}");
tvh_strlcatf(buf, sizeof(buf), ptr, "}}");
tvhtrace("http", "%s%s", hc->hc_url, buf);
}

View file

@ -1426,7 +1426,7 @@ linuxdvb_diseqc_send
for (i = 0; i < len; i++) {
message.msg[3 + i] = (uint8_t)va_arg(ap, int);
#if ENABLE_TRACE
tvh_strlcatf2(buf, sizeof(buf), c, "%02X ", message.msg[3 + i]);
tvh_strlcatf(buf, sizeof(buf), c, "%02X ", message.msg[3 + i]);
#endif
}
va_end(ap);

View file

@ -200,6 +200,6 @@ mpegts_pid_dump(mpegts_apids_t *pids, char *buf, int len)
if (pids->all)
return snprintf(buf, len, "all");
for (i = 0; i < pids->count && l + 1 < len; i++)
tvh_strlcatf2(buf, len, l, "%s%i", i > 0 ? "," : "", pids->pids[i]);
tvh_strlcatf(buf, len, l, "%s%i", i > 0 ? "," : "", pids->pids[i]);
return l;
}

View file

@ -1039,9 +1039,9 @@ play:
dvb_mux_conf_str(dmc, buf, sizeof(buf));
r = strlen(buf);
tvh_strlcatf2(buf, sizeof(buf), r, " pids ");
tvh_strlcatf(buf, sizeof(buf), r, " pids ");
if (mpegts_pid_dump(&rs->pids, buf + r, sizeof(buf) - r) == 0)
tvh_strlcatf2(buf, sizeof(buf), r, "<none>");
tvh_strlcatf(buf, sizeof(buf), r, "<none>");
tvhdebug("satips", "%i/%s/%d: %s from %s:%d %s",
rs->frontend, rs->session, rs->stream,

View file

@ -169,27 +169,27 @@ subscription_show_none(th_subscription_t *s)
char buf[256], buf2[128];
size_t l = 0;
tvh_strlcatf2(buf, sizeof(buf), l,
tvh_strlcatf(buf, sizeof(buf), l,
"No input source available for subscription \"%s\"",
s->ths_title);
if (s->ths_channel)
tvh_strlcatf2(buf, sizeof(buf), l, " to channel \"%s\"",
tvh_strlcatf(buf, sizeof(buf), l, " to channel \"%s\"",
s->ths_channel ? channel_get_name(s->ths_channel) : "none");
#if ENABLE_MPEGTS
else if (s->ths_raw_service) {
mpegts_service_t *ms = (mpegts_service_t *)s->ths_raw_service;
mpegts_mux_nice_name(ms->s_dvb_mux, buf2, sizeof(buf2));
tvh_strlcatf2(buf, sizeof(buf), l, " to mux \"%s\"", buf2);
tvh_strlcatf(buf, sizeof(buf), l, " to mux \"%s\"", buf2);
}
#endif
else {
tvh_strlcatf2(buf, sizeof(buf), l, " to service \"%s\"",
tvh_strlcatf(buf, sizeof(buf), l, " to service \"%s\"",
s->ths_service ? s->ths_service->s_nicename : "none");
#if ENABLE_MPEGTS
if (idnode_is_instance(&s->ths_service->s_id, &mpegts_service_class)) {
mpegts_service_t *ms = (mpegts_service_t *)s->ths_service;
mpegts_mux_nice_name(ms->s_dvb_mux, buf2, sizeof(buf2));
tvh_strlcatf2(buf, sizeof(buf), l, " in mux \"%s\"", buf2);
tvh_strlcatf(buf, sizeof(buf), l, " in mux \"%s\"", buf2);
}
#endif
}
@ -205,43 +205,43 @@ subscription_show_info(th_subscription_t *s)
int mux = 0, service = 0;
s->ths_service->s_setsourceinfo(s->ths_service, &si);
tvh_strlcatf2(buf, sizeof(buf), l, "\"%s\" subscribing", s->ths_title);
tvh_strlcatf(buf, sizeof(buf), l, "\"%s\" subscribing", s->ths_title);
if (s->ths_channel) {
tvh_strlcatf2(buf, sizeof(buf), l, " on channel \"%s\"",
tvh_strlcatf(buf, sizeof(buf), l, " on channel \"%s\"",
s->ths_channel ? channel_get_name(s->ths_channel) : "none");
#if ENABLE_MPEGTS
} else if (s->ths_raw_service && si.si_mux) {
tvh_strlcatf2(buf, sizeof(buf), l, " to mux \"%s\"", si.si_mux);
tvh_strlcatf(buf, sizeof(buf), l, " to mux \"%s\"", si.si_mux);
mux = 1;
#endif
} else {
tvh_strlcatf2(buf, sizeof(buf), l, " to service \"%s\"",
tvh_strlcatf(buf, sizeof(buf), l, " to service \"%s\"",
s->ths_service ? s->ths_service->s_nicename : "none");
service = 1;
}
tvh_strlcatf2(buf, sizeof(buf), l, ", weight: %d", s->ths_weight);
tvh_strlcatf(buf, sizeof(buf), l, ", weight: %d", s->ths_weight);
if (si.si_adapter)
tvh_strlcatf2(buf, sizeof(buf), l, ", adapter: \"%s\"", si.si_adapter);
tvh_strlcatf(buf, sizeof(buf), l, ", adapter: \"%s\"", si.si_adapter);
if (si.si_network)
tvh_strlcatf2(buf, sizeof(buf), l, ", network: \"%s\"", si.si_network);
tvh_strlcatf(buf, sizeof(buf), l, ", network: \"%s\"", si.si_network);
if (!mux && si.si_mux)
tvh_strlcatf2(buf, sizeof(buf), l, ", mux: \"%s\"", si.si_mux);
tvh_strlcatf(buf, sizeof(buf), l, ", mux: \"%s\"", si.si_mux);
if (si.si_provider)
tvh_strlcatf2(buf, sizeof(buf), l, ", provider: \"%s\"", si.si_provider);
tvh_strlcatf(buf, sizeof(buf), l, ", provider: \"%s\"", si.si_provider);
if (!service && si.si_service)
tvh_strlcatf2(buf, sizeof(buf), l, ", service: \"%s\"", si.si_service);
tvh_strlcatf(buf, sizeof(buf), l, ", service: \"%s\"", si.si_service);
if (s->ths_prch && s->ths_prch->prch_pro)
tvh_strlcatf2(buf, sizeof(buf), l,
tvh_strlcatf(buf, sizeof(buf), l,
", profile=\"%s\"",
s->ths_prch->prch_pro->pro_name ?: "");
if (s->ths_hostname)
tvh_strlcatf2(buf, sizeof(buf), l, ", hostname=\"%s\"", s->ths_hostname);
tvh_strlcatf(buf, sizeof(buf), l, ", hostname=\"%s\"", s->ths_hostname);
if (s->ths_username)
tvh_strlcatf2(buf, sizeof(buf), l, ", username=\"%s\"", s->ths_username);
tvh_strlcatf(buf, sizeof(buf), l, ", username=\"%s\"", s->ths_username);
if (s->ths_client)
tvh_strlcatf2(buf, sizeof(buf), l, ", client=\"%s\"", s->ths_client);
tvh_strlcatf(buf, sizeof(buf), l, ", client=\"%s\"", s->ths_client);
tvhlog(LOG_INFO, "subscription", "%04X: %s", shortid(s), buf);
}
@ -556,18 +556,18 @@ subscription_unsubscribe(th_subscription_t *s, int quiet)
if (s->ths_channel != NULL) {
LIST_REMOVE(s, ths_channel_link);
tvh_strlcatf2(buf, sizeof(buf), l, "\"%s\" unsubscribing from \"%s\"",
tvh_strlcatf(buf, sizeof(buf), l, "\"%s\" unsubscribing from \"%s\"",
s->ths_title, channel_get_name(s->ths_channel));
} else {
tvh_strlcatf2(buf, sizeof(buf), l, "\"%s\" unsubscribing", s->ths_title);
tvh_strlcatf(buf, sizeof(buf), l, "\"%s\" unsubscribing", s->ths_title);
}
if (s->ths_hostname)
tvh_strlcatf2(buf, sizeof(buf), l, ", hostname=\"%s\"", s->ths_hostname);
tvh_strlcatf(buf, sizeof(buf), l, ", hostname=\"%s\"", s->ths_hostname);
if (s->ths_username)
tvh_strlcatf2(buf, sizeof(buf), l, ", username=\"%s\"", s->ths_username);
tvh_strlcatf(buf, sizeof(buf), l, ", username=\"%s\"", s->ths_username);
if (s->ths_client)
tvh_strlcatf2(buf, sizeof(buf), l, ", username=\"%s\"", s->ths_client);
tvh_strlcatf(buf, sizeof(buf), l, ", username=\"%s\"", s->ths_client);
tvhlog(quiet ? LOG_TRACE : LOG_INFO, "subscription", "%04X: %s", shortid(s), buf);
if (t) {

View file

@ -580,12 +580,7 @@ extern void scopedunlock(pthread_mutex_t **mtxp);
char *tvh_b = alloca(tvh_l + 1); \
memcpy(tvh_b, n, tvh_l + 1); })
#define tvh_strlcatf(buf, size, fmt...) \
({ size_t __l = strlen(buf); \
int __r = snprintf((buf) + __l, (size) - __l, fmt); \
__r >= (size) - __l ? (size) - 1 : __l + __r }}
#define tvh_strlcatf2(buf, size, ptr, fmt...) \
#define tvh_strlcatf(buf, size, ptr, fmt...) \
do { int __r = snprintf((buf) + ptr, (size) - ptr, fmt); \
ptr = __r >= (size) - ptr ? (size) - 1 : ptr + __r; } while (0)

View file

@ -74,7 +74,7 @@ tvhlog_get_subsys ( htsmsg_t *ss, char *subsys, size_t len )
if (ss) {
HTSMSG_FOREACH(f, ss) {
if (f->hmf_type != HMF_S64) continue;
tvh_strlcatf2(subsys, len, c, "%s%c%s",
tvh_strlcatf(subsys, len, c, "%s%c%s",
first ? "" : ",",
f->hmf_s64 ? '+' : '-',
f->hmf_name);
@ -168,7 +168,7 @@ tvhlog_process
l = strftime(t, sizeof(t), "%F %T", &tm);// %d %H:%M:%S", &tm);
if (options & TVHLOG_OPT_MILLIS) {
int ms = msg->time.tv_usec / 1000;
tvh_strlcatf2(t, sizeof(t), l, ".%03d", ms);
tvh_strlcatf(t, sizeof(t), l, ".%03d", ms);
}
/* Comet (debug must still be enabled??) */
@ -311,11 +311,11 @@ void tvhlogv ( const char *file, int line,
/* Basic message */
l = 0;
if (options & TVHLOG_OPT_THREAD) {
tvh_strlcatf2(buf, sizeof(buf), l, "tid %ld: ", (long)pthread_self());
tvh_strlcatf(buf, sizeof(buf), l, "tid %ld: ", (long)pthread_self());
}
tvh_strlcatf2(buf, sizeof(buf), l, "%s: ", subsys);
tvh_strlcatf(buf, sizeof(buf), l, "%s: ", subsys);
if (options & TVHLOG_OPT_FILELINE && severity >= LOG_DEBUG)
tvh_strlcatf2(buf, sizeof(buf), l, "(%s:%d) ", file, line);
tvh_strlcatf(buf, sizeof(buf), l, "(%s:%d) ", file, line);
if (args)
vsnprintf(buf + l, sizeof(buf) - l, fmt, *args);
else
@ -381,9 +381,9 @@ _tvhlog_hexdump(const char *file, int line,
c = 0;
for (i = 0; i < HEXDUMP_WIDTH; i++) {
if (i >= len)
tvh_strlcatf2(str, sizeof(str), c, " ");
tvh_strlcatf(str, sizeof(str), c, " ");
else
tvh_strlcatf2(str, sizeof(str), c, "%02X ", data[i]);
tvh_strlcatf(str, sizeof(str), c, "%02X ", data[i]);
}
for (i = 0; i < HEXDUMP_WIDTH; i++) {
if (i < len) {