本文整理汇总了C++中dupstring函数的典型用法代码示例。如果您正苦于以下问题:C++ dupstring函数的具体用法?C++ dupstring怎么用?C++ dupstring使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dupstring函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getlanginfo
static HashNode
getlanginfo(UNUSED(HashTable ht), const char *name)
{
int len, *elem;
char *listr, *nameu;
Param pm = NULL;
nameu = dupstring(name);
unmetafy(nameu, &len);
pm = (Param) hcalloc(sizeof(struct param));
pm->node.nam = nameu;
pm->node.flags = PM_READONLY | PM_SCALAR;
pm->gsu.s = &nullsetscalar_gsu;
if(name)
elem = liitem(name);
else
elem = NULL;
if (elem && (listr = nl_langinfo(*elem))) {
pm->u.str = dupstring(listr);
}
else
{
/* zwarn("no such lang info: %s", name); */
pm->u.str = dupstring("");
pm->node.flags |= PM_UNSET;
}
return &pm->node;
}
示例2: init_gconf
static void
init_gconf (void)
{
#if defined (HAVE_GCONF)
char *s;
#if ! GLIB_CHECK_VERSION (2, 36, 0)
g_type_init ();
#endif
gconf_client = gconf_client_get_default ();
gconf_client_set_error_handling (gconf_client, GCONF_CLIENT_HANDLE_NONE);
gconf_client_add_dir (gconf_client,
GCONF_TOOL_BAR_STYLE,
GCONF_CLIENT_PRELOAD_ONELEVEL,
NULL);
gconf_client_notify_add (gconf_client,
GCONF_TOOL_BAR_STYLE,
something_changed_gconfCB,
NULL, NULL, NULL);
s = gconf_client_get_string (gconf_client, GCONF_TOOL_BAR_STYLE, NULL);
if (s)
{
current_tool_bar_style = map_tool_bar_style (s);
g_free (s);
}
#ifdef HAVE_XFT
s = gconf_client_get_string (gconf_client, GCONF_MONO_FONT, NULL);
if (s)
{
dupstring (¤t_mono_font, s);
g_free (s);
}
s = gconf_client_get_string (gconf_client, GCONF_FONT_NAME, NULL);
if (s)
{
dupstring (¤t_font, s);
g_free (s);
}
gconf_client_add_dir (gconf_client,
GCONF_MONO_FONT,
GCONF_CLIENT_PRELOAD_ONELEVEL,
NULL);
gconf_client_notify_add (gconf_client,
GCONF_MONO_FONT,
something_changed_gconfCB,
NULL, NULL, NULL);
gconf_client_add_dir (gconf_client,
GCONF_FONT_NAME,
GCONF_CLIENT_PRELOAD_ONELEVEL,
NULL);
gconf_client_notify_add (gconf_client,
GCONF_FONT_NAME,
something_changed_gconfCB,
NULL, NULL, NULL);
#endif /* HAVE_XFT */
#endif /* HAVE_GCONF */
}
示例3: zgetcwd
char *
zgetcwd(void)
{
char *ret = zgetdir(NULL);
#ifdef HAVE_GETCWD
if (!ret) {
#ifdef GETCWD_CALLS_MALLOC
char *cwd = getcwd(NULL, 0);
if (cwd) {
ret = dupstring(cwd);
free(cwd);
}
#else
char *cwdbuf = zalloc(PATH_MAX);
ret = getcwd(cwdbuf, PATH_MAX);
if (ret)
ret = dupstring(ret);
free(cwdbuf);
#endif /* GETCWD_CALLS_MALLOC */
}
#endif /* HAVE_GETCWD */
if (!ret)
ret = pwd;
if (!ret)
ret = dupstring(".");
return ret;
}
示例4: gettermcap
static HashNode
gettermcap(UNUSED(HashTable ht), char *name)
{
int len, num;
char *tcstr, buf[2048], *u;
Param pm = NULL;
/* This depends on the termcap stuff in init.c */
if (termflags & TERM_BAD)
return NULL;
if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term()))
return NULL;
unmetafy(name, &len);
pm = (Param) hcalloc(sizeof(struct param));
pm->nam = dupstring(name);
pm->flags = PM_READONLY;
u = buf;
/* logic in the following cascade copied from echotc, above */
if ((num = tgetnum(name)) != -1) {
pm->gsu.i = &nullsetinteger_gsu;
pm->u.val = num;
pm->flags |= PM_INTEGER;
return (HashNode) pm;
}
pm->gsu.s = &nullsetscalar_gsu;
switch (ztgetflag(name)) {
case -1:
break;
case 0:
pm->u.str = dupstring("no");
pm->flags |= PM_SCALAR;
return (HashNode) pm;
default:
pm->u.str = dupstring("yes");
pm->flags |= PM_SCALAR;
return (HashNode) pm;
}
if ((tcstr = (char*)tgetstr(name, &u)) != NULL && tcstr != (char *)-1)
{
pm->u.str = dupstring(tcstr);
pm->flags |= PM_SCALAR;
}
else
{
/* zwarn("no such capability: %s", name, 0); */
pm->u.str = dupstring("");
pm->flags |= PM_UNSET;
}
return (HashNode) pm;
}
示例5: read_and_apply_settings
static void
read_and_apply_settings (struct x_display_info *dpyinfo, bool send_event_p)
{
struct xsettings settings;
if (!read_settings (dpyinfo, &settings))
return;
apply_xft_settings (dpyinfo, &settings);
if (settings.seen & SEEN_TB_STYLE)
{
if (send_event_p)
store_tool_bar_style_changed (settings.tb_style, dpyinfo);
else
current_tool_bar_style = map_tool_bar_style (settings.tb_style);
xfree (settings.tb_style);
}
#ifdef HAVE_XFT
if (settings.seen & SEEN_FONT)
{
if (send_event_p)
store_font_name_changed (settings.font);
else
dupstring (¤t_font, settings.font);
xfree (settings.font);
}
#endif
}
示例6: ptywrite
static int
ptywrite(Ptycmd cmd, char **args, int nonl)
{
if (*args) {
char sp = ' ', *tmp;
int len;
while (*args) {
unmetafy((tmp = dupstring(*args)), &len);
if (ptywritestr(cmd, tmp, len) ||
(*++args && ptywritestr(cmd, &sp, 1)))
return 1;
}
if (!nonl) {
sp = '\n';
if (ptywritestr(cmd, &sp, 1))
return 1;
}
} else {
int n;
char buf[BUFSIZ];
while ((n = read(0, buf, BUFSIZ)) > 0)
if (ptywritestr(cmd, buf, n))
return 1;
}
return 0;
}
示例7: optlookup
mod_export int
optlookup(char const *name)
{
char *s, *t;
Optname n;
s = t = dupstring(name);
/* exorcise underscores, and change to lowercase */
while (*t)
if (*t == '_')
chuck(t);
else {
/*
* Some locales (in particular tr_TR.UTF-8) may
* have non-standard mappings of ASCII characters,
* so be careful. Option names must be ASCII so
* we don't need to be too clever.
*/
if (*t >= 'A' && *t <= 'Z')
*t = (*t - 'A') + 'a';
t++;
}
/* look up name in the table */
if (s[0] == 'n' && s[1] == 'o' &&
(n = (Optname) optiontab->getnode(optiontab, s + 2))) {
return -n->optno;
} else if ((n = (Optname) optiontab->getnode(optiontab, s)))
return n->optno;
else
return OPT_INVALID;
}
示例8: parse_subscript
mod_export char *
parse_subscript(char *s, int sub, int endchar)
{
int l = strlen(s), err;
char *t;
if (!*s || *s == endchar)
return 0;
zcontext_save();
untokenize(t = dupstring(s));
inpush(t, 0, NULL);
strinbeg(0);
lexbuf.len = 0;
lexbuf.ptr = tokstr = s;
lexbuf.siz = l + 1;
err = dquote_parse(endchar, sub);
if (err) {
err = *lexbuf.ptr;
*lexbuf.ptr = '\0';
untokenize(s);
*lexbuf.ptr = err;
s = NULL;
} else {
s = lexbuf.ptr;
}
strinend();
inpop();
DPUTS(cmdsp, "BUG: parse_subscript: cmdstack not empty.");
zcontext_restore();
return s;
}
示例9: optlookup
mod_export int
optlookup(char const *name)
{
char *s, *t;
Optname n;
s = t = dupstring(name);
/* exorcise underscores, and change to lowercase */
while (*t)
if (*t == '_')
chuck(t);
else {
*t = tulower(*t);
t++;
}
/* look up name in the table */
if (s[0] == 'n' && s[1] == 'o' &&
(n = (Optname) optiontab->getnode(optiontab, s + 2))) {
return -n->optno;
} else if ((n = (Optname) optiontab->getnode(optiontab, s)))
return n->optno;
else
return OPT_INVALID;
}
示例10: scanpmmapfile
static void
scanpmmapfile(UNUSED(HashTable ht), ScanFunc func, int flags)
{
struct param pm;
DIR *dir;
if (!(dir = opendir(".")))
return;
memset((void *)&pm, 0, sizeof(struct param));
pm.flags = PM_SCALAR;
pm.gsu.s = &mapfile_gsu;
pm.flags |= (mapfile_pm->flags & PM_READONLY);
/* Here we scan the current directory, calling func() for each file */
while ((pm.nam = zreaddir(dir, 1))) {
/*
* Hmmm, it's rather wasteful always to read the contents.
* In fact, it's grotesequely wasteful, since that would mean
* we always read the entire contents of every single file
* in the directory into memory. Hence just leave it empty.
*/
pm.nam = dupstring(pm.nam);
pm.u.str = "";
func((HashNode) &pm, flags);
}
closedir(dir);
}
示例11: get_buffer
static char *
get_buffer(UNUSED(Param pm))
{
if (zlemetaline != 0)
return dupstring(zlemetaline);
return zlelineasstring(zleline, zlell, 0, NULL, NULL, 1);
}
示例12: stdCmdName
void MConsole::AddCommand(SMJS_Plugin *pl, const char *cmdName, v8::Handle<v8::Function> func, bool serverOnly){
std::string stdCmdName(cmdName);
std::transform(stdCmdName.begin(), stdCmdName.end(), stdCmdName.begin(), ::tolower);
CommandHook *wrapper = new CommandHook;
wrapper->pl = pl;
wrapper->func = v8::Persistent<v8::Function>::New(func);
wrapper->serverOnly = serverOnly;
auto infoIt = g_MConsole->pluginCmds2.find(stdCmdName);
if(infoIt == g_MConsole->pluginCmds2.end()){
CommandHookInfo *info = new CommandHookInfo();
g_MConsole->pluginCmds2.insert(std::make_pair(stdCmdName, info));
infoIt = g_MConsole->pluginCmds2.find(stdCmdName);
ConCommand *conCmd = icvar->FindCommand(cmdName);
if(!conCmd){
conCmd = new ConCommand(dupstring(cmdName), MConsole::CommandCallback2);
icvar->RegisterConCommand(conCmd);
info->isSMJS = true;
}else{
SH_ADD_HOOK(ConCommand, Dispatch, conCmd, SH_STATIC(MConsole::CommandCallback), false);
info->isSMJS = false;
}
}
infoIt->second->hooks.push_back(wrapper);
}
示例13: parse_subscript
mod_export char *
parse_subscript(char *s, int sub)
{
int l = strlen(s), err;
char *t;
if (!*s || *s == ']')
return 0;
lexsave();
untokenize(t = dupstring(s));
inpush(t, 0, NULL);
strinbeg(0);
len = 0;
bptr = tokstr = s;
bsiz = l + 1;
err = dquote_parse(']', sub);
if (err) {
err = *bptr;
*bptr = 0;
untokenize(s);
*bptr = err;
s = 0;
} else
s = bptr;
strinend();
inpop();
DPUTS(cmdsp, "BUG: parse_subscript: cmdstack not empty.");
lexrestore();
return s;
}
示例14: get_intarg
int
get_intarg(char **s)
{
char *t = get_strarg(*s + 1);
char *p, sav;
long ret;
if (!*t)
return -1;
sav = *t;
*t = '\0';
p = dupstring(*s + 2);
*s = t;
*t = sav;
if (parsestr(p))
return -1;
singsub(&p);
if (errflag)
return -1;
ret = matheval(p);
if (errflag)
return -1;
if (ret < 0)
ret = -ret;
return ret < 0 ? -ret : ret;
}
示例15: parse_subscript
mod_export char *
parse_subscript(char *s, int sub, int endchar)
{
int l = strlen(s), err, toklen;
char *t;
if (!*s || *s == endchar)
return 0;
zcontext_save();
untokenize(t = dupstring(s));
inpush(t, 0, NULL);
strinbeg(0);
/*
* Warning to Future Generations:
*
* This way of passing the subscript through the lexer is brittle.
* Code above this for several layers assumes that when we tokenise
* the input it goes into the same place as the original string.
* However, the lexer may overwrite later bits of the string or
* reallocate it, in particular when expanding aliaes. To get
* around this, we copy the string and then copy it back. This is a
* bit more robust but still relies on the underlying assumption of
* length preservation.
*/
lexbuf.len = 0;
lexbuf.ptr = tokstr = dupstring(s);
lexbuf.siz = l + 1;
err = dquote_parse(endchar, sub);
toklen = (int)(lexbuf.ptr - tokstr);
DPUTS(toklen > l, "Bad length for parsed subscript");
memcpy(s, tokstr, toklen);
if (err) {
char *strend = s + toklen;
err = *strend;
*strend = '\0';
untokenize(s);
*strend = err;
s = NULL;
} else {
s += toklen;
}
strinend();
inpop();
DPUTS(cmdsp, "BUG: parse_subscript: cmdstack not empty.");
zcontext_restore();
return s;
}