本文整理汇总了C++中re_snprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ re_snprintf函数的具体用法?C++ re_snprintf怎么用?C++ re_snprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了re_snprintf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: conf_path_get
/**
* Get the path to configuration files
*
* @param path Buffer to write path
* @param sz Size of path buffer
*
* @return 0 if success, otherwise errorcode
*/
int conf_path_get(char *path, size_t sz)
{
char buf[FS_PATH_MAX];
int err;
/* Use explicit conf path */
if (conf_path) {
if (re_snprintf(path, sz, "%s", conf_path) < 0)
return ENOMEM;
return 0;
}
#ifdef CONFIG_PATH
str_ncpy(buf, CONFIG_PATH, sizeof(buf));
(void)err;
#else
err = fs_gethome(buf, sizeof(buf));
if (err)
return err;
#endif
if (re_snprintf(path, sz, "%s" DIR_SEP ".baresip", buf) < 0)
return ENOMEM;
return 0;
}
开发者ID:Studio-Link-v2,项目名称:baresip,代码行数:34,代码来源:conf.c
示例2: message_handler
static void message_handler(const struct pl *peer, const struct pl *ctype,
struct mbuf *body, void *arg)
{
(void)ctype;
(void)arg;
char message[256] = {0};
char s_peer[50] = {0};
struct contacts *contacts = baresip_contacts();
(void)re_snprintf(message, sizeof(message), "%b",
mbuf_buf(body), mbuf_get_left(body));
(void)re_snprintf(s_peer, sizeof(s_peer), "%r", peer);
warning("message from %s: %s\n", s_peer, message);
struct contact *c = contact_find(contacts, s_peer);
if (c) {
const struct sip_addr *addr = contact_addr(c);
(void)re_snprintf(s_peer, sizeof(s_peer), "%r", &addr->dname);
(void)webapp_chat_add(s_peer, message, false);
ws_send_json(WS_CHAT, webapp_messages_get());
}
}
开发者ID:Studio-Link-v2,项目名称:backend,代码行数:25,代码来源:chat.c
示例3: ua_register
/**
* Start registration of a User-Agent
*
* @param ua User-Agent
*
* @return 0 if success, otherwise errorcode
*/
int ua_register(struct ua *ua)
{
struct account *acc;
struct le *le;
struct uri uri;
char reg_uri[64];
char params[256] = "";
unsigned i;
int err;
info("baresip.ua.ua_register()\n");
if (!ua)
return EINVAL;
acc = ua->acc;
uri = ua->acc->luri;
uri.user = uri.password = pl_null;
if (re_snprintf(reg_uri, sizeof(reg_uri), "%H", uri_encode, &uri) < 0)
return ENOMEM;
if (str_isset(uag.cfg->uuid)) {
if (re_snprintf(params, sizeof(params),
";+sip.instance=\"<urn:uuid:%s>\"",
uag.cfg->uuid) < 0)
return ENOMEM;
}
if (acc->regq) {
if (re_snprintf(¶ms[strlen(params)],
sizeof(params) - strlen(params),
";q=%s", acc->regq) < 0)
return ENOMEM;
}
if (acc->mnat && acc->mnat->ftag) {
if (re_snprintf(¶ms[strlen(params)],
sizeof(params) - strlen(params),
";%s", acc->mnat->ftag) < 0)
return ENOMEM;
}
ua_event(ua, UA_EVENT_REGISTERING, NULL, NULL);
for (le = ua->regl.head, i=0; le; le = le->next, i++) {
struct reg *reg = le->data;
info("outbound[i]: ");
info(acc->outbound[i]);
err = reg_register(reg, reg_uri, params,
acc->regint, acc->outbound[i]);
if (err) {
warning("ua: SIP register failed: %m\n", err);
return err;
}
}
return 0;
}
开发者ID:tamy83,项目名称:baresip-android-mtt,代码行数:65,代码来源:ua.c
示例4: module_init
static int module_init(void)
{
struct conf *conf = conf_cur();
uint32_t value;
char *p = fmtp + str_len(fmtp);
bool b;
int n = 0;
if (0 == conf_get_u32(conf, "opus_bitrate", &value)) {
n = re_snprintf(p, sizeof(fmtp) - str_len(p),
";maxaveragebitrate=%d", value);
if (n <= 0)
return ENOMEM;
p += n;
}
if (0 == conf_get_bool(conf, "opus_cbr", &b)) {
n = re_snprintf(p, sizeof(fmtp) - str_len(p),
";cbr=%d", b);
if (n <= 0)
return ENOMEM;
p += n;
}
if (0 == conf_get_bool(conf, "opus_inbandfec", &b)) {
n = re_snprintf(p, sizeof(fmtp) - str_len(p),
";useinbandfec=%d", b);
if (n <= 0)
return ENOMEM;
p += n;
}
if (0 == conf_get_bool(conf, "opus_dtx", &b)) {
n = re_snprintf(p, sizeof(fmtp) - str_len(p),
";usedtx=%d", b);
if (n <= 0)
return ENOMEM;
p += n;
}
(void)conf_get_bool(conf, "opus_mirror", &opus_mirror);
debug("opus: fmtp=\"%s\"\n", fmtp);
aucodec_register(&opus);
return 0;
}
开发者ID:Studio-Link-v2,项目名称:baresip,代码行数:56,代码来源:opus.c
示例5: display
static int display(struct vidisp_st *st, const char *title,
const struct vidframe *frame)
{
struct vidframe frame_rgb;
int err = 0;
if (!vidsz_cmp(&st->size, &frame->size)) {
char capt[256];
if (st->size.w && st->size.h) {
info("x11: reset: %u x %u ---> %u x %u\n",
st->size.w, st->size.h,
frame->size.w, frame->size.h);
}
if (st->internal && !st->win)
err = create_window(st, &frame->size);
err |= x11_reset(st, &frame->size);
if (err)
return err;
if (title) {
re_snprintf(capt, sizeof(capt), "%s - %u x %u",
title, frame->size.w, frame->size.h);
}
else {
re_snprintf(capt, sizeof(capt), "%u x %u",
frame->size.w, frame->size.h);
}
XStoreName(st->disp, st->win, capt);
}
/* Convert from YUV420P to RGB */
vidframe_init_buf(&frame_rgb, st->pixfmt, &frame->size,
(uint8_t *)st->shm.shmaddr);
vidconv(&frame_rgb, frame, 0);
/* draw */
if (st->xshmat)
XShmPutImage(st->disp, st->win, st->gc, st->image,
0, 0, 0, 0, st->size.w, st->size.h, false);
else
XPutImage(st->disp, st->win, st->gc, st->image,
0, 0, 0, 0, st->size.w, st->size.h);
XSync(st->disp, false);
return err;
}
开发者ID:FOSSRIT,项目名称:baresip,代码行数:53,代码来源:x11.c
示例6: tcp_sock_bind
/**
* Bind to a TCP Socket
*
* @param ts TCP Socket
* @param local Local bind address
*
* @return 0 if success, otherwise errorcode
*/
int tcp_sock_bind(struct tcp_sock *ts, const struct sa *local)
{
struct addrinfo hints, *res = NULL, *r;
char addr[64] = "";
char serv[NI_MAXSERV] = "0";
int error, err;
if (!ts || ts->fd<0)
return EINVAL;
if (local) {
(void)re_snprintf(addr, sizeof(addr), "%H",
sa_print_addr, local);
(void)re_snprintf(serv, sizeof(serv), "%u", sa_port(local));
}
memset(&hints, 0, sizeof(hints));
/* set-up hints structure */
hints.ai_family = PF_UNSPEC;
hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
error = getaddrinfo(addr[0] ? addr : NULL, serv, &hints, &res);
if (error) {
#ifdef WIN32
DEBUG_WARNING("sock_bind: getaddrinfo: wsaerr=%d\n",
WSAGetLastError());
#endif
DEBUG_WARNING("sock_bind: getaddrinfo: %s:%s error=%d (%s)\n",
addr, serv, error, gai_strerror(error));
return EADDRNOTAVAIL;
}
err = EINVAL;
for (r = res; r; r = r->ai_next) {
if (bind(ts->fd, r->ai_addr, SIZ_CAST r->ai_addrlen) < 0) {
err = errno;
DEBUG_WARNING("sock_bind: bind: %m (af=%d, %J)\n",
err, r->ai_family, local);
continue;
}
/* OK */
err = 0;
break;
}
freeaddrinfo(res);
return err;
}
开发者ID:wireapp,项目名称:wire-audio-video-signaling,代码行数:61,代码来源:tcp.c
示例7: update
static int update(struct aufilt_st **stp, struct aufilt *af,
const struct aufilt_prm *encprm,
const struct aufilt_prm *decprm)
{
char filename_enc[128], filename_dec[128];
SF_INFO sfinfo_enc, sfinfo_dec;
struct sndfile_st *st;
(void)af;
st = mem_zalloc(sizeof(*st), sndfile_destructor);
if (!st)
return EINVAL;
(void)re_snprintf(filename_enc, sizeof(filename_enc),
"dump-%u-enc.wav", count);
(void)re_snprintf(filename_dec, sizeof(filename_dec),
"dump-%u-dec.wav", count);
sfinfo_enc.samplerate = encprm->srate;
sfinfo_enc.channels = encprm->ch;
sfinfo_enc.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
sfinfo_dec.samplerate = decprm->srate;
sfinfo_dec.channels = decprm->ch;
sfinfo_dec.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
st->enc = sf_open(filename_enc, SFM_WRITE, &sfinfo_enc);
if (!st->enc) {
DEBUG_WARNING("could not open: %s\n", filename_enc);
puts(sf_strerror(NULL));
goto error;
}
st->dec = sf_open(filename_dec, SFM_WRITE, &sfinfo_dec);
if (!st->dec) {
DEBUG_WARNING("could not open: %s\n", filename_dec);
puts(sf_strerror(NULL));
goto error;
}
DEBUG_NOTICE("dumping audio to %s and %s\n",
filename_enc, filename_dec);
++count;
*stp = (struct aufilt_st *)st;
return 0;
error:
mem_deref(st);
return ENOMEM;
}
开发者ID:mralexgray,项目名称:baresip,代码行数:52,代码来源:sndfile.c
示例8: conf_apply
/**
* Apply a function handler to all config items of a certain key
*
* @param conf Configuration object
* @param name Name of config item key
* @param ch Config item handler
* @param arg Handler argument
*
* @return 0 if success, otherwise errorcode
*/
int conf_apply(const struct conf *conf, const char *name,
conf_h *ch, void *arg)
{
char expr[512];
struct pl pl, val;
int err = 0;
if (!conf || !name || !ch)
return EINVAL;
pl.p = (const char *)conf->mb->buf;
pl.l = conf->mb->end;
(void)re_snprintf(expr, sizeof(expr),
"[\r\n]+[ \t]*%s[ \t]+[~ \t\r\n]+", name);
while (!re_regex(pl.p, pl.l, expr, NULL, NULL, NULL, &val)) {
err = ch(&val, arg);
if (err)
break;
pl.l -= val.p + val.l - pl.p;
pl.p = val.p + val.l;
}
return err;
}
开发者ID:ClearwaterCore,项目名称:libre-upstream,代码行数:38,代码来源:conf.c
示例9: time
static SNDFILE *openfile(const struct aufilt_prm *prm, bool enc)
{
char filename[128];
SF_INFO sfinfo;
time_t tnow = time(0);
struct tm *tm = localtime(&tnow);
SNDFILE *sf;
(void)re_snprintf(filename, sizeof(filename),
"dump-%H-%s.wav",
timestamp_print, tm, enc ? "enc" : "dec");
sfinfo.samplerate = prm->srate;
sfinfo.channels = prm->ch;
sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
sf = sf_open(filename, SFM_WRITE, &sfinfo);
if (!sf) {
warning("sndfile: could not open: %s\n", filename);
puts(sf_strerror(NULL));
return NULL;
}
info("sndfile: dumping %s audio to %s\n",
enc ? "encode" : "decode", filename);
return sf;
}
开发者ID:FOSSRIT,项目名称:baresip,代码行数:28,代码来源:sndfile.c
示例10: GTK_MENU_SHELL
static GtkMenuItem *accounts_menu_add_item(struct gtk_mod *mod,
struct ua *ua)
{
GtkMenuShell *accounts_menu = GTK_MENU_SHELL(mod->accounts_menu);
GtkWidget *item;
GSList *group = mod->accounts_menu_group;
struct ua *ua_current = uag_current();
char buf[256];
re_snprintf(buf, sizeof buf, "%s%s", ua_aor(ua),
ua_isregistered(ua) ? " (OK)" : "");
item = gtk_radio_menu_item_new_with_label(group, buf);
group = gtk_radio_menu_item_get_group(
GTK_RADIO_MENU_ITEM (item));
if (ua == ua_current)
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
TRUE);
g_object_set_data(G_OBJECT(item), "ua", ua);
g_signal_connect(item, "toggled",
G_CALLBACK(menu_on_account_toggled), mod);
gtk_menu_shell_append(accounts_menu, item);
mod->accounts_menu_group = group;
return GTK_MENU_ITEM(item);
}
开发者ID:AlexMarlo,项目名称:baresip,代码行数:25,代码来源:gtk_mod.c
示例11: module_init
static int module_init(void)
{
struct contacts *contacts = baresip_contacts();
char path[256] = "", file[256] = "";
int err;
err = conf_path_get(path, sizeof(path));
if (err)
return err;
if (re_snprintf(file, sizeof(file), "%s/contacts", path) < 0)
return ENOMEM;
if (!conf_fileexist(file)) {
(void)fs_mkdir(path, 0700);
err = write_template(file);
if (err)
return err;
}
err = conf_parse(file, confline_handler, contacts);
if (err)
return err;
err = cmd_register(baresip_commands(), cmdv, ARRAY_SIZE(cmdv));
if (err)
return err;
info("Populated %u contacts\n",
list_count(contact_list(contacts)));
return err;
}
开发者ID:Studio-Link-v2,项目名称:baresip,代码行数:35,代码来源:contact.c
示例12: contact_handler
static bool contact_handler(const struct sip_hdr *hdr,
const struct sip_msg *msg, void *arg)
{
struct sipreg *reg = arg;
struct sip_addr c;
struct pl pval;
char uri[256];
if (sip_addr_decode(&c, &hdr->val))
return false;
if (re_snprintf(uri, sizeof(uri), "sip:%[email protected]%J%s", reg->cuser,
®->laddr, sip_transp_param(reg->tp)) < 0)
return false;
if (pl_strcmp(&c.auri, uri))
return false;
if (!sip_param_decode(&c.params, "expires", &pval)) {
reg->wait = pl_u32(&pval);
}
else if (pl_isset(&msg->expires))
reg->wait = pl_u32(&msg->expires);
else
reg->wait = DEFAULT_EXPIRES;
return true;
}
开发者ID:ClearwaterCore,项目名称:libre-upstream,代码行数:28,代码来源:reg.c
示例13: denotify_incoming_call
static void denotify_incoming_call(struct gtk_mod *mod, struct call *call)
{
GSList *item, *next;
#if GLIB_CHECK_VERSION(2,40,0)
char id[64];
re_snprintf(id, sizeof id, "incoming-call-%p", call);
id[sizeof id - 1] = '\0';
g_application_withdraw_notification(mod->app, id);
#endif
/* Remove call submenu */
for (item = mod->incoming_call_menus; item; item = next) {
GtkWidget *menu_item = item->data;
next = item->next;
if (call == g_object_get_data(G_OBJECT(menu_item), "call")) {
gtk_widget_destroy(menu_item);
mod->incoming_call_menus =
g_slist_delete_link(mod->incoming_call_menus,
item);
}
}
}
开发者ID:AlexMarlo,项目名称:baresip,代码行数:25,代码来源:gtk_mod.c
示例14: play_file
/**
* Play an audio file in WAV format
*
* @param playp Pointer to allocated player object
* @param filename Name of WAV file to play
* @param repeat Number of times to repeat
*
* @return 0 if success, otherwise errorcode
*/
int play_file(struct play **playp, const char *filename, int repeat)
{
struct mbuf *mb;
char path[256];
uint32_t srate;
uint8_t ch;
int err;
if (playp && *playp)
return EALREADY;
#ifndef PREFIX
#define PREFIX "/usr"
#endif
if (re_snprintf(path, sizeof(path), PREFIX "/share/baresip/%s",
filename) < 0)
return ENOMEM;
mb = mbuf_alloc(1024);
if (!mb)
return ENOMEM;
err = aufile_load(mb, path, &srate, &ch);
if (err) {
DEBUG_WARNING("%s: %m\n", path, err);
goto out;
}
err = play_tone(playp, mb, srate, ch, repeat);
out:
mem_deref(mb);
return err;
}
开发者ID:mralexgray,项目名称:baresip,代码行数:44,代码来源:play.c
示例15:
static const char *mknonce(char *nonce, uint32_t now, const struct sa *src)
{
(void)re_snprintf(nonce, NONCE_SIZE + 1, "%08x%08x",
auth.rand_time ^ now,
auth.rand_addr ^ sa_hash(src, SA_ADDR));
return nonce;
}
开发者ID:anchowee,项目名称:traversal_server,代码行数:7,代码来源:auth.c
示例16: on_zrtp_secure
static void on_zrtp_secure(zrtp_stream_t *stream)
{
const struct menc_media *st = zrtp_stream_get_userdata(stream);
const struct menc_sess *sess = st->sess;
zrtp_session_info_t sess_info;
char buf[128] = "";
zrtp_session_get(sess->zrtp_session, &sess_info);
if (!sess_info.sas_is_verified && sess_info.sas_is_ready) {
info("zrtp: verify SAS <%s> <%s> for remote peer %w"
" (type /zrtp_verify %w to verify)\n",
sess_info.sas1.buffer,
sess_info.sas2.buffer,
sess_info.peer_zid.buffer,
(size_t)sess_info.peer_zid.length,
sess_info.peer_zid.buffer,
(size_t)sess_info.peer_zid.length);
if (sess->eventh) {
if (re_snprintf(buf, sizeof(buf), "%s,%s,%w",
sess_info.sas1.buffer,
sess_info.sas2.buffer,
sess_info.peer_zid.buffer,
(size_t)sess_info.peer_zid.length))
(sess->eventh)(MENC_EVENT_VERIFY_REQUEST,
buf, sess->arg);
else
warning("zrtp: failed to print verify "
" arguments\n");
}
}
else if (sess_info.sas_is_verified) {
info("zrtp: secure session with verified remote peer %w\n",
sess_info.peer_zid.buffer,
(size_t)sess_info.peer_zid.length);
if (sess->eventh) {
if (re_snprintf(buf, sizeof(buf), "%w",
sess_info.peer_zid.buffer,
(size_t)sess_info.peer_zid.length))
(sess->eventh)(MENC_EVENT_PEER_VERIFIED,
buf, sess->arg);
else
warning("zrtp: failed to print verified "
" argument\n");
}
}
}
开发者ID:Studio-Link,项目名称:baresip,代码行数:46,代码来源:zrtp.c
示例17: module_init
static int module_init(void)
{
(void)re_snprintf(ilbc_fmtp, sizeof(ilbc_fmtp),
"mode=%d", DEFAULT_MODE);
aucodec_register(&ilbc);
return 0;
}
开发者ID:GGGO,项目名称:baresip,代码行数:8,代码来源:ilbc.c
示例18: accounts_menu_set_status
static void accounts_menu_set_status(struct gtk_mod *mod,
struct ua *ua, enum ua_event ev)
{
GtkMenuItem *item = accounts_menu_get_item(mod, ua);
char buf[256];
re_snprintf(buf, sizeof buf, "%s (%s)", ua_aor(ua),
ua_event_reg_str(ev));
gtk_menu_item_set_label(item, buf);
}
开发者ID:AlexMarlo,项目名称:baresip,代码行数:9,代码来源:gtk_mod.c
示例19: append_extension
/*
* Append module extension, if not exist
*
* input: foobar
* output: foobar.so
*
*/
static void append_extension(char *buf, size_t sz, const char *name)
{
if (0 == re_regex(name, str_len(name), "[^.]+"MOD_EXT, NULL)) {
str_ncpy(buf, name, sz);
}
else {
re_snprintf(buf, sz, "%s"MOD_EXT, name);
}
}
开发者ID:Studio-Link,项目名称:baresip,代码行数:17,代码来源:module.c
示例20: message_handler
static void message_handler(struct ua *ua,
const struct pl *peer, const struct pl *ctype,
struct mbuf *body, void *arg)
{
struct gtk_mod *mod = arg;
char title[128];
char msg[512];
#if GLIB_CHECK_VERSION(2,40,0)
GNotification *notification;
#elif defined(USE_LIBNOTIFY)
NotifyNotification *notification;
#endif
(void)ua;
(void)ctype;
/* Display notification of chat */
re_snprintf(title, sizeof title, "Chat from %r", peer);
title[sizeof title - 1] = '\0';
re_snprintf(msg, sizeof msg, "%b",
mbuf_buf(body), mbuf_get_left(body));
#if GLIB_CHECK_VERSION(2,40,0)
notification = g_notification_new(title);
g_notification_set_body(notification, msg);
g_application_send_notification(mod->app, NULL, notification);
g_object_unref(notification);
#elif defined(USE_LIBNOTIFY)
(void)mod;
if (!notify_is_initted())
return;
notification = notify_notification_new(title, msg, "baresip");
notify_notification_show(notification, NULL);
g_object_unref(notification);
#endif
}
开发者ID:Studio-Link,项目名称:baresip,代码行数:42,代码来源:gtk_mod.c
注:本文中的re_snprintf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论