*/
#define DO_JUMP { \
DBGP2("jumping"); \
- obj = obj->data.ifblock.next; \
+ obj = obj->sub; \
}
#define OBJ(a) break; case OBJ_##a:
* Do Ninja jump here: without leaving traces.
* This is to prevent us from stale jumped flags.
*/
- obj = obj->data.ifblock.next;
+ obj = obj->sub;
continue;
}
OBJ(endif) {
OBJ(if_existing) {
char *spc;
- spc = strchr(obj->data.ifblock.s, ' ');
- if (!spc && access(obj->data.ifblock.s, F_OK)) {
+ spc = strchr(obj->data.s, ' ');
+ if (!spc && access(obj->data.s, F_OK)) {
DO_JUMP;
} else if (spc) {
*spc = '\0';
- if (check_contains(obj->data.ifblock.s, spc + 1))
+ if (check_contains(obj->data.s, spc + 1))
DO_JUMP;
*spc = ' ';
}
}
OBJ(if_mounted) {
- if ((obj->data.ifblock.s)
- && (!check_mount(obj->data.ifblock.s))) {
+ if ((obj->data.s)
+ && (!check_mount(obj->data.s))) {
DO_JUMP;
}
}
OBJ(if_running) {
#ifdef __linux__
- if (!get_process_by_name(obj->data.ifblock.s)) {
+ if (!get_process_by_name(obj->data.s)) {
#else
- if ((obj->data.ifblock.s) && system(obj->data.ifblock.s)) {
+ if ((obj->data.s) && system(obj->data.s)) {
#endif
DO_JUMP;
}
snprintf(p, p_max_size, "%d", total_updates);
}
OBJ(if_updatenr) {
- if(total_updates % updatereset != obj->data.ifblock.i - 1) {
+ if(total_updates % updatereset != obj->data.i - 1) {
DO_JUMP;
}
}
}
OBJ(if_smapi_bat_installed) {
int idx;
- if(obj->data.ifblock.s && sscanf(obj->data.ifblock.s, "%i", &idx) == 1) {
+ if(obj->data.s && sscanf(obj->data.s, "%i", &idx) == 1) {
if(!smapi_bat_installed(idx)) {
DO_JUMP;
}
obj->sub = malloc(sizeof(struct text_object));
extract_variable_text_internal(obj->sub, arg);
END OBJ_IF_ARG(if_existing, 0, "if_existing needs an argument or two")
- obj->data.ifblock.s = strndup(arg, text_buffer_size);
+ obj->data.s = strndup(arg, text_buffer_size);
END OBJ_IF_ARG(if_mounted, 0, "if_mounted needs an argument")
- obj->data.ifblock.s = strndup(arg, text_buffer_size);
+ obj->data.s = strndup(arg, text_buffer_size);
#ifdef __linux__
END OBJ_IF_ARG(if_running, &update_top, "if_running needs an argument")
top_running = 1;
- obj->data.ifblock.s = strndup(arg, text_buffer_size);
+ obj->data.s = strndup(arg, text_buffer_size);
#else
END OBJ_IF_ARG(if_running, 0, "if_running needs an argument")
char buf[256];
snprintf(buf, 256, "pidof %s >/dev/null", arg);
- obj->data.ifblock.s = strndup(buf, text_buffer_size);
+ obj->data.s = strndup(buf, text_buffer_size);
#endif
END OBJ(kernel, 0)
END OBJ(machine, 0)
parse_net_stat_arg(obj, arg, free_at_crash);
END OBJ(updates, 0)
END OBJ_IF(if_updatenr, 0)
- obj->data.ifblock.i = arg ? atoi(arg) : 0;
- if(obj->data.ifblock.i == 0) CRIT_ERR(obj, free_at_crash, "if_updatenr needs a number above 0 as argument");
- set_updatereset(obj->data.ifblock.i > get_updatereset() ? obj->data.ifblock.i : get_updatereset());
+ obj->data.i = arg ? atoi(arg) : 0;
+ if(obj->data.i == 0) CRIT_ERR(obj, free_at_crash, "if_updatenr needs a number above 0 as argument");
+ set_updatereset(obj->data.i > get_updatereset() ? obj->data.i : get_updatereset());
END OBJ(alignr, 0)
obj->data.i = arg ? atoi(arg) : 0;
END OBJ(alignc, 0)
END OBJ_ARG(smapi, 0, "smapi needs an argument")
obj->data.s = strndup(arg, text_buffer_size);
END OBJ_IF_ARG(if_smapi_bat_installed, 0, "if_smapi_bat_installed needs an argument")
- obj->data.ifblock.s = strndup(arg, text_buffer_size);
+ obj->data.s = strndup(arg, text_buffer_size);
END OBJ_ARG(smapi_bat_perc, 0, "smapi_bat_perc needs an argument")
obj->data.s = strndup(arg, text_buffer_size);
END OBJ_ARG(smapi_bat_temp, 0, "smapi_bat_temp needs an argument")
case OBJ_if_existing:
case OBJ_if_mounted:
case OBJ_if_running:
- free(data.ifblock.s);
+ free(data.s);
break;
case OBJ_head:
case OBJ_tail:
free(data.s);
break;
case OBJ_if_gw:
- free(data.ifblock.s);
+ free(data.s);
case OBJ_gw_iface:
case OBJ_gw_ip:
free_gateway_info();
free(data.s);
break;
case OBJ_if_smapi_bat_installed:
- free(data.ifblock.s);
+ free(data.s);
break;
#endif /* IBM */
#ifdef NVIDIA
case IFBLOCK_ENDIF:
if (!(*ifblock_stack_top))
CRIT_ERR(NULL, NULL, "got an endif without matching if");
- (*ifblock_stack_top)->obj->data.ifblock.next = obj;
+ (*ifblock_stack_top)->obj->sub = obj;
/* if there's some else in between, remove and free it */
if ((*ifblock_stack_top)->type == IFBLOCK_ELSE) {
stackobj = *ifblock_stack_top;
case IFBLOCK_ELSE:
if (!(*ifblock_stack_top))
CRIT_ERR(NULL, NULL, "got an else without matching if");
- (*ifblock_stack_top)->obj->data.ifblock.next = obj;
+ (*ifblock_stack_top)->obj->sub = obj;
/* fall through */
case IFBLOCK_IF:
stackobj = malloc(sizeof(struct ifblock_stack_obj));