void bat_utils_init(void) { int t; for (t=1; t<GDKatomcnt; t++) { if (t != TYPE_bat && BATatoms[t].name[0]) { eubats[t] = bat_new(TYPE_oid, t, 0); ebats[t] = bat_new(TYPE_void, t, 0); bat_set_access(eubats[t], BAT_READ); bat_set_access(ebats[t], BAT_READ); } } }
log_bid ebat_copy(log_bid b, oid ibase, int temp) { /* make a copy of b */ BAT *o = temp_descriptor(b); BAT *c; log_bid r; if (!ebats[o->ttype]) ebats[o->ttype] = bat_new(TYPE_void, o->ttype, 0); if (!temp && BATcount(o)) { c = BATcopy(o, TYPE_void, o->ttype, TRUE); BATseqbase(c, ibase ); c->H->dense = 1; BATcommit(o); BATcommit(c); bat_set_access(c, BAT_READ); r = temp_create(c); bat_destroy(c); } else { c = ebats[o->ttype]; r = temp_create(c); } bat_destroy(o); return r; }
log_bid e_ubat(int type) { if (!eubats[type]) eubats[type] = bat_new(TYPE_oid, type, 0); return temp_create(eubats[type]); }
BAT * e_BAT(int type) { if (!ebats[type]) ebats[type] = bat_new(TYPE_void, type, 0); return temp_descriptor(ebats[type]->batCacheid); }
log_bid e_bat(int type) { if (!ebats[type]) ebats[type] = bat_new(TYPE_void, type, 0, TRANSIENT); return temp_create(ebats[type]); }
/* Parses power supplies on the current system. */ extern power_supply* power_supply_parse(power_supply* ps) { GDir* dir = NULL; const gchar* tmp; GString* filename = g_string_sized_new(STRING_LEN); guint len = 0; gchar* contents; if (g_file_test(SYS_ACPI_PATH, G_FILE_TEST_IS_DIR)) { dir = g_dir_open(SYS_ACPI_PATH, 0, NULL); if (dir != NULL) { while ((tmp = g_dir_read_name(dir)) != NULL) { g_string_append(filename, SYS_ACPI_PATH); g_string_append(filename, tmp); g_string_append_c(filename, G_DIR_SEPARATOR); len = filename->len; g_string_append(filename, SYS_ACPI_TYPE_FILE); if (g_file_test(filename->str, G_FILE_TEST_IS_REGULAR)) { g_file_get_contents(filename->str, &contents, 0, NULL); g_string_truncate(filename, len); g_string_append(filename, SYS_ACPI_UEVENT_FILE); if (strcmp(SYS_ACPI_TYPE_AC, contents) == 0) { ac* tmp = ac_new(g_strdup(filename->str)); ac_parse(tmp); g_sequence_append(ps->ac_list, tmp); } else if (strcmp(SYS_ACPI_TYPE_BAT, contents) == 0) { bat* tmp = bat_new(g_strdup(filename->str)); bat_parse(tmp); g_sequence_append(ps->bat_list, tmp); } else { g_fprintf(stderr, "unsupported power supply type %s", contents); } g_free(contents); } g_string_truncate(filename, 0); } g_dir_close(dir); } } g_string_free(filename, TRUE); if (DEBUG) { g_sequence_foreach(ps->ac_list, &ac_print, NULL); g_sequence_foreach(ps->bat_list, &bat_print, NULL); } return ps; }
log_bid temp_copy(log_bid b, int temp) { /* make a copy of b, if temp is set only create a empty bat */ BAT *o = temp_descriptor(b); BAT *c; log_bid r; if (!temp) { c = BATcopy(o, o->htype, o->ttype, TRUE); bat_set_access(c, BAT_READ); BATcommit(c); } else { c = bat_new(o->htype, o->ttype, COLSIZE); } r = temp_create(c); bat_destroy(c); bat_destroy(o); return r; }
log_bid eubat_copy(log_bid b, int temp) { /* make a copy of b */ BAT *o = temp_descriptor(b); BAT *c; log_bid r; if (!eubats[o->ttype]) eubats[o->ttype] = bat_new(TYPE_oid, o->ttype, 0, TRANSIENT); if (!temp && BATcount(o)) { c = BATcopy(o, TYPE_oid, o->ttype, TRUE, PERSISTENT); BATcommit(c); r = temp_create(c); bat_set_access(c, BAT_READ); bat_destroy(c); } else { c = eubats[o->ttype]; r = temp_create(c); } bat_destroy(o); return r; }