Improve allocating system and integrate parser
emalloc remplaced with xcalloc/xmalloc/xrealloc and easy wrappers for strings zmalloc/zcalloc/zrealloc - exit on fail - prevent size_t overflow Integrate parser in src/
This commit is contained in:
parent
19ecd89d89
commit
82b17ea02f
3
.gitignore
vendored
3
.gitignore
vendored
@ -4,3 +4,6 @@ wmfs
|
|||||||
#*
|
#*
|
||||||
\#*
|
\#*
|
||||||
Makefile
|
Makefile
|
||||||
|
wmfs.1.gz
|
||||||
|
tags
|
||||||
|
*.patch
|
||||||
|
|||||||
@ -19,8 +19,8 @@ src/launcher.c \
|
|||||||
src/layout.c \
|
src/layout.c \
|
||||||
src/menu.c \
|
src/menu.c \
|
||||||
src/mouse.c \
|
src/mouse.c \
|
||||||
src/parse/api.c \
|
src/parse_api.c \
|
||||||
src/parse/parse.c \
|
src/parse.c \
|
||||||
src/screen.c \
|
src/screen.c \
|
||||||
src/status.c \
|
src/status.c \
|
||||||
src/systray.c \
|
src/systray.c \
|
||||||
@ -38,7 +38,7 @@ OBJS= ${SRCS:.c=.o}
|
|||||||
|
|
||||||
all: ${PROG} ${MAN}.gz
|
all: ${PROG} ${MAN}.gz
|
||||||
|
|
||||||
${PROG}: ${OBJS} src/structs.h src/wmfs.h src/parse/parse.h
|
${PROG}: ${OBJS} src/structs.h src/wmfs.h src/parse.h
|
||||||
${CC} -o $@ ${OBJS} ${LDFLAGS}
|
${CC} -o $@ ${OBJS} ${LDFLAGS}
|
||||||
|
|
||||||
${MAN}.gz: ${MAN}
|
${MAN}.gz: ${MAN}
|
||||||
|
|||||||
@ -58,7 +58,7 @@ barwin_create(Window parent,
|
|||||||
BarWindow *bw;
|
BarWindow *bw;
|
||||||
|
|
||||||
/* Allocate memory */
|
/* Allocate memory */
|
||||||
bw = emalloc(1, sizeof(BarWindow));
|
bw = zcalloc(sizeof(*bw));
|
||||||
|
|
||||||
/* Barwin attributes */
|
/* Barwin attributes */
|
||||||
at.override_redirect = True;
|
at.override_redirect = True;
|
||||||
|
|||||||
@ -536,7 +536,7 @@ client_get_name(Client *c)
|
|||||||
XFetchName(dpy, c->win, &(c->title));
|
XFetchName(dpy, c->win, &(c->title));
|
||||||
|
|
||||||
if(!c->title)
|
if(!c->title)
|
||||||
c->title = _strdup("WMFS");
|
c->title = xstrdup("WMFS");
|
||||||
}
|
}
|
||||||
|
|
||||||
frame_update(c);
|
frame_update(c);
|
||||||
@ -676,7 +676,7 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar)
|
|||||||
|
|
||||||
screen_get_sel();
|
screen_get_sel();
|
||||||
|
|
||||||
c = emalloc(1, sizeof(Client));
|
c = zmalloc(sizeof(Client));
|
||||||
c->win = w;
|
c->win = w;
|
||||||
c->screen = selscreen;
|
c->screen = selscreen;
|
||||||
c->flags = 0;
|
c->flags = 0;
|
||||||
|
|||||||
42
src/config.c
42
src/config.c
@ -196,7 +196,7 @@ conf_bar_section(void)
|
|||||||
|
|
||||||
if ((conf.bars.nmouse = fetch_section_count(mouse)) > 0)
|
if ((conf.bars.nmouse = fetch_section_count(mouse)) > 0)
|
||||||
{
|
{
|
||||||
conf.bars.mouse = emalloc(conf.bars.nmouse, sizeof(MouseBinding));
|
conf.bars.mouse = xcalloc(conf.bars.nmouse, sizeof(MouseBinding));
|
||||||
mouse_section(conf.bars.mouse, mouse);
|
mouse_section(conf.bars.mouse, mouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ conf_bar_section(void)
|
|||||||
|
|
||||||
if ((conf.selbar.nmouse = fetch_section_count(mouse)))
|
if ((conf.selbar.nmouse = fetch_section_count(mouse)))
|
||||||
{
|
{
|
||||||
conf.selbar.mouse = emalloc(conf.selbar.nmouse, sizeof(MouseBinding));
|
conf.selbar.mouse = xcalloc(conf.selbar.nmouse, sizeof(MouseBinding));
|
||||||
mouse_section(conf.selbar.mouse, mouse);
|
mouse_section(conf.selbar.mouse, mouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ conf_root_section(void)
|
|||||||
|
|
||||||
if ((conf.root.nmouse = fetch_section_count(mouse)) > 0)
|
if ((conf.root.nmouse = fetch_section_count(mouse)) > 0)
|
||||||
{
|
{
|
||||||
conf.root.mouse = emalloc(conf.root.nmouse, sizeof(MouseBinding));
|
conf.root.mouse = xcalloc(conf.root.nmouse, sizeof(MouseBinding));
|
||||||
mouse_section(conf.root.mouse, mouse);
|
mouse_section(conf.root.mouse, mouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,7 +289,7 @@ conf_client_section(void)
|
|||||||
|
|
||||||
if((conf.client.nmouse = fetch_section_count(mouse)) > 0)
|
if((conf.client.nmouse = fetch_section_count(mouse)) > 0)
|
||||||
{
|
{
|
||||||
conf.client.mouse = emalloc(conf.client.nmouse, sizeof(MouseBinding));
|
conf.client.mouse = xcalloc(conf.client.nmouse, sizeof(MouseBinding));
|
||||||
mouse_section(conf.client.mouse, mouse);
|
mouse_section(conf.client.mouse, mouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ conf_client_section(void)
|
|||||||
|
|
||||||
if((conf.titlebar.nmouse = fetch_section_count(mouse)) > 0)
|
if((conf.titlebar.nmouse = fetch_section_count(mouse)) > 0)
|
||||||
{
|
{
|
||||||
conf.titlebar.mouse = emalloc(conf.titlebar.nmouse, sizeof(MouseBinding));
|
conf.titlebar.mouse = xcalloc(conf.titlebar.nmouse, sizeof(MouseBinding));
|
||||||
mouse_section(conf.titlebar.mouse, mouse);
|
mouse_section(conf.titlebar.mouse, mouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,7 +328,7 @@ conf_client_section(void)
|
|||||||
|
|
||||||
if((conf.titlebar.nbutton = fetch_section_count(button)) > 0)
|
if((conf.titlebar.nbutton = fetch_section_count(button)) > 0)
|
||||||
{
|
{
|
||||||
conf.titlebar.button = emalloc(conf.titlebar.nbutton, sizeof(Button));
|
conf.titlebar.button = xcalloc(conf.titlebar.nbutton, sizeof(Button));
|
||||||
for(i = 0; i < conf.titlebar.nbutton; ++i)
|
for(i = 0; i < conf.titlebar.nbutton; ++i)
|
||||||
{
|
{
|
||||||
flags = fetch_opt_first(button[i], "none", "flags").str;
|
flags = fetch_opt_first(button[i], "none", "flags").str;
|
||||||
@ -346,7 +346,7 @@ conf_client_section(void)
|
|||||||
|
|
||||||
if((conf.titlebar.button[i].nmouse = fetch_section_count(mouse)) > 0)
|
if((conf.titlebar.button[i].nmouse = fetch_section_count(mouse)) > 0)
|
||||||
{
|
{
|
||||||
conf.titlebar.button[i].mouse = emalloc(conf.titlebar.button[i].nmouse, sizeof(MouseBinding));
|
conf.titlebar.button[i].mouse = xcalloc(conf.titlebar.button[i].nmouse, sizeof(MouseBinding));
|
||||||
mouse_section(conf.titlebar.button[i].mouse, mouse);
|
mouse_section(conf.titlebar.button[i].mouse, mouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ conf_client_section(void)
|
|||||||
|
|
||||||
if((conf.titlebar.button[i].nlines = fetch_section_count(line)) > 0)
|
if((conf.titlebar.button[i].nlines = fetch_section_count(line)) > 0)
|
||||||
{
|
{
|
||||||
conf.titlebar.button[i].linecoord = emalloc(conf.titlebar.button[i].nlines, sizeof(XSegment));
|
conf.titlebar.button[i].linecoord = xcalloc(conf.titlebar.button[i].nlines, sizeof(XSegment));
|
||||||
|
|
||||||
for(j = 0; j < conf.titlebar.button[i].nlines; ++j)
|
for(j = 0; j < conf.titlebar.button[i].nlines; ++j)
|
||||||
{
|
{
|
||||||
@ -414,7 +414,7 @@ conf_layout_section(void)
|
|||||||
{
|
{
|
||||||
warnx("configuration : Too many or no layouts (%d).", conf.nlayout);
|
warnx("configuration : Too many or no layouts (%d).", conf.nlayout);
|
||||||
conf.nlayout = 1;
|
conf.nlayout = 1;
|
||||||
conf.layout[0].symbol = _strdup("TILE");
|
conf.layout[0].symbol = xstrdup("TILE");
|
||||||
conf.layout[0].func = tile;
|
conf.layout[0].func = tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,10 +519,10 @@ conf_tag_section(void)
|
|||||||
sc = screen_count();
|
sc = screen_count();
|
||||||
|
|
||||||
/* Alloc all */
|
/* Alloc all */
|
||||||
conf.ntag = emalloc(sc, sizeof(int));
|
conf.ntag = xcalloc(sc, sizeof(*conf.ntag));
|
||||||
tags = emalloc(sc, sizeof(Tag*));
|
tags = xcalloc(sc, sizeof(*tags));
|
||||||
seltag = emalloc(sc, sizeof(int));
|
seltag = xcalloc(sc, sizeof(*seltag));
|
||||||
prevseltag = emalloc(sc, sizeof(int));
|
prevseltag = xcalloc(sc, sizeof(*prevseltag));
|
||||||
|
|
||||||
for(i = 0; i < sc; ++i)
|
for(i = 0; i < sc; ++i)
|
||||||
seltag[i] = 1;
|
seltag[i] = 1;
|
||||||
@ -532,7 +532,7 @@ conf_tag_section(void)
|
|||||||
n = fetch_section_count(tag);
|
n = fetch_section_count(tag);
|
||||||
|
|
||||||
for(i = 0; i < sc; ++i)
|
for(i = 0; i < sc; ++i)
|
||||||
tags[i] = emalloc(n + 2, sizeof(Tag));
|
tags[i] = xcalloc(n + 2, sizeof(Tag));
|
||||||
|
|
||||||
for(i = 0; i < n; i++)
|
for(i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
@ -573,7 +573,7 @@ conf_tag_section(void)
|
|||||||
if ((count = fetch_opt_count(opt)))
|
if ((count = fetch_opt_count(opt)))
|
||||||
{
|
{
|
||||||
tags[k][conf.ntag[k]].nclients = count;
|
tags[k][conf.ntag[k]].nclients = count;
|
||||||
tags[k][conf.ntag[k]].clients = emalloc(count, sizeof(char *));
|
tags[k][conf.ntag[k]].clients = xcalloc(count, sizeof(char *));
|
||||||
for(m = 0; m < count; ++m)
|
for(m = 0; m < count; ++m)
|
||||||
tags[k][conf.ntag[k]].clients[m] = opt[m].str;
|
tags[k][conf.ntag[k]].clients[m] = opt[m].str;
|
||||||
}
|
}
|
||||||
@ -585,7 +585,7 @@ conf_tag_section(void)
|
|||||||
|
|
||||||
if((tags[k][conf.ntag[k]].nmouse = fetch_section_count(mouse)))
|
if((tags[k][conf.ntag[k]].nmouse = fetch_section_count(mouse)))
|
||||||
{
|
{
|
||||||
tags[k][conf.ntag[k]].mouse = emalloc(tags[k][conf.ntag[k]].nmouse, sizeof(MouseBinding));
|
tags[k][conf.ntag[k]].mouse = xcalloc(tags[k][conf.ntag[k]].nmouse, sizeof(MouseBinding));
|
||||||
mouse_section(tags[k][conf.ntag[k]].mouse, mouse);
|
mouse_section(tags[k][conf.ntag[k]].mouse, mouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -619,7 +619,7 @@ conf_rule_section(void)
|
|||||||
|
|
||||||
CHECK((conf.nrule = fetch_section_count(rule)));
|
CHECK((conf.nrule = fetch_section_count(rule)));
|
||||||
|
|
||||||
conf.rule = emalloc(conf.nrule, sizeof(Rule));
|
conf.rule = xcalloc(conf.nrule, sizeof(Rule));
|
||||||
|
|
||||||
for(i = 0; i < conf.nrule; ++i)
|
for(i = 0; i < conf.nrule; ++i)
|
||||||
{
|
{
|
||||||
@ -650,7 +650,7 @@ conf_menu_section(void)
|
|||||||
|
|
||||||
CHECK((conf.nmenu = fetch_section_count(set_menu)));
|
CHECK((conf.nmenu = fetch_section_count(set_menu)));
|
||||||
|
|
||||||
conf.menu = emalloc(conf.nmenu, sizeof(Menu));
|
conf.menu = xcalloc(conf.nmenu, sizeof(Menu));
|
||||||
|
|
||||||
for(i = 0; i < conf.nmenu; ++i)
|
for(i = 0; i < conf.nmenu; ++i)
|
||||||
{
|
{
|
||||||
@ -681,7 +681,7 @@ conf_menu_section(void)
|
|||||||
|
|
||||||
if((conf.menu[i].nitem = fetch_section_count(item)))
|
if((conf.menu[i].nitem = fetch_section_count(item)))
|
||||||
{
|
{
|
||||||
conf.menu[i].item = emalloc(conf.menu[i].nitem, sizeof(MenuItem));
|
conf.menu[i].item = xcalloc(conf.menu[i].nitem, sizeof(MenuItem));
|
||||||
for(j = 0; j < conf.menu[i].nitem; ++j)
|
for(j = 0; j < conf.menu[i].nitem; ++j)
|
||||||
{
|
{
|
||||||
conf.menu[i].item[j].name = fetch_opt_first(item[j], "item_wname", "name").str;
|
conf.menu[i].item[j].name = fetch_opt_first(item[j], "item_wname", "name").str;
|
||||||
@ -709,7 +709,7 @@ conf_launcher_section(void)
|
|||||||
|
|
||||||
CHECK((conf.nlauncher = fetch_section_count(set_launcher)));
|
CHECK((conf.nlauncher = fetch_section_count(set_launcher)));
|
||||||
|
|
||||||
conf.launcher = emalloc(conf.nlauncher, sizeof(Launcher));
|
conf.launcher = xcalloc(conf.nlauncher, sizeof(Launcher));
|
||||||
|
|
||||||
for(i = 0; i < conf.nlauncher; ++i)
|
for(i = 0; i < conf.nlauncher; ++i)
|
||||||
{
|
{
|
||||||
@ -735,7 +735,7 @@ conf_keybind_section(void)
|
|||||||
ks = fetch_section(sec, "key");
|
ks = fetch_section(sec, "key");
|
||||||
|
|
||||||
conf.nkeybind = fetch_section_count(ks);
|
conf.nkeybind = fetch_section_count(ks);
|
||||||
keys = emalloc(conf.nkeybind, sizeof(Key));
|
keys = xcalloc(conf.nkeybind, sizeof(Key));
|
||||||
|
|
||||||
for(i = 0; i < conf.nkeybind; ++i)
|
for(i = 0; i < conf.nkeybind; ++i)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -62,7 +62,7 @@ draw_image_ofset_text(Drawable d, int x, int y, char* fg, int pad, char *str, in
|
|||||||
int i, ni, sw = 0;
|
int i, ni, sw = 0;
|
||||||
ImageAttr im[128];
|
ImageAttr im[128];
|
||||||
|
|
||||||
ostr = _strdup(str);
|
ostr = xstrdup(str);
|
||||||
|
|
||||||
if(strstr(str, "i["))
|
if(strstr(str, "i["))
|
||||||
{
|
{
|
||||||
@ -204,7 +204,7 @@ textw(char *text)
|
|||||||
|
|
||||||
ImageAttr im[128];
|
ImageAttr im[128];
|
||||||
|
|
||||||
ostr = _strdup(text);
|
ostr = xstrdup(text);
|
||||||
|
|
||||||
if(strstr(text, "i["))
|
if(strstr(text, "i["))
|
||||||
parse_image_block(im, text);
|
parse_image_block(im, text);
|
||||||
|
|||||||
@ -50,7 +50,7 @@ ewmh_init_hints(void)
|
|||||||
|
|
||||||
|
|
||||||
s = screen_count();
|
s = screen_count();
|
||||||
net_atom = emalloc(net_last + s, sizeof(Atom));
|
net_atom = xcalloc(net_last + s, sizeof(Atom));
|
||||||
|
|
||||||
/* EWMH hints */
|
/* EWMH hints */
|
||||||
net_atom[net_supported] = ATOM("_NET_SUPPORTED");
|
net_atom[net_supported] = ATOM("_NET_SUPPORTED");
|
||||||
@ -252,7 +252,7 @@ ewmh_get_client_list(void)
|
|||||||
int win_n;
|
int win_n;
|
||||||
|
|
||||||
for(win_n = 0, c = clients; c; c = c->next, ++win_n);
|
for(win_n = 0, c = clients; c; c = c->next, ++win_n);
|
||||||
list = emalloc(win_n, sizeof(Window));
|
list = xcalloc(win_n, sizeof(Window));
|
||||||
|
|
||||||
for(win_n = 0, c = clients; c; c = c->next, ++win_n)
|
for(win_n = 0, c = clients; c; c = c->next, ++win_n)
|
||||||
list[win_n] = c->win;
|
list[win_n] = c->win;
|
||||||
@ -279,7 +279,7 @@ ewmh_get_desktop_names(void)
|
|||||||
for(i = 1; i < conf.ntag[s] + 1; ++i)
|
for(i = 1; i < conf.ntag[s] + 1; ++i)
|
||||||
len += strlen(tags[s][i].name);
|
len += strlen(tags[s][i].name);
|
||||||
|
|
||||||
str = emalloc(len + i + 1, sizeof(char*));
|
str = xcalloc(len + i + 1, sizeof(char*));
|
||||||
|
|
||||||
for(s = 0; s < S; ++s)
|
for(s = 0; s < S; ++s)
|
||||||
for(i = 1; i < conf.ntag[s] + 1; ++i, ++pos)
|
for(i = 1; i < conf.ntag[s] + 1; ++i, ++pos)
|
||||||
|
|||||||
@ -83,7 +83,7 @@ frame_create(Client *c)
|
|||||||
/* Buttons */
|
/* Buttons */
|
||||||
if(BUTTONWH >= 1)
|
if(BUTTONWH >= 1)
|
||||||
{
|
{
|
||||||
c->button = emalloc(conf.titlebar.nbutton, sizeof(Window));
|
c->button = xcalloc(conf.titlebar.nbutton, sizeof(Window));
|
||||||
for(i = 0; i < conf.titlebar.nbutton; ++i)
|
for(i = 0; i < conf.titlebar.nbutton; ++i)
|
||||||
{
|
{
|
||||||
CWIN(c->button[i], c->titlebar->win,
|
CWIN(c->button[i], c->titlebar->win,
|
||||||
|
|||||||
@ -60,14 +60,14 @@ getinfo_tag(void)
|
|||||||
if(XGetWindowProperty(dpy, ROOT, ATOM("_WMFS_CURRENT_TAG"), 0L, 4096,
|
if(XGetWindowProperty(dpy, ROOT, ATOM("_WMFS_CURRENT_TAG"), 0L, 4096,
|
||||||
False, ATOM("UTF8_STRING"), &rt, &rf, &ir, &il, &ret) == Success && ret)
|
False, ATOM("UTF8_STRING"), &rt, &rf, &ir, &il, &ret) == Success && ret)
|
||||||
{
|
{
|
||||||
tag_name = _strdup((char*)ret);
|
tag_name = xstrdup((char*)ret);
|
||||||
XFree(ret);
|
XFree(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(XGetWindowProperty(dpy, ROOT, ATOM("_WMFS_TAG_LIST"), 0L, 4096,
|
if(XGetWindowProperty(dpy, ROOT, ATOM("_WMFS_TAG_LIST"), 0L, 4096,
|
||||||
False, ATOM("UTF8_STRING"), &rt, &rf, &ir, &il, &ret) == Success && ret)
|
False, ATOM("UTF8_STRING"), &rt, &rf, &ir, &il, &ret) == Success && ret)
|
||||||
{
|
{
|
||||||
tag_list = _strdup((char*)ret);
|
tag_list = xstrdup((char*)ret);
|
||||||
XFree(ret);
|
XFree(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ getinfo_layout(void)
|
|||||||
if(XGetWindowProperty(dpy, ROOT, ATOM("_WMFS_CURRENT_LAYOUT"), 0L, 4096,
|
if(XGetWindowProperty(dpy, ROOT, ATOM("_WMFS_CURRENT_LAYOUT"), 0L, 4096,
|
||||||
False, ATOM("UTF8_STRING"), &rt, &rf, &ir, &il, &ret) == Success && ret)
|
False, ATOM("UTF8_STRING"), &rt, &rf, &ir, &il, &ret) == Success && ret)
|
||||||
{
|
{
|
||||||
layout = _strdup((char*)ret);
|
layout = xstrdup((char*)ret);
|
||||||
XFree(ret);
|
XFree(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ getinfo_mwfact(void)
|
|||||||
if(XGetWindowProperty(dpy, ROOT, ATOM("_WMFS_MWFACT"), 0L, 4096,
|
if(XGetWindowProperty(dpy, ROOT, ATOM("_WMFS_MWFACT"), 0L, 4096,
|
||||||
False, XA_STRING, &rt, &rf, &ir, &il, &ret) == Success && ret)
|
False, XA_STRING, &rt, &rf, &ir, &il, &ret) == Success && ret)
|
||||||
{
|
{
|
||||||
mwfact = _strdup((char*)ret);
|
mwfact = xstrdup((char*)ret);
|
||||||
XFree(ret);
|
XFree(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,7 @@ infobar_init(void)
|
|||||||
s = screen_count();
|
s = screen_count();
|
||||||
|
|
||||||
if(!infobar)
|
if(!infobar)
|
||||||
infobar = emalloc(s, sizeof(InfoBar));
|
infobar = xcalloc(s, sizeof(InfoBar));
|
||||||
|
|
||||||
for(sc = 0; sc < s; ++sc)
|
for(sc = 0; sc < s; ++sc)
|
||||||
{
|
{
|
||||||
@ -127,7 +127,7 @@ infobar_init(void)
|
|||||||
barwin_refresh(infobar[sc].bar);
|
barwin_refresh(infobar[sc].bar);
|
||||||
|
|
||||||
/* Default statustext is set here */
|
/* Default statustext is set here */
|
||||||
infobar[sc].statustext = _strdup(WMFS_VERSION);
|
infobar[sc].statustext = xstrdup(WMFS_VERSION);
|
||||||
|
|
||||||
infobar_draw(sc);
|
infobar_draw(sc);
|
||||||
}
|
}
|
||||||
@ -190,7 +190,7 @@ infobar_draw_selbar(int sc)
|
|||||||
|
|
||||||
if(conf.selbar.maxlength >= 0 && sel)
|
if(conf.selbar.maxlength >= 0 && sel)
|
||||||
{
|
{
|
||||||
str = emalloc(conf.selbar.maxlength + 4, sizeof(char));
|
str = xcalloc(conf.selbar.maxlength + 4, sizeof(char));
|
||||||
strncpy(str, sel->title, conf.selbar.maxlength);
|
strncpy(str, sel->title, conf.selbar.maxlength);
|
||||||
|
|
||||||
if(strlen(sel->title) > (size_t)conf.selbar.maxlength)
|
if(strlen(sel->title) > (size_t)conf.selbar.maxlength)
|
||||||
|
|||||||
@ -196,7 +196,7 @@ init_status(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.status_path = emalloc(strlen(home) + strlen(DEF_STATUS) + 2, sizeof(char));
|
conf.status_path = zmalloc(strlen(home) + strlen(DEF_STATUS) + 2);
|
||||||
sprintf(conf.status_path, "%s/"DEF_STATUS, home);
|
sprintf(conf.status_path, "%s/"DEF_STATUS, home);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -253,12 +253,11 @@ complete_on_command(char *start, size_t hits)
|
|||||||
|
|
||||||
char **namelist = NULL;
|
char **namelist = NULL;
|
||||||
int n = 0, i;
|
int n = 0, i;
|
||||||
void *temp = NULL;
|
|
||||||
|
|
||||||
if (!getenv("PATH") || !start || hits <= 0)
|
if (!getenv("PATH") || !start || hits <= 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
path = _strdup(getenv("PATH"));
|
path = xstrdup(getenv("PATH"));
|
||||||
dirname = strtok(path, ":");
|
dirname = strtok(path, ":");
|
||||||
|
|
||||||
/* recursively open PATH */
|
/* recursively open PATH */
|
||||||
@ -272,10 +271,8 @@ complete_on_command(char *start, size_t hits)
|
|||||||
{
|
{
|
||||||
if (!strncmp(content->d_name, start, strlen(start)))
|
if (!strncmp(content->d_name, start, strlen(start)))
|
||||||
{
|
{
|
||||||
temp = realloc(namelist, ++n * sizeof(*namelist));
|
namelist = xrealloc(namelist, ++n, sizeof(*namelist));
|
||||||
if ( temp != NULL )
|
namelist[n-1] = xstrdup(content->d_name);
|
||||||
namelist = temp;
|
|
||||||
namelist[n-1] = strdup(content->d_name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,7 +286,7 @@ complete_on_command(char *start, size_t hits)
|
|||||||
|
|
||||||
if(n > 0)
|
if(n > 0)
|
||||||
{
|
{
|
||||||
ret = _strdup(namelist[((hits > 0) ? hits - 1 : 0) % n] + strlen(start));
|
ret = xstrdup(namelist[((hits > 0) ? hits - 1 : 0) % n] + strlen(start));
|
||||||
|
|
||||||
for(i = 0; i < n; i++)
|
for(i = 0; i < n; i++)
|
||||||
free(namelist[i]);
|
free(namelist[i]);
|
||||||
@ -324,14 +321,14 @@ complete_on_files(char *start, size_t hits)
|
|||||||
* the beginning of file to complete on pointer 'p'.
|
* the beginning of file to complete on pointer 'p'.
|
||||||
*/
|
*/
|
||||||
if (*(++p) == '\0' || !strrchr(p, '/'))
|
if (*(++p) == '\0' || !strrchr(p, '/'))
|
||||||
path = _strdup(".");
|
path = xstrdup(".");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* remplace ~ by $HOME in dirname */
|
/* remplace ~ by $HOME in dirname */
|
||||||
if (!strncmp(p, "~/", 2) && getenv("HOME"))
|
if (!strncmp(p, "~/", 2) && getenv("HOME"))
|
||||||
xasprintf(&dirname, "%s%s", getenv("HOME"), p+1);
|
xasprintf(&dirname, "%s%s", getenv("HOME"), p+1);
|
||||||
else
|
else
|
||||||
dirname = _strdup(p);
|
dirname = xstrdup(p);
|
||||||
|
|
||||||
/* Set p to filename to be complete
|
/* Set p to filename to be complete
|
||||||
* and path the directory containing the file
|
* and path the directory containing the file
|
||||||
@ -342,11 +339,11 @@ complete_on_files(char *start, size_t hits)
|
|||||||
if (p != dirname)
|
if (p != dirname)
|
||||||
{
|
{
|
||||||
*(p++) = '\0';
|
*(p++) = '\0';
|
||||||
path = _strdup(dirname);
|
path = xstrdup(dirname);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
path = _strdup("/");
|
path = xstrdup("/");
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -367,7 +364,7 @@ complete_on_files(char *start, size_t hits)
|
|||||||
if (S_ISDIR(st.st_mode))
|
if (S_ISDIR(st.st_mode))
|
||||||
xasprintf(&ret, "%s/", content->d_name + strlen(p));
|
xasprintf(&ret, "%s/", content->d_name + strlen(p));
|
||||||
else
|
else
|
||||||
ret = _strdup(content->d_name + strlen(p));
|
ret = xstrdup(content->d_name + strlen(p));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
warn("%s", filepath);
|
warn("%s", filepath);
|
||||||
|
|||||||
@ -823,7 +823,7 @@ uicb_set_layout(uicb_t cmd)
|
|||||||
for(n = 0; layout_list[n].name != NULL && layout_list[n].func != NULL; ++n);
|
for(n = 0; layout_list[n].name != NULL && layout_list[n].func != NULL; ++n);
|
||||||
|
|
||||||
for(i = 0; i < n; ++i)
|
for(i = 0; i < n; ++i)
|
||||||
if(!strcmp(cmd, _strdup(layout_list[i].name)))
|
if(!strcmp(cmd, xstrdup(layout_list[i].name)))
|
||||||
for(j = 0; j < LEN(conf.layout); ++j)
|
for(j = 0; j < LEN(conf.layout); ++j)
|
||||||
if(layout_list[i].func == conf.layout[j].func)
|
if(layout_list[i].func == conf.layout[j].func)
|
||||||
tags[selscreen][seltag[selscreen]].layout = conf.layout[j];
|
tags[selscreen][seltag[selscreen]].layout = conf.layout[j];
|
||||||
|
|||||||
@ -37,7 +37,7 @@ menu_init(Menu *menu, char *name, int nitem, uint bg_f, char *fg_f, uint bg_n, c
|
|||||||
{
|
{
|
||||||
/* Item */
|
/* Item */
|
||||||
menu->nitem = nitem;
|
menu->nitem = nitem;
|
||||||
menu->item = emalloc(sizeof(MenuItem), nitem);
|
menu->item = xcalloc(nitem, sizeof(*menu->item));
|
||||||
menu->name = name;
|
menu->name = name;
|
||||||
|
|
||||||
/* Colors */
|
/* Colors */
|
||||||
|
|||||||
@ -14,8 +14,12 @@
|
|||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#endif
|
||||||
|
#ifndef _BSD_SOURCE
|
||||||
#define _BSD_SOURCE
|
#define _BSD_SOURCE
|
||||||
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -87,7 +91,7 @@ push_keyword(struct keyword *tail, enum keyword_t type, char *buf, size_t *offse
|
|||||||
if (type == WORD && *offset == 0)
|
if (type == WORD && *offset == 0)
|
||||||
return tail;
|
return tail;
|
||||||
|
|
||||||
kw = xcalloc(1, sizeof(*kw));
|
kw = zcalloc(sizeof(*kw));
|
||||||
kw->type = type;
|
kw->type = type;
|
||||||
kw->line = line;
|
kw->line = line;
|
||||||
kw->file = file;
|
kw->file = file;
|
||||||
@ -179,8 +183,8 @@ parse_keywords(const char *filename)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
file = xcalloc(1, sizeof(*file));
|
file = zcalloc(sizeof(*file));
|
||||||
bufname = xcalloc(1, sizeof(*bufname) * BUFSIZ);
|
bufname = zcalloc(sizeof(*bufname) * BUFSIZ);
|
||||||
file->name = strdup(path);
|
file->name = strdup(path);
|
||||||
file->parent = NULL;
|
file->parent = NULL;
|
||||||
|
|
||||||
@ -394,7 +398,7 @@ get_option(struct keyword **head)
|
|||||||
size_t j = 0;
|
size_t j = 0;
|
||||||
struct keyword *kw = *head;
|
struct keyword *kw = *head;
|
||||||
|
|
||||||
o = xcalloc(1, sizeof(*o));
|
o = zcalloc(sizeof(*o));
|
||||||
o->name = kw->name;
|
o->name = kw->name;
|
||||||
o->used = False;
|
o->used = False;
|
||||||
o->line = kw->line;
|
o->line = kw->line;
|
||||||
@ -495,7 +499,7 @@ get_section(struct keyword **head)
|
|||||||
struct conf_sec *sub;
|
struct conf_sec *sub;
|
||||||
struct keyword *kw = *head;
|
struct keyword *kw = *head;
|
||||||
|
|
||||||
s = xcalloc(1, sizeof(*s));
|
s = zcalloc(sizeof(*s));
|
||||||
s->name = kw->name;
|
s->name = kw->name;
|
||||||
TAILQ_INIT(&s->sub);
|
TAILQ_INIT(&s->sub);
|
||||||
SLIST_INIT(&s->optlist);
|
SLIST_INIT(&s->optlist);
|
||||||
@ -616,32 +620,3 @@ get_conf(const char *filename)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* calloc wrapper */
|
|
||||||
void *
|
|
||||||
xcalloc(size_t nmemb, size_t size)
|
|
||||||
{
|
|
||||||
void *ret;
|
|
||||||
|
|
||||||
if (!(ret = calloc(nmemb, size)))
|
|
||||||
err(EXIT_FAILURE, "calloc");
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* asprintf wrapper */
|
|
||||||
int
|
|
||||||
xasprintf(char **strp, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
va_list args;
|
|
||||||
|
|
||||||
va_start(args, fmt);
|
|
||||||
ret = vasprintf(strp, fmt, args);
|
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
if (ret == -1)
|
|
||||||
err(EXIT_FAILURE, "asprintf");
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
@ -17,6 +17,7 @@
|
|||||||
#ifndef PARSE_H
|
#ifndef PARSE_H
|
||||||
#define PARSE_H
|
#define PARSE_H
|
||||||
|
|
||||||
|
#include "wmfs.h"
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
|
|
||||||
#define INCLUDE_CMD "@include"
|
#define INCLUDE_CMD "@include"
|
||||||
@ -117,10 +118,4 @@ struct opt_type *fetch_opt(struct conf_sec *, char *, char *);
|
|||||||
*/
|
*/
|
||||||
size_t fetch_opt_count(struct opt_type *);
|
size_t fetch_opt_count(struct opt_type *);
|
||||||
|
|
||||||
|
|
||||||
/* wrapper for calloc */
|
|
||||||
void *xcalloc(size_t, size_t);
|
|
||||||
/* wrapper for asprintf */
|
|
||||||
int xasprintf(char **, const char *, ...);
|
|
||||||
|
|
||||||
#endif /* PARSE_H */
|
#endif /* PARSE_H */
|
||||||
@ -14,7 +14,9 @@
|
|||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _BSD_SOURCE
|
||||||
#define _BSD_SOURCE
|
#define _BSD_SOURCE
|
||||||
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
@ -177,8 +177,8 @@ screen_init_geo(void)
|
|||||||
int i;
|
int i;
|
||||||
int s = screen_count();
|
int s = screen_count();
|
||||||
|
|
||||||
sgeo = emalloc(s, sizeof(XRectangle));
|
sgeo = xcalloc(s, sizeof(XRectangle));
|
||||||
spgeo = emalloc(s, sizeof(XRectangle));
|
spgeo = xcalloc(s, sizeof(XRectangle));
|
||||||
|
|
||||||
for(i = 0; i < s; ++i)
|
for(i = 0; i < s; ++i)
|
||||||
sgeo[i] = screen_get_geo(i);
|
sgeo[i] = screen_get_geo(i);
|
||||||
|
|||||||
@ -212,7 +212,7 @@ statustext_handle(int sc, char *str)
|
|||||||
/* save last status text address (for free at the end) */
|
/* save last status text address (for free at the end) */
|
||||||
lastst = infobar[sc].statustext;
|
lastst = infobar[sc].statustext;
|
||||||
|
|
||||||
infobar[sc].statustext = _strdup(str);
|
infobar[sc].statustext = xstrdup(str);
|
||||||
len = ((strlen(str) > MAXSTATUS) ? MAXSTATUS : strlen(str));
|
len = ((strlen(str) > MAXSTATUS) ? MAXSTATUS : strlen(str));
|
||||||
|
|
||||||
/* Store rectangles, located text & images properties. */
|
/* Store rectangles, located text & images properties. */
|
||||||
|
|||||||
@ -85,7 +85,7 @@ systray_add(Window win)
|
|||||||
if(!conf.systray.active)
|
if(!conf.systray.active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s = emalloc(1, sizeof(Systray));
|
s = zcalloc(sizeof(Systray));
|
||||||
s->win = win;
|
s->win = win;
|
||||||
|
|
||||||
s->geo.height = infobar[conf.systray.screen].bar->geo.height;
|
s->geo.height = infobar[conf.systray.screen].bar->geo.height;
|
||||||
|
|||||||
@ -512,7 +512,7 @@ tag_new(int s, char *name)
|
|||||||
{
|
{
|
||||||
if(conf.tagnamecount)
|
if(conf.tagnamecount)
|
||||||
{
|
{
|
||||||
displayedName = (char*) malloc( sizeof(char)*2 );
|
displayedName = zmalloc(2);
|
||||||
sprintf(displayedName, "[%d]", conf.ntag[s]);
|
sprintf(displayedName, "[%d]", conf.ntag[s]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
118
src/util.c
118
src/util.c
@ -32,22 +32,100 @@
|
|||||||
|
|
||||||
#include "wmfs.h"
|
#include "wmfs.h"
|
||||||
|
|
||||||
/** Calloc with an error message if there is a probleme
|
/** malloc with error support and size_t overflow protection
|
||||||
* \param element Element
|
* \param nmemb number of objects
|
||||||
* \param size Size
|
* \param size size of single object
|
||||||
* \return void pointer
|
* \return non null void pointer
|
||||||
*/
|
*/
|
||||||
void*
|
void *
|
||||||
emalloc(uint element, uint size)
|
xmalloc(size_t nmemb, size_t size)
|
||||||
{
|
{
|
||||||
void *ret = calloc(element, size);
|
void *ret;
|
||||||
|
|
||||||
if(!ret)
|
if (SIZE_MAX / nmemb < size)
|
||||||
warn("calloc()");
|
err(EXIT_FAILURE, "xmalloc(%zu, %zu), "
|
||||||
|
"size_t overflow detected", nmemb, size);
|
||||||
|
|
||||||
|
if ((ret = malloc(nmemb * size)) == NULL)
|
||||||
|
err(EXIT_FAILURE, "malloc(%zu)", nmemb * size);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** calloc with error support
|
||||||
|
* \param nmemb Number of objects
|
||||||
|
* \param size size of single object
|
||||||
|
* \return non null void pointer
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
xcalloc(size_t nmemb, size_t size)
|
||||||
|
{
|
||||||
|
void *ret;
|
||||||
|
|
||||||
|
if ((ret = calloc(nmemb, size)) == NULL)
|
||||||
|
err(EXIT_FAILURE, "calloc(%zu * %zu)", nmemb, size);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** realloc with error support and size_t overflow check
|
||||||
|
* \param ptr old pointer
|
||||||
|
* \param nmemb number of objects
|
||||||
|
* \param size size of single object
|
||||||
|
* \return non null void pointer
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
xrealloc(void *ptr, size_t nmemb, size_t size)
|
||||||
|
{
|
||||||
|
void *ret;
|
||||||
|
|
||||||
|
if (SIZE_MAX / nmemb < size)
|
||||||
|
err(EXIT_FAILURE, "xrealloc(%p, %zu, %zu), "
|
||||||
|
"size_t overflow detected", ptr, nmemb, size);
|
||||||
|
|
||||||
|
if ((ret = realloc(ptr, nmemb * size)) == NULL)
|
||||||
|
err(EXIT_FAILURE, "realloc(%p, %zu)", ptr, nmemb * size);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** strdup with error support
|
||||||
|
* \param str char pointer
|
||||||
|
* \retun non null void pointer
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
xstrdup(const char *str)
|
||||||
|
{
|
||||||
|
char *ret;
|
||||||
|
|
||||||
|
if (str == NULL || (ret = strdup(str)) == NULL)
|
||||||
|
err(EXIT_FAILURE, "strdup(%s)", str);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** asprintf wrapper
|
||||||
|
* \param strp target string
|
||||||
|
* \param fmt format
|
||||||
|
* \return non zero integer
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xasprintf(char **strp, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
ret = vasprintf(strp, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
if (ret == -1)
|
||||||
|
err(EXIT_FAILURE, "asprintf(%s)", fmt);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Get a color with a string
|
/** Get a color with a string
|
||||||
* \param color Color string
|
* \param color Color string
|
||||||
* \return Color pixel
|
* \return Color pixel
|
||||||
@ -93,20 +171,6 @@ setwinstate(Window win, long state)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** My strdup. the strdup of string.h isn't ansi compatible..
|
|
||||||
* Thanks linkdd.
|
|
||||||
* \param str char pointer
|
|
||||||
*/
|
|
||||||
char*
|
|
||||||
_strdup(const char *str)
|
|
||||||
{
|
|
||||||
char *ret = emalloc(strlen(str) + 1, sizeof(char));
|
|
||||||
|
|
||||||
strcpy(ret, str);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The following function are for configuration
|
/* The following function are for configuration
|
||||||
usage. {{{
|
usage. {{{
|
||||||
*/
|
*/
|
||||||
@ -176,9 +240,9 @@ alias_to_str(char *conf_choice)
|
|||||||
tmpchar = conf.alias[i].content;
|
tmpchar = conf.alias[i].content;
|
||||||
|
|
||||||
if(tmpchar)
|
if(tmpchar)
|
||||||
return _strdup(tmpchar);
|
return xstrdup(tmpchar);
|
||||||
else
|
else
|
||||||
return _strdup(conf_choice);
|
return xstrdup(conf_choice);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -327,7 +391,7 @@ clean_value(char *str)
|
|||||||
int i;
|
int i;
|
||||||
char c, *p;
|
char c, *p;
|
||||||
|
|
||||||
if(!str || !(p = _strdup(str)))
|
if(!str || !(p = xstrdup(str)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Remove useless spaces */
|
/* Remove useless spaces */
|
||||||
|
|||||||
@ -116,7 +116,7 @@ viwmfs(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
for(i = 0; i < strlen(str); str[i] = str[i + 1], ++i);
|
for(i = 0; i < strlen(str); str[i] = str[i + 1], ++i);
|
||||||
|
|
||||||
cmd = _strdup(str);
|
cmd = xstrdup(str);
|
||||||
|
|
||||||
for(i = 0; cmd[i] && cmd[i] != ' '; ++i);
|
for(i = 0; cmd[i] && cmd[i] != ' '; ++i);
|
||||||
cmd[i] = '\0';
|
cmd[i] = '\0';
|
||||||
|
|||||||
@ -422,7 +422,7 @@ main(int argc, char **argv)
|
|||||||
int i;
|
int i;
|
||||||
char *ol = "csgVS";
|
char *ol = "csgVS";
|
||||||
|
|
||||||
argv_global = _strdup(argv[0]);
|
argv_global = xstrdup(argv[0]);
|
||||||
sprintf(conf.confpath, "%s/"DEF_CONF, getenv("HOME"));
|
sprintf(conf.confpath, "%s/"DEF_CONF, getenv("HOME"));
|
||||||
|
|
||||||
while((i = getopt(argc, argv, "hviSc:s:g:C:V:")) != -1)
|
while((i = getopt(argc, argv, "hviSc:s:g:C:V:")) != -1)
|
||||||
|
|||||||
23
src/wmfs.h
23
src/wmfs.h
@ -34,14 +34,22 @@
|
|||||||
#define WMFS_H
|
#define WMFS_H
|
||||||
|
|
||||||
/* glibc stuff */
|
/* glibc stuff */
|
||||||
|
#ifndef _BSD_SOURCE
|
||||||
#define _BSD_SOURCE /* vsnprintf */
|
#define _BSD_SOURCE /* vsnprintf */
|
||||||
#define _POSIX_SOURCE /* kill() */
|
#endif
|
||||||
|
#ifndef _POSIX_SOURCE
|
||||||
|
#define _POSIX_SOURCE /* kill */
|
||||||
|
#endif
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
|
#define _GNU_SOURCE /* asprintf */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Lib headers */
|
/* Lib headers */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@ -61,7 +69,7 @@
|
|||||||
#include <X11/Xft/Xft.h>
|
#include <X11/Xft/Xft.h>
|
||||||
|
|
||||||
/* Local headers */
|
/* Local headers */
|
||||||
#include "parse/parse.h"
|
#include "parse.h"
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
|
|
||||||
/* Optional dependencies */
|
/* Optional dependencies */
|
||||||
@ -281,11 +289,18 @@ void uicb_mouse_move(uicb_t);
|
|||||||
void uicb_mouse_resize(uicb_t);
|
void uicb_mouse_resize(uicb_t);
|
||||||
|
|
||||||
/* util.c */
|
/* util.c */
|
||||||
|
void *xmalloc(size_t, size_t);
|
||||||
|
void *xcalloc(size_t, size_t);
|
||||||
|
void *xrealloc(void *, size_t, size_t);
|
||||||
|
/* simples wrappers for allocating only one object */
|
||||||
|
#define zmalloc(size) xmalloc(1, (size))
|
||||||
|
#define zcalloc(size) xcalloc(1, (size))
|
||||||
|
#define zrealloc(ptr, size) xrealloc((ptr), 1, (size))
|
||||||
|
char *xstrdup(const char *);
|
||||||
|
int xasprintf(char **, const char *, ...);
|
||||||
ulong color_enlight(ulong col);
|
ulong color_enlight(ulong col);
|
||||||
void *emalloc(uint element, uint size);
|
|
||||||
long getcolor(char *color);
|
long getcolor(char *color);
|
||||||
void setwinstate(Window win, long state);
|
void setwinstate(Window win, long state);
|
||||||
char* _strdup(char const *str);
|
|
||||||
/* Conf usage {{{ */
|
/* Conf usage {{{ */
|
||||||
void* name_to_func(char *name, const func_name_list_t *l);
|
void* name_to_func(char *name, const func_name_list_t *l);
|
||||||
ulong char_to_modkey(char *name, key_name_list_t key_l[]);
|
ulong char_to_modkey(char *name, key_name_list_t key_l[]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user