hd_t *hd_read_config(hd_data_t *hd_data, const char *id) { hd_t *hd = NULL; hal_prop_t *prop = NULL; const char *udi = NULL; /* only of we didn't already (check internal db pointer) */ /* prop2hd() makes db lookups */ if(!hd_data->hddb2[1]) hddb_init(hd_data); if(id && *id == '/') { udi = id; id = NULL; } prop = read_properties(hd_data, udi, id); if(prop) { hd = new_mem(sizeof *hd); hd->idx = ++(hd_data->last_idx); hd->module = hd_data->module; hd->line = __LINE__; hd->tag.freeit = 1; /* make it a 'stand alone' entry */ hd->persistent_prop = prop; prop2hd(hd_data, hd, 0); } return hd; }
void authorization::on_pushButton_2_clicked() { read_properties(); db->setUserName(ui->lineEdit->text()); db->setPassword(ui->lineEdit_2->text()); if( db->open() ){ QSqlQuery query (*db); query.prepare ("select count(*) from users where login= :login"); query.bindValue(":login", ui->lineEdit->text()); if ( query.exec()){ query.next(); if (query.value(0).toInt()>0){ this->hide(); }else{ QMessageBox::critical(0, tr("Autorization error"),tr("Autorization failed"), 0,0,0); } }else{ QMessageBox::critical(0, tr("Autorization error"),db->lastError().text(), 0,0,0); } }else{ QMessageBox::critical(0, tr("Autorization error"),db->lastError().text(), 0,0,0); } }
authorization::authorization(QSqlDatabase *kept_db, QColor *d_color, QWidget *parent) : QDialog(parent), ui(new Ui::authorization) { ui->setupUi(this); db=kept_db; dinner_color=d_color; read_properties(); }
static void get_properties(struct wlc_xwm *xwm, struct wlc_x11_window *win) { const xcb_atom_t props[] = { XCB_ATOM_WM_CLASS, XCB_ATOM_WM_NAME, XCB_ATOM_WM_TRANSIENT_FOR, x11.atoms[WM_PROTOCOLS], x11.atoms[WM_NORMAL_HINTS], x11.atoms[NET_WM_STATE], x11.atoms[NET_WM_WINDOW_TYPE], x11.atoms[NET_WM_NAME], x11.atoms[NET_WM_PID], x11.atoms[MOTIF_WM_HINTS] }; read_properties(xwm, win, props, LENGTH(props)); }
int main(int argc, char *argv[]) { char *mainclsname; char *mainclsargs; // Determine configuration if (argc > 1) { cfgname = argv[1]; } else { cfgname = "java"; } if (argc > 2) { cfg = read_properties(argv[2]); if (cfg == NULL) { syslog(LOG_ERR, "Unable to read JVM configuration from %s", argv[2]); return 1; } } else { cfg = osconfig(); } // Initialize Java VM if (init_jvm() != 0) return 1; // Get main class and arguments mainclsname = get_property(cfg, cfgname, "mainclass", "sanos.os.Shell"); mainclsargs = get_property(cfg, cfgname, "mainargs", ""); // Call main method execute_main_method(mainclsname, mainclsargs); // Detach main thread from jvm if ((*vm)->DetachCurrentThread(vm) != 0) { syslog(LOG_ERR, "Could not detach main thread"); return 1; } (*vm)->DestroyJavaVM(vm); return 0; }
void hd_scan_manual2(hd_data_t *hd_data) { hd_t *hd, *hd1; /* add persistent properties */ for(hd = hd_data->hd; hd; hd = hd->next) { if(hd->persistent_prop) continue; hd->persistent_prop = read_properties(hd_data, hd->udi, hd->unique_id); prop2hd(hd_data, hd, 1); if(hd->status.available != status_unknown) hd->status.available = status_yes; } /* check if it's necessary to reconfigure this hardware */ for(hd = hd_data->hd; hd; hd = hd->next) { hd->status.reconfig = status_no; if(hd->status.needed != status_yes) continue; if(hd->status.available == status_no) { hd->status.reconfig = status_yes; continue; } if(hd->status.available != status_unknown) continue; for(hd1 = hd_data->hd; hd1; hd1 = hd1->next) { if(hd1 == hd) continue; if( hd1->hw_class == hd->hw_class && hd1->status.configured == status_new && hd1->status.available == status_yes ) break; } if(hd1) hd->status.reconfig = status_yes; } }
static int remove_package(char *pkgname, struct pkgdb *db, int options) { struct pkg *pkg; struct section *files; // Find package and load manifest pkg = find_package(db, pkgname); if (!pkg) { fprintf(stderr, "%s: package not found\n", pkgname); return 1; } if (pkg->removed) return 0; if (!pkg->manifest) { if (options & VERBOSE) printf("reading manifest from %s\n", pkg->inffile); pkg->manifest = read_properties(pkg->inffile); if (!pkg->manifest) { fprintf(stderr, "%s: unable to read manifest\n", pkg->inffile); return 1; } } // Remove package files files = find_section(pkg->manifest, "files"); if (files) { struct property *p; for (p = files->properties; p; p = p->next) { remove_path(p->name, options); } } // Remove manifest file unlink(pkg->inffile); // Remove package from package database pkg->removed = 1; db->dirty = 1; return 0; }
/* Reads a _triangular_ mesh from a PLY ASCII file. Note that no * binary formats are supported, although PLY format allows * them. Maybe in a further version ... * Only the vertices and faces are read. All other possible properties * (e.g. color ...) are skipped silently. * However, this code should be sufficient to read most common PLY files. * It returns the number of meshes read (i.e. 1) if successful, and a * negative code if it failed. */ int read_ply_tmesh(struct model **tmesh_ref, struct file_data *data) { char stmp[MAX_WORD_LEN+1]; vertex_t bbmin, bbmax; struct model* tmesh; int rcode=1; int is_bin=0; int file_endianness=0, platform_endianness=0, swap_bytes=0; struct ply_prop *vertex_prop=NULL, *face_prop=NULL; int n_vert_prop=0, n_face_prop=0; int c; union sw_uint32 test_byte_order = {{0x01, 0x02, 0x03, 0x04}}; tmesh = (struct model*)calloc(1, sizeof(struct model)); /* read the header */ /* check if the format is ASCII or binary */ if (skip_ws_str_scanf(data, stmp) == 1 && strcmp(stmp, "format") == 0) { if (skip_ws_str_scanf(data, stmp) == 1) { /* check whether we have ASCII or binary stuff */ if (strcmp(stmp, "binary_little_endian") == 0) { is_bin = 1; } else if (strcmp(stmp, "binary_big_endian") == 0) { is_bin = 1; file_endianness = 1; } else if (strcmp(stmp, "ascii") != 0) { rcode = MESH_CORRUPTED; } else { if (skip_ws_str_scanf(data, stmp) != 1 || strcmp(stmp, "1.0") != 0) rcode = MESH_CORRUPTED; } } else { rcode = MESH_CORRUPTED; } } else rcode = MESH_CORRUPTED; if (rcode >= 0) { do { if ((c = find_string(data, "element")) != EOF) { if (skip_ws_str_scanf(data, stmp) == 1) { if (strcmp(stmp, "vertex") == 0) { if ((c = int_scanf(data, &(tmesh->num_vert))) != 1) rcode = MESH_CORRUPTED; else { n_vert_prop = read_properties(data, &vertex_prop); if (n_vert_prop <= 0) rcode = MESH_CORRUPTED; #ifdef DEBUG DEBUG_PRINT("num_vert = %d\n", tmesh->num_vert); #endif } } else if (strcmp(stmp, "face") == 0) { if ((c = int_scanf(data, &(tmesh->num_faces))) != 1) rcode = MESH_CORRUPTED; else { n_face_prop = read_properties(data, &face_prop); if (n_face_prop <= 0) rcode = MESH_CORRUPTED; #ifdef DEBUG DEBUG_PRINT("num_faces = %d\n", tmesh->num_faces); #endif } } else if (strcmp(stmp, "edge") == 0) { fprintf(stderr, "[Warning] 'edge' field not supported !\n"); } else if (strcmp(stmp, "material") == 0) fprintf(stderr, "[Warning] 'material' field not supported !\n"); } else { fprintf(stderr, "[Warning] Unrecognized 'element' field found." " Skipping...\n"); } } else rcode = MESH_CORRUPTED; } while (rcode >= 0 && (tmesh->num_faces == 0 || tmesh->num_vert == 0)); /* Ignore everything else from the header */ if ((c = find_string(data, "end_header")) == EOF) rcode = MESH_CORRUPTED; /* end_header read */ else { tmesh->vertices = (vertex_t*)malloc(tmesh->num_vert*sizeof(vertex_t)); tmesh->faces = (face_t*)malloc(tmesh->num_faces*sizeof(face_t)); if (tmesh->vertices == NULL || tmesh->faces == NULL) rcode = MESH_NO_MEM; else { if (is_bin) { /* check endianness of the platform, just in case ;-) */ if (test_byte_order.bo == TEST_BIG_ENDIAN) platform_endianness = 1; else if (test_byte_order.bo != TEST_LITTLE_ENDIAN) { fprintf(stderr, "Unable to probe for byte ordering\n"); platform_endianness = -1; } swap_bytes = (file_endianness == platform_endianness)?0:1; skip_ws_comm(data); /* find the first relevant byte */ } /* read the vertices */ rcode = read_ply_vertices(tmesh->vertices, data, is_bin, tmesh->num_vert, &bbmin, &bbmax, swap_bytes, vertex_prop, n_vert_prop); /* read the faces */ rcode = read_ply_faces(tmesh->faces, data, is_bin, tmesh->num_faces, tmesh->num_vert, swap_bytes, face_prop, n_face_prop); } } } if (rcode < 0) { /* something went wrong */ if (tmesh->vertices != NULL) free(tmesh->vertices); if (tmesh->faces != NULL) free(tmesh->faces); free(tmesh); } else { tmesh->bBox[0] = bbmin; tmesh->bBox[1] = bbmax; *tmesh_ref = tmesh; rcode = 1; } if (vertex_prop != NULL) free(vertex_prop); if (face_prop != NULL) free(face_prop); return rcode; }
static int install_package(char *pkgname, struct pkgdb *db, int options) { char url[STRLEN]; FILE *f; int rc; char inffile[STRLEN]; struct section *manifest; struct section *dep; struct section *build; struct pkg *pkg; char *description; int time; // Check if package is already installed if (!(options & FROM_FILE)) { pkg = find_package(db, pkgname); if (pkg) { if (options & UPGRADE) { if (pkg->time == pkg->avail) return 0; } else if (options & DEPENDENCY) { return 0; } else if (options & UPDATE) { if (options & VERBOSE) printf("updating package %s\n", pkgname); } else { printf("package %s is already installed\n", pkgname); return 0; } } } // Open package file printf("Fetching %s\n", pkgname); if (options & FROM_FILE) { snprintf(url, sizeof(url), "file:///%s", pkgname); } else { snprintf(url, sizeof(url), "%s/%s.pkg", db->repo, pkgname); } if (options & VERBOSE) printf("fetching package %s from %s\n", pkgname, url); f = open_url(url, "pkg"); if (!f) return 1; // Extract file from package file time = 0; rc = extract_files(url, f, inffile, options & VERBOSE, &time); fclose(f); if (rc != 0) return rc; // Read manifest if (options & VERBOSE) printf("reading manifest from %s\n", inffile); manifest = read_properties(inffile); if (!manifest) { fprintf(stderr, "%s: unable to read manifest\n", inffile); return 1; } // Add package to package database pkgname = get_property(manifest, "package", "name", pkgname); description = get_property(manifest, "package", "description", NULL); pkg = find_package(db, pkgname); if (pkg) { if (options & VERBOSE) printf("updating package %s in database\n", pkgname); if (description) { free(pkg->description); pkg->description = strdup(description); db->dirty = 1; } if (pkg->manifest) free_properties(pkg->manifest); free(pkg->inffile); } else { if (options & VERBOSE) printf("adding package %s to database\n", pkgname); pkg = add_package(db, pkgname, description); } pkg->inffile = strdup(inffile); pkg->manifest = manifest; if (time != pkg->time) { pkg->time = time; db->dirty = 1; } // Install package dependencies dep = find_section(manifest, "dependencies"); if (dep) { struct property *p; for (p = dep->properties; p; p = p->next) { if (options & VERBOSE) printf("package %s depends on %s\n", pkgname, p->name); rc = install_package(p->name, db, options | DEPENDENCY); if (rc != 0) return rc; } } if ((options & ONLY_FETCH) && !(options & DEPENDENCY)) return 0; // Run package build/installation commands if (!(options & ONLY_FETCH) || (options & DEPENDENCY)) { build = find_section(manifest, (options & ONLY_BUILD) && !(options & DEPENDENCY) ? "build" : "install"); if (build) { struct property *p; printf((options & ONLY_BUILD) && !(options & DEPENDENCY) ? "Building %s\n" : "Installing %s\n", pkgname); for (p = build->properties; p; p = p->next) { if (options & VERBOSE) printf("%s\n", p->name); rc = system(p->name); if (rc != 0) { fprintf(stderr, "%s: build failed\n", pkgname); return rc; } } } } return 0; }