+
+void print_smapi(struct text_object *obj, char *p, int p_max_size)
+{
+ char *s;
+
+ if (!obj->data.s)
+ return;
+
+ s = smapi_get_val(obj->data.s);
+ snprintf(p, p_max_size, "%s", s);
+ free(s);
+}
+
+void print_smapi_bat_perc(struct text_object *obj, char *p, int p_max_size)
+{
+ int idx, val;
+ if (obj->data.s && sscanf(obj->data.s, "%i", &idx) == 1) {
+ val = smapi_bat_installed(idx) ?
+ smapi_get_bat_int(idx, "remaining_percent") : 0;
+ percent_print(p, p_max_size, val);
+ } else
+ NORM_ERR("argument to smapi_bat_perc must be an integer");
+}
+
+void print_smapi_bat_temp(struct text_object *obj, char *p, int p_max_size)
+{
+ int idx, val;
+ if (obj->data.s && sscanf(obj->data.s, "%i", &idx) == 1) {
+ val = smapi_bat_installed(idx) ?
+ smapi_get_bat_int(idx, "temperature") : 0;
+ /* temperature is in milli degree celsius */
+ temp_print(p, p_max_size, val / 1000, TEMP_CELSIUS);
+ } else
+ NORM_ERR("argument to smapi_bat_temp must be an integer");
+}
+
+void print_smapi_bat_power(struct text_object *obj, char *p, int p_max_size)
+{
+ int idx, val;
+ if (obj->data.s && sscanf(obj->data.s, "%i", &idx) == 1) {
+ val = smapi_bat_installed(idx) ?
+ smapi_get_bat_int(idx, "power_now") : 0;
+ /* power_now is in mW, set to W with one digit precision */
+ snprintf(p, p_max_size, "%.1f", ((double)val / 1000));
+ } else
+ NORM_ERR("argument to smapi_bat_power must be an integer");
+}
+
+void print_smapi_bat_bar(struct text_object *obj, char *p, int p_max_size)
+{
+ if (!p_max_size)
+ return;
+
+ if (obj->data.i >= 0 && smapi_bat_installed(obj->data.i))
+ new_bar(obj, p, p_max_size, (int)
+ (255 * smapi_get_bat_int(obj->data.i, "remaining_percent") / 100));
+ else
+ new_bar(obj, p, p_max_size, 0);
+}