You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by mt...@apache.org on 2003/09/04 14:32:31 UTC
cvs commit: jakarta-commons-sandbox/daemon/src/native/nt/procrun procgui.c
mturk 2003/09/04 05:32:31
Modified: daemon/src/native/nt/procrun procgui.c
Log:
Add the 4000 lines limit to ListView (could be defined at compile time).
Fix the log parsing omitting scanf.
Revision Changes Path
1.26 +37 -10 jakarta-commons-sandbox/daemon/src/native/nt/procrun/procgui.c
Index: procgui.c
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/procrun/procgui.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- procgui.c 3 Sep 2003 03:45:09 -0000 1.25
+++ procgui.c 4 Sep 2003 12:32:31 -0000 1.26
@@ -106,6 +106,8 @@
#define PSH_NOCONTEXTHELP 0x02000000
#endif
+#define MAX_LIST_ITEMS 4000 /* maximum items in ListView */
+
extern int g_proc_mode;
/* The main envronment for services */
extern procrun_t *g_env;
@@ -175,8 +177,10 @@
Shell_NotifyIcon(message, &nid);
}
-static char ac_lv_stat[32] = {0};
-static char ac_lv_class[1024] = {0};
+static char *ac_lv_stat = NULL;
+static char ac_lv_clbuf[1024] = {0};
+static char *ac_lv_class = NULL;
+static char *ac_lv_clmsg = NULL;
static int ac_lv_iicon = 0;
static void ac_parse_list_string(const char *str)
@@ -186,12 +190,26 @@
int off = 0;
if (isdigit(*str)) {
- char t[32];
- sscanf(str, "%s %s %s", ac_lv_stat, t, ac_lv_class);
- strcat(ac_lv_stat, " ");
- strcat(ac_lv_stat, t);
- strcpy(ac_lv_class, str + strlen(ac_lv_stat) + strlen(t) + 2);
- str += strlen(ac_lv_stat) + strlen(t) + strlen(ac_lv_class) + 3;
+ char *p;
+
+ strncpy(ac_lv_clbuf, str, 1023);
+ ac_lv_stat = p = &ac_lv_clbuf[0];
+
+ while (*p && !isspace(*p))
+ ++p;
+ ++p;
+ while (*p && !isspace(*p))
+ ++p;
+ *(p++) = 0;
+ while (*p && isspace(*p))
+ ++p;
+ ac_lv_class = p;
+
+ while (*p && !isspace(*p))
+ ++p;
+ *(p++) = 0;
+ ac_lv_clmsg = p;
+
}
else {
if (STRN_COMPARE(str, "INFO:")) {
@@ -210,6 +228,11 @@
ac_lv_iicon = 2;
off = STRN_SIZE("SEVERE:") + 1;
}
+ ac_lv_clmsg = (char *)str + off;
+
+ /* skip leading spaces */
+ while (*ac_lv_clmsg && isspace(*ac_lv_clmsg))
+ ++ac_lv_clmsg;
}
memset(&lvi, 0, sizeof(LV_ITEM));
lvi.mask = LVIF_IMAGE | LVIF_TEXT;
@@ -221,7 +244,7 @@
if (row == -1)
return;
ListView_SetItemText(ac_list_hwnd, row, 1, ac_lv_class);
- ListView_SetItemText(ac_list_hwnd, row, 2, (char *)(str + off));
+ ListView_SetItemText(ac_list_hwnd, row, 2, ac_lv_clmsg);
ListView_EnsureVisible(ac_list_hwnd,
ListView_GetItemCount(ac_list_hwnd) - 1,
FALSE);
@@ -233,6 +256,7 @@
{
static int nqueue = 0;
static int nlen = 0, olen = 0;
+ static int litems = 0;
int i;
if (str) {
@@ -264,8 +288,11 @@
return;
if (ac_use_lview) {
- for (i = 0; i < nqueue; i++)
+ for (i = 0; i < nqueue; i++) {
ac_parse_list_string(ac_stdout_lines[i]);
+ if (litems++ > MAX_LIST_ITEMS)
+ ListView_DeleteItem(ac_list_hwnd, 0);
+ }
}
else {
for (i = 0; i < nqueue; i++)