Eliminate use of word() and atword().
SVN revision: 28473
This commit is contained in:
parent
15ca4f8718
commit
4071d88a87
|
@ -31,7 +31,6 @@
|
|||
#include "emodule.h"
|
||||
#include "file.h"
|
||||
#include "iclass.h"
|
||||
#include "parse.h"
|
||||
#include "settings.h"
|
||||
#include "tclass.h"
|
||||
#include "timers.h"
|
||||
|
@ -2378,7 +2377,7 @@ BackgroundSet1(const char *name, const char *params)
|
|||
Background *bg;
|
||||
XColor xclr;
|
||||
|
||||
if (!p)
|
||||
if (!p || !p[0])
|
||||
return;
|
||||
|
||||
bg = BackgroundFind(name);
|
||||
|
@ -2514,7 +2513,7 @@ BackgroundsIpc(const char *params, Client * c __UNUSED__)
|
|||
{
|
||||
const char *p;
|
||||
char cmd[128], prm[128], buf[4096];
|
||||
int i, len, num;
|
||||
int i, len, num, len2;
|
||||
Background *bg;
|
||||
|
||||
cmd[0] = prm[0] = '\0';
|
||||
|
@ -2522,7 +2521,7 @@ BackgroundsIpc(const char *params, Client * c __UNUSED__)
|
|||
if (p)
|
||||
{
|
||||
len = 0;
|
||||
sscanf(p, "%100s %100s %n", cmd, prm, &len);
|
||||
sscanf(p, "%100s %n%100s %n", cmd, &len2, prm, &len);
|
||||
p += len;
|
||||
}
|
||||
|
||||
|
@ -2626,32 +2625,38 @@ BackgroundsIpc(const char *params, Client * c __UNUSED__)
|
|||
else
|
||||
{
|
||||
/* Compatibility with pre- 0.16.8 clients */
|
||||
BackgroundSet1(cmd, atword(params, 2));
|
||||
BackgroundSet1(cmd, params + len2);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
IPC_BackgroundUse(const char *params, Client * c __UNUSED__)
|
||||
{
|
||||
char param1[FILEPATH_LEN_MAX], w[FILEPATH_LEN_MAX];
|
||||
char name[1024];
|
||||
const char *p;
|
||||
Background *bg;
|
||||
int i, wd;
|
||||
int i, l;
|
||||
|
||||
word(params, 1, param1);
|
||||
p = params;
|
||||
name[0] = '\0';
|
||||
l = 0;
|
||||
sscanf(p, "%1000s %n", name, &l);
|
||||
p += l;
|
||||
|
||||
bg = BackgroundFind(param1);
|
||||
bg = BackgroundFind(name);
|
||||
if (!bg)
|
||||
return;
|
||||
|
||||
for (wd = 2;; wd++)
|
||||
for (;;)
|
||||
{
|
||||
w[0] = 0;
|
||||
word(params, wd++, w);
|
||||
if (!w[0])
|
||||
i = l = -1;
|
||||
sscanf(p, "%d %n", &i, &l);
|
||||
p += l;
|
||||
if (i < 0)
|
||||
break;
|
||||
i = atoi(w);
|
||||
DeskBackgroundSet(DeskGet(i), bg);
|
||||
}
|
||||
|
||||
autosave();
|
||||
}
|
||||
|
||||
|
|
78
src/iclass.c
78
src/iclass.c
|
@ -29,7 +29,6 @@
|
|||
#include "eimage.h"
|
||||
#include "emodule.h"
|
||||
#include "iclass.h"
|
||||
#include "parse.h"
|
||||
#include "tclass.h"
|
||||
#include "xwin.h"
|
||||
|
||||
|
@ -1466,9 +1465,10 @@ ImageclassSighan(int sig, void *prm __UNUSED__)
|
|||
static void
|
||||
ImageclassIpc(const char *params, Client * c __UNUSED__)
|
||||
{
|
||||
char param1[FILEPATH_LEN_MAX];
|
||||
char param2[FILEPATH_LEN_MAX];
|
||||
char param3[FILEPATH_LEN_MAX];
|
||||
char param1[1024];
|
||||
char param2[1024];
|
||||
int l;
|
||||
const char *p;
|
||||
ImageClass *ic;
|
||||
|
||||
if (!params)
|
||||
|
@ -1477,12 +1477,11 @@ ImageclassIpc(const char *params, Client * c __UNUSED__)
|
|||
return;
|
||||
}
|
||||
|
||||
param1[0] = 0;
|
||||
param2[0] = 0;
|
||||
param3[0] = 0;
|
||||
|
||||
word(params, 1, param1);
|
||||
word(params, 2, param2);
|
||||
p = params;
|
||||
l = 0;
|
||||
param1[0] = param2[0] = '\0';
|
||||
sscanf(p, "%1000s %1000s %n", param1, param2, &l);
|
||||
p += l;
|
||||
|
||||
if (!strncmp(param1, "list", 2))
|
||||
{
|
||||
|
@ -1503,11 +1502,10 @@ ImageclassIpc(const char *params, Client * c __UNUSED__)
|
|||
}
|
||||
else if (!strcmp(param2, "free_pixmap"))
|
||||
{
|
||||
Pixmap p;
|
||||
Pixmap pmap;
|
||||
|
||||
word(params, 3, param3);
|
||||
p = (Pixmap) strtol(param3, (char **)NULL, 0);
|
||||
EImagePixmapFree(p);
|
||||
pmap = (Pixmap) strtol(p, NULL, 0);
|
||||
EImagePixmapFree(pmap);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1549,17 +1547,21 @@ ImageclassIpc(const char *params, Client * c __UNUSED__)
|
|||
Window xwin;
|
||||
Win win;
|
||||
char state[20];
|
||||
const char *winptr, *hptr;
|
||||
int st, w = -1, h = -1;
|
||||
int st, w, h;
|
||||
|
||||
/* 3:xwin 4:state 5:w 6:h */
|
||||
xwin = None;
|
||||
state[0] = '\0';
|
||||
w = h = -1;
|
||||
sscanf(p, "%lx %16s %d %d", &xwin, state, &w, &h);
|
||||
|
||||
winptr = atword(params, 3);
|
||||
xwin = (Window) strtoul(winptr, NULL, 0);
|
||||
win = ECreateWinFromXwin(xwin);
|
||||
if (!win)
|
||||
return;
|
||||
|
||||
word(params, 4, state);
|
||||
if (!strcmp(state, "hilited"))
|
||||
if (!strcmp(state, "normal"))
|
||||
st = STATE_NORMAL;
|
||||
else if (!strcmp(state, "hilited"))
|
||||
st = STATE_HILITED;
|
||||
else if (!strcmp(state, "clicked"))
|
||||
st = STATE_CLICKED;
|
||||
|
@ -1568,13 +1570,6 @@ ImageclassIpc(const char *params, Client * c __UNUSED__)
|
|||
else
|
||||
st = STATE_NORMAL;
|
||||
|
||||
hptr = atword(params, 6);
|
||||
if (hptr)
|
||||
{
|
||||
w = (int)strtol(atword(params, 5), NULL, 0);
|
||||
h = (int)strtol(hptr, NULL, 0);
|
||||
}
|
||||
|
||||
ImageclassApply(ic, win, w, h, 0, 0, st, ST_SOLID);
|
||||
EDestroyWin(win);
|
||||
}
|
||||
|
@ -1583,15 +1578,22 @@ ImageclassIpc(const char *params, Client * c __UNUSED__)
|
|||
Window xwin;
|
||||
Win win;
|
||||
char state[20];
|
||||
const char *winptr, *hptr;
|
||||
int st, w = -1, h = -1;
|
||||
int st, w, h;
|
||||
PmapMask pmm;
|
||||
|
||||
winptr = atword(params, 3);
|
||||
xwin = (Window) strtoul(winptr, NULL, 0);
|
||||
/* 3:xwin 4:state 5:w 6:h */
|
||||
xwin = None;
|
||||
state[0] = '\0';
|
||||
w = h = -1;
|
||||
sscanf(p, "%lx %16s %d %d", &xwin, state, &w, &h);
|
||||
|
||||
word(params, 4, state);
|
||||
if (!strcmp(state, "hilited"))
|
||||
win = ECreateWinFromXwin(xwin);
|
||||
if (!win)
|
||||
return;
|
||||
|
||||
if (!strcmp(state, "normal"))
|
||||
st = STATE_NORMAL;
|
||||
else if (!strcmp(state, "hilited"))
|
||||
st = STATE_HILITED;
|
||||
else if (!strcmp(state, "clicked"))
|
||||
st = STATE_CLICKED;
|
||||
|
@ -1600,20 +1602,12 @@ ImageclassIpc(const char *params, Client * c __UNUSED__)
|
|||
else
|
||||
st = STATE_NORMAL;
|
||||
|
||||
hptr = atword(params, 6);
|
||||
if (!hptr)
|
||||
if (w < 0 || h < 0)
|
||||
{
|
||||
IpcPrintf("Error: missing width and/or height\n");
|
||||
return;
|
||||
}
|
||||
|
||||
w = (int)strtol(atword(params, 5), NULL, 0);
|
||||
h = (int)strtol(hptr, NULL, 0);
|
||||
|
||||
win = ECreateWinFromXwin(xwin);
|
||||
if (!win)
|
||||
return;
|
||||
|
||||
ImageclassApplyCopy(ic, win, w, h, 0, 0, st, &pmm, 1, ST_SOLID);
|
||||
IpcPrintf("0x%08lx 0x%08lx\n", pmm.pmap, pmm.mask);
|
||||
EDestroyWin(win);
|
||||
|
|
42
src/ipc.c
42
src/ipc.c
|
@ -31,7 +31,6 @@
|
|||
#include "ewin-ops.h"
|
||||
#include "grabs.h"
|
||||
#include "hints.h" /* FIXME - Should not be here */
|
||||
#include "parse.h"
|
||||
#include "screen.h"
|
||||
#include "session.h"
|
||||
#include "snaps.h"
|
||||
|
@ -994,7 +993,7 @@ IPC_WinOps(const char *params, Client * c __UNUSED__)
|
|||
static void
|
||||
IPC_Remember(const char *params, Client * c __UNUSED__)
|
||||
{
|
||||
int window;
|
||||
int window, l;
|
||||
EWin *ewin;
|
||||
|
||||
if (!params)
|
||||
|
@ -1003,8 +1002,12 @@ IPC_Remember(const char *params, Client * c __UNUSED__)
|
|||
goto done;
|
||||
}
|
||||
|
||||
l = 0;
|
||||
window = 0;
|
||||
sscanf(params, "%x", &window);
|
||||
sscanf(params, "%x %n", &window, &l);
|
||||
if (l <= 0)
|
||||
return;
|
||||
|
||||
ewin = EwinFindByClient(window);
|
||||
if (!ewin)
|
||||
{
|
||||
|
@ -1012,7 +1015,7 @@ IPC_Remember(const char *params, Client * c __UNUSED__)
|
|||
goto done;
|
||||
}
|
||||
|
||||
SnapshotEwinParse(ewin, atword(params, 2));
|
||||
SnapshotEwinParse(ewin, params + l);
|
||||
|
||||
done:
|
||||
return;
|
||||
|
@ -1033,10 +1036,14 @@ IPC_Restart(const char *params __UNUSED__, Client * c __UNUSED__)
|
|||
static void
|
||||
IPC_Exit(const char *params, Client * c __UNUSED__)
|
||||
{
|
||||
char param1[FILEPATH_LEN_MAX];
|
||||
char param1[1024];
|
||||
const char *p2;
|
||||
int l;
|
||||
|
||||
param1[0] = 0;
|
||||
word(params, 1, param1);
|
||||
l = 0;
|
||||
sscanf(params, "%1000s %n", param1, &l);
|
||||
p2 = (l > 0) ? params + l : NULL;
|
||||
|
||||
if (!param1[0])
|
||||
SessionExit(EEXIT_EXIT, NULL);
|
||||
|
@ -1045,9 +1052,9 @@ IPC_Exit(const char *params, Client * c __UNUSED__)
|
|||
else if (!strcmp(param1, "restart"))
|
||||
SessionExit(EEXIT_RESTART, NULL);
|
||||
else if (!strcmp(param1, "theme"))
|
||||
SessionExit(EEXIT_THEME, atword(params, 2));
|
||||
SessionExit(EEXIT_THEME, p2);
|
||||
else if (!strcmp(param1, "exec"))
|
||||
SessionExit(EEXIT_EXEC, atword(params, 2));
|
||||
SessionExit(EEXIT_EXEC, p2);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1588,7 +1595,8 @@ int
|
|||
HandleIPC(const char *params, Client * c)
|
||||
{
|
||||
int i, num, ok;
|
||||
char w[FILEPATH_LEN_MAX];
|
||||
char cmd[128];
|
||||
const char *prm;
|
||||
const IpcItem **lst, *ipc;
|
||||
|
||||
if (EDebug(EDBUG_TYPE_IPC))
|
||||
|
@ -1596,24 +1604,20 @@ HandleIPC(const char *params, Client * c)
|
|||
|
||||
IpcPrintInit();
|
||||
|
||||
lst = IPC_GetList(&num);
|
||||
cmd[0] = 0;
|
||||
sscanf(params, "%100s %n", cmd, &num);
|
||||
prm = (num > 0) ? params + num : NULL;
|
||||
|
||||
w[0] = 0;
|
||||
word(params, 1, w);
|
||||
lst = IPC_GetList(&num);
|
||||
|
||||
ok = 0;
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
ipc = lst[i];
|
||||
if (!(ipc->nick && !strcmp(w, ipc->nick)) && strcmp(w, ipc->name))
|
||||
if (!(ipc->nick && !strcmp(cmd, ipc->nick)) && strcmp(cmd, ipc->name))
|
||||
continue;
|
||||
|
||||
w[0] = 0;
|
||||
word(params, 2, w);
|
||||
if (w[0])
|
||||
ipc->func(atword(params, 2), c);
|
||||
else
|
||||
ipc->func(NULL, c);
|
||||
ipc->func(prm, c);
|
||||
|
||||
ok = 1;
|
||||
break;
|
||||
|
|
73
src/tclass.c
73
src/tclass.c
|
@ -26,7 +26,6 @@
|
|||
#include "e16-ecore_list.h"
|
||||
#include "emodule.h"
|
||||
#include "iclass.h"
|
||||
#include "parse.h"
|
||||
#include "tclass.h"
|
||||
#include "xwin.h"
|
||||
|
||||
|
@ -494,9 +493,10 @@ TextclassSighan(int sig, void *prm __UNUSED__)
|
|||
static void
|
||||
TextclassIpc(const char *params, Client * c __UNUSED__)
|
||||
{
|
||||
char param1[FILEPATH_LEN_MAX];
|
||||
char param2[FILEPATH_LEN_MAX];
|
||||
char param3[FILEPATH_LEN_MAX];
|
||||
char param1[1024];
|
||||
char param2[1024];
|
||||
int l;
|
||||
const char *p;
|
||||
TextClass *tc;
|
||||
|
||||
if (!params)
|
||||
|
@ -505,12 +505,11 @@ TextclassIpc(const char *params, Client * c __UNUSED__)
|
|||
return;
|
||||
}
|
||||
|
||||
param1[0] = 0;
|
||||
param2[0] = 0;
|
||||
param3[0] = 0;
|
||||
|
||||
word(params, 1, param1);
|
||||
word(params, 2, param2);
|
||||
p = params;
|
||||
l = 0;
|
||||
param1[0] = param2[0] = '\0';
|
||||
sscanf(params, "%1000s %1000s %n", param1, param2, &l);
|
||||
p += l;
|
||||
|
||||
if (!strncmp(param1, "list", 2))
|
||||
{
|
||||
|
@ -549,49 +548,49 @@ TextclassIpc(const char *params, Client * c __UNUSED__)
|
|||
{
|
||||
Window xwin;
|
||||
Win win;
|
||||
int state;
|
||||
int x, y;
|
||||
const char *txt;
|
||||
char state[20];
|
||||
int x, y, st;
|
||||
|
||||
word(params, 3, param3);
|
||||
xwin = (Window) strtoul(param3, NULL, 0);
|
||||
/* 3:xwin 4:x 5:y 6:state 7-:txt */
|
||||
xwin = None;
|
||||
x = y = 0;
|
||||
state[0] = '\0';
|
||||
l = 0;
|
||||
sscanf(p, "%lx %d %d %16s %n", &xwin, &x, &y, state, &l);
|
||||
p += l;
|
||||
|
||||
word(params, 4, param3);
|
||||
x = atoi(param3);
|
||||
word(params, 5, param3);
|
||||
y = atoi(param3);
|
||||
if (!strcmp(state, "normal"))
|
||||
st = STATE_NORMAL;
|
||||
else if (!strcmp(state, "hilited"))
|
||||
st = STATE_HILITED;
|
||||
else if (!strcmp(state, "clicked"))
|
||||
st = STATE_CLICKED;
|
||||
else if (!strcmp(state, "disabled"))
|
||||
st = STATE_DISABLED;
|
||||
else
|
||||
st = STATE_NORMAL;
|
||||
|
||||
word(params, 6, param3);
|
||||
state = STATE_NORMAL;
|
||||
if (!strcmp(param3, "normal"))
|
||||
state = STATE_NORMAL;
|
||||
else if (!strcmp(param3, "hilited"))
|
||||
state = STATE_HILITED;
|
||||
else if (!strcmp(param3, "clicked"))
|
||||
state = STATE_CLICKED;
|
||||
else if (!strcmp(param3, "disabled"))
|
||||
state = STATE_DISABLED;
|
||||
|
||||
txt = atword(params, 7);
|
||||
if (!txt)
|
||||
if (l == 0)
|
||||
return;
|
||||
|
||||
win = ECreateWinFromXwin(xwin);
|
||||
if (!win)
|
||||
return;
|
||||
|
||||
TextDraw(tc, win, None, 0, 0, state, txt, x, y, 99999, 99999, 17, 0);
|
||||
TextDraw(tc, win, None, 0, 0, st, p, x, y, 99999, 99999, 17, 0);
|
||||
EDestroyWin(win);
|
||||
}
|
||||
else if (!strcmp(param2, "query_size"))
|
||||
{
|
||||
int w, h;
|
||||
const char *txt;
|
||||
|
||||
/* 3-:txt */
|
||||
|
||||
if (l == 0)
|
||||
return;
|
||||
|
||||
w = h = 0;
|
||||
txt = atword(params, 3);
|
||||
if (txt)
|
||||
TextSize(tc, 0, 0, STATE_NORMAL, txt, &w, &h, 17);
|
||||
TextSize(tc, 0, 0, STATE_NORMAL, p, &w, &h, 17);
|
||||
IpcPrintf("%i %i\n", w, h);
|
||||
}
|
||||
else if (!strcmp(param2, "query"))
|
||||
|
|
Loading…
Reference in New Issue