static void _extract_series(FILE* fp, int stepx, bool header, hid_t gid_level, char* node_name, char* data_set_name) { hid_t gid_series; int size_data; void *data; uint32_t type; char *data_type, *subtype; hdf5_api_ops_t* ops; gid_series = get_group(gid_level, data_set_name); if (gid_series < 0) { // This is okay, may not have ran long enough for // a sample (hostname????) // OR trying to get all tasks return; } data_type = get_string_attribute(gid_series, ATTR_DATATYPE); if (!data_type) { H5Gclose(gid_series); info("No datatype in %s", data_set_name); return; } type = acct_gather_profile_type_from_string(data_type); xfree(data_type); subtype = get_string_attribute(gid_series, ATTR_SUBDATATYPE); if (subtype == NULL) { H5Gclose(gid_series); info("No %s attribute", ATTR_SUBDATATYPE); return; } ops = profile_factory(type); if (ops == NULL) { xfree(subtype); H5Gclose(gid_series); info("Failed to create operations for %s", acct_gather_profile_type_to_string(type)); return; } data = get_hdf5_data( gid_series, type, data_set_name, &size_data); if (data) { if (strcmp(subtype,SUBDATA_SUMMARY) != 0) (*(ops->extract_series)) (fp, header, params.job_id, stepx, node_name, data_set_name, data, size_data); else (*(ops->extract_total)) (fp, header, params.job_id, stepx, node_name, data_set_name, data, size_data); xfree(data); } else { fprintf(fp, "%d,%d,%s,No %s Data\n", params.job_id, stepx, node_name, data_set_name); } xfree(ops); H5Gclose(gid_series); }
/* PUBLIC */ void adjust_weight_with_hints(Topform c, BOOL degrade, BOOL breadth_first_hints) { Topform hint = find_matching_hint(c, Hints_idx); if (hint == NULL && unit_clause(c->literals) && eq_term(c->literals->atom) && !oriented_eq(c->literals->atom)) { /* Try to find a hint that matches the flipped equality. */ Term save_atom = c->literals->atom; c->literals->atom = top_flip(save_atom); hint = find_matching_hint(c, Hints_idx); zap_top_flip(c->literals->atom); c->literals->atom = save_atom; if (hint != NULL) c->attributes = set_string_attribute(c->attributes, label_att(), "flip_matches_hint"); } if (hint != NULL) { int bsub_wt = get_int_attribute(hint->attributes, Bsub_wt_attr, 1); if (bsub_wt != INT_MAX) c->weight = bsub_wt; else if (breadth_first_hints) c->weight = 0; /* If the hint has label attributes, copy them to the clause. */ { int i = 0; char *s = get_string_attribute(hint->attributes, label_att(), ++i); while (s) { if (!string_attribute_member(c->attributes, label_att(), s)) c->attributes = set_string_attribute(c->attributes, label_att(), s); s = get_string_attribute(hint->attributes, label_att(), ++i); } } /* Veroff's hint degradation strategy. */ if (degrade) { /* for now, add 1000 for each previous match */ int i; for (i = 0; i < hint->weight; i++) c->weight = c->weight + 1000; } c->matching_hint = hint; /* If/when c is eventually kept, the hint will have its weight field incremented in case hint degradation is being used. */ } } /* adjust_weight_with_hints */
static gboolean on_connect_server_info_completed (LDAPMessage *result, gpointer user_data) { GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data); source_connect_closure *closure = g_simple_async_result_get_op_res_gpointer (res); SeahorseLDAPSource *self = SEAHORSE_LDAP_SOURCE (g_async_result_get_source_object (user_data)); LDAPServerInfo *sinfo; char *message; int code; int type; int rc; type = ldap_msgtype (result); g_return_val_if_fail (type == LDAP_RES_SEARCH_ENTRY || type == LDAP_RES_SEARCH_RESULT, FALSE); /* If we have results then fill in the server info */ if (type == LDAP_RES_SEARCH_ENTRY) { g_debug ("Server Info Result"); #ifdef WITH_DEBUG dump_ldap_entry (closure->ldap, result); #endif /* NOTE: When adding attributes here make sure to add them to kServerAttributes */ sinfo = g_new0 (LDAPServerInfo, 1); sinfo->version = get_int_attribute (closure->ldap, result, "version"); sinfo->base_dn = get_string_attribute (closure->ldap, result, "basekeyspacedn"); if (!sinfo->base_dn) sinfo->base_dn = get_string_attribute (closure->ldap, result, "pgpbasekeyspacedn"); sinfo->key_attr = g_strdup (sinfo->version > 1 ? "pgpkeyv2" : "pgpkey"); set_ldap_server_info (self, sinfo); return TRUE; /* callback again */ } else { rc = ldap_parse_result (closure->ldap, result, &code, NULL, &message, NULL, NULL, 0); g_return_val_if_fail (rc == LDAP_SUCCESS, FALSE); if (code != LDAP_SUCCESS) g_warning ("operation to get LDAP server info failed: %s", message); ldap_memfree (message); g_simple_async_result_complete_in_idle (res); seahorse_progress_end (closure->cancellable, res); return FALSE; /* don't callback again */ } }
// Get the data_set for a node static void *_get_series_data(hid_t jgid_node, char* series, hdf5_api_ops_t **ops_p, int *nsmp) { hid_t gid_level, gid_series; int size_data; void *data; uint32_t type; char *data_type; hdf5_api_ops_t* ops; *nsmp = 0; // Initialize return arguments. *ops_p = NULL; // Navigate from the node group to the data set gid_level = get_group(jgid_node, GRP_SAMPLES); if (gid_level == -1) { return NULL; } gid_series = get_group(gid_level, series); if (gid_series < 0) { // This is okay, may not have ran long enough for // a sample (srun hostname) H5Gclose(gid_level); return NULL; } data_type = get_string_attribute(gid_series, ATTR_DATATYPE); if (!data_type) { H5Gclose(gid_series); H5Gclose(gid_level); debug("No datatype in %s", series); return NULL; } // Invoke the data type operator to get the data set type = acct_gather_profile_type_from_string(data_type); xfree(data_type); ops = profile_factory(type); if (ops == NULL) { H5Gclose(gid_series); H5Gclose(gid_level); debug("Failed to create operations for %s", acct_gather_profile_type_to_string(type)); return NULL; } data = get_hdf5_data(gid_series, type, series, &size_data); if (data) { *nsmp = (size_data / ops->dataset_size()); *ops_p = ops; } else { xfree(ops); } H5Gclose(gid_series); H5Gclose(gid_level); return data; }
static void _extract_all_tasks(FILE *fp, hid_t gid_step, hid_t gid_nodes, int nnodes, int stepx) { hid_t gid_tasks, gid_task = 0, gid_node = -1, gid_level = -1; H5G_info_t group_info; int ntasks, itx, len, task_id; char task_name[MAX_GROUP_NAME+1]; char* node_name; char buf[MAX_GROUP_NAME+1]; bool hd = true; gid_tasks = get_group(gid_step, GRP_TASKS); if (gid_tasks < 0) fatal("No tasks in step %d", stepx); H5Gget_info(gid_tasks, &group_info); ntasks = (int) group_info.nlinks; if (ntasks <= 0) fatal("No tasks in step %d", stepx); for (itx = 0; itx<ntasks; itx++) { // Get the name of the group. len = H5Lget_name_by_idx(gid_tasks, ".", H5_INDEX_NAME, H5_ITER_INC, itx, buf, MAX_GROUP_NAME, H5P_DEFAULT); if ((len > 0) && (len < MAX_GROUP_NAME)) { gid_task = H5Gopen(gid_tasks, buf, H5P_DEFAULT); if (gid_task < 0) fatal("Failed to open %s", buf); } else fatal("Illegal task name %s",buf); task_id = get_int_attribute(gid_task, ATTR_TASKID); node_name = get_string_attribute(gid_task, ATTR_NODENAME); sprintf(task_name,"%s_%d", GRP_TASK, task_id); gid_node = H5Gopen(gid_nodes, node_name, H5P_DEFAULT); if (gid_node < 0) fatal("Failed to open %s for Task_%d", node_name, task_id); gid_level = get_group(gid_node, GRP_SAMPLES); if (gid_level < 0) fatal("Failed to open group %s for node=%s task=%d", GRP_SAMPLES,node_name, task_id); _extract_series(fp, stepx, hd, gid_level, node_name, task_name); hd = false; xfree(node_name); H5Gclose(gid_level); H5Gclose(gid_node); H5Gclose(gid_task); } H5Gclose(gid_tasks); }
static void _merge_node_step_data(hid_t fid_job, char* file_name, int nodeIndex, char* node_name, hid_t jgid_nodes, hid_t jgid_tasks) { hid_t fid_nodestep, jgid_node, nsgid_root, nsgid_node; char *start_time; char group_name[MAX_GROUP_NAME+1]; jgid_node = H5Gcreate(jgid_nodes, node_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (jgid_node < 0) { error("Failed to create group %s",node_name); return; } put_string_attribute(jgid_node, ATTR_NODENAME, node_name); // Process node step file // Open the file and the node group. fid_nodestep = H5Fopen(file_name, H5F_ACC_RDONLY, H5P_DEFAULT); if (fid_nodestep < 0) { H5Gclose(jgid_node); error("Failed to open %s",file_name); return; } nsgid_root = H5Gopen(fid_nodestep,"/", H5P_DEFAULT); sprintf(group_name, "/%s_%s", GRP_NODE, node_name); nsgid_node = H5Gopen(nsgid_root, group_name, H5P_DEFAULT); if (nsgid_node < 0) { H5Gclose(fid_nodestep); H5Gclose(jgid_node); error("Failed to open node group"); return;; } start_time = get_string_attribute(nsgid_node,ATTR_STARTTIME); if (start_time == NULL) { info("No %s attribute", ATTR_STARTTIME); } else { put_string_attribute(jgid_node, ATTR_STARTTIME, start_time); xfree(start_time); } _merge_node_totals(jgid_node, nsgid_node); _merge_task_totals(jgid_tasks, nsgid_node, node_name); _merge_series_data(jgid_tasks, jgid_node, nsgid_node); H5Gclose(nsgid_node); H5Fclose(fid_nodestep); H5Gclose(jgid_node); if (!params.keepfiles) remove(file_name); return; }
// Search for TIFF tag 'tagid' having type 'tifftype', and if found, // add it in the obvious way to m_spec under the name 'oiioname'. void find_tag (int tifftag, TIFFDataType tifftype, const char *oiioname) { #ifdef TIFF_VERSION_BIG const TIFFField *info = TIFFFindField (m_tif, tifftag, tifftype); #else const TIFFFieldInfo *info = TIFFFindFieldInfo (m_tif, tifftag, tifftype); #endif if (! info) { // Something has gone wrong, libtiff doesn't think the field type // is the same as we do. return; } if (tifftype == TIFF_ASCII) get_string_attribute (oiioname, tifftag); else if (tifftype == TIFF_SHORT) get_short_attribute (oiioname, tifftag); else if (tifftype == TIFF_LONG) get_int_attribute (oiioname, tifftag); else if (tifftype == TIFF_RATIONAL || tifftype == TIFF_SRATIONAL || tifftype == TIFF_FLOAT || tifftype == TIFF_DOUBLE) get_float_attribute (oiioname, tifftag); }
static void _extract_node_level(FILE* fp, int stepx, hid_t jgid_nodes, int nnodes, bool header, char* data_set_name) { hid_t jgid_node, gid_level, gid_series; int nodex, len, size_data; void *data; uint32_t type; char *data_type, *subtype; char jgrp_node_name[MAX_GROUP_NAME+1]; hdf5_api_ops_t* ops; for (nodex=0; nodex<nnodes; nodex++) { len = H5Lget_name_by_idx(jgid_nodes, ".", H5_INDEX_NAME, H5_ITER_INC, nodex, jgrp_node_name, MAX_GROUP_NAME, H5P_DEFAULT); if ((len < 0) || (len > MAX_GROUP_NAME)) { info("Invalid node name=%s", jgrp_node_name); continue; } jgid_node = get_group(jgid_nodes, jgrp_node_name); if (jgid_node < 0) { info("Failed to open group %s", jgrp_node_name); continue; } if (params.node && strcmp(params.node, "*") && strcmp(params.node, jgrp_node_name)) continue; gid_level = _get_series_parent(jgid_node); if (gid_level == -1) { H5Gclose(jgid_node); continue; } gid_series = get_group(gid_level, data_set_name); if (gid_series < 0) { // This is okay, may not have ran long enough for // a sample (hostname????) H5Gclose(gid_level); H5Gclose(jgid_node); continue; } data_type = get_string_attribute(gid_series, ATTR_DATATYPE); if (!data_type) { H5Gclose(gid_series); H5Gclose(gid_level); H5Gclose(jgid_node); info("No datatype in %s", data_set_name); continue; } type = acct_gather_profile_type_from_string(data_type); xfree(data_type); subtype = get_string_attribute(gid_series, ATTR_SUBDATATYPE); if (subtype == NULL) { H5Gclose(gid_series); H5Gclose(gid_level); H5Gclose(jgid_node); info("No %s attribute", ATTR_SUBDATATYPE); continue; } ops = profile_factory(type); if (ops == NULL) { xfree(subtype); H5Gclose(gid_series); H5Gclose(gid_level); H5Gclose(jgid_node); info("Failed to create operations for %s", acct_gather_profile_type_to_string(type)); continue; } data = get_hdf5_data( gid_series, type, data_set_name, &size_data); if (data) { if (strcmp(subtype,SUBDATA_SUMMARY) != 0) (*(ops->extract_series)) (fp, header, params.job_id, stepx, jgrp_node_name, data_set_name, data, size_data); else (*(ops->extract_total)) (fp, header, params.job_id, stepx, jgrp_node_name, data_set_name, data, size_data); header = false; xfree(data); } else { fprintf(fp, "%d,%d,%s,No %s Data\n", params.job_id, stepx, jgrp_node_name, data_set_name); } xfree(ops); H5Gclose(gid_series); H5Gclose(gid_level); H5Gclose(jgid_node); } }
static void _merge_series_data(hid_t jgid_tasks, hid_t jg_node, hid_t nsg_node) { hid_t jg_samples, nsg_samples; hid_t g_series, g_series_total = -1; hsize_t num_samples, n_series; int idsx, len; void *data = NULL, *series_total = NULL; uint32_t type; char *data_type; char nam_series[MAX_GROUP_NAME+1]; hdf5_api_ops_t* ops = NULL; H5G_info_t group_info; H5O_info_t object_info; if (jg_node < 0) { info("Job Node is not HDF5 object"); return; } if (nsg_node < 0) { info("Node-Step is not HDF5 object"); return; } jg_samples = H5Gcreate(jg_node, GRP_SAMPLES, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (jg_samples < 0) { info("Failed to create job node Samples"); return; } nsg_samples = get_group(nsg_node, GRP_SAMPLES); if (nsg_samples < 0) { H5Gclose(jg_samples); debug("Failed to get node-step Samples"); return; } H5Gget_info(nsg_samples, &group_info); n_series = group_info.nlinks; if (n_series < 1) { // No series? H5Gclose(jg_samples); H5Gclose(nsg_samples); info("No Samples"); return; } for (idsx = 0; idsx < n_series; idsx++) { H5Oget_info_by_idx(nsg_samples, ".", H5_INDEX_NAME, H5_ITER_INC, idsx, &object_info, H5P_DEFAULT); if (object_info.type != H5O_TYPE_GROUP) continue; len = H5Lget_name_by_idx(nsg_samples, ".", H5_INDEX_NAME, H5_ITER_INC, idsx, nam_series, MAX_GROUP_NAME, H5P_DEFAULT); if (len<1 || len>MAX_GROUP_NAME) { info("Invalid group name %s", nam_series); continue; } g_series = H5Gopen(nsg_samples, nam_series, H5P_DEFAULT); if (g_series < 0) { info("Failed to open %s", nam_series); continue; } H5Gget_info(g_series, &group_info); num_samples = group_info.nlinks; if (num_samples <= 0) { H5Gclose(g_series); info("_series %s has no samples", nam_series); continue; } // Get first sample in series to find out how big the data is. data_type = get_string_attribute(g_series, ATTR_DATATYPE); if (!data_type) { H5Gclose(g_series); info("Failed to get datatype for Time Series Dataset"); continue; } type = acct_gather_profile_type_from_string(data_type); xfree(data_type); data = _get_all_samples(g_series, nam_series, type, num_samples); if (data == NULL) { H5Gclose(g_series); info("Failed to get memory for Time Series Dataset"); continue; } put_hdf5_data(jg_samples, type, SUBDATA_SERIES, nam_series, data, num_samples); ops = profile_factory(type); if (ops == NULL) { xfree(data); H5Gclose(g_series); info("Failed to create operations for %s", acct_gather_profile_type_to_string(type)); continue; } series_total = (*(ops->series_total))(num_samples, data); if (series_total != NULL) { // Totals for series attaches to node g_series_total = make_group(jg_node, GRP_TOTALS); if (g_series_total < 0) { H5Gclose(g_series); xfree(series_total); xfree(data); xfree(ops); info("Failed to make Totals for Node"); continue; } put_hdf5_data(g_series_total, type, SUBDATA_SUMMARY, nam_series, series_total, 1); H5Gclose(g_series_total); } xfree(series_total); xfree(ops); xfree(data); H5Gclose(g_series); } return; }
static void _get_all_task_series(FILE *fp, bool hd, hid_t jgid_step, int stepx) { hid_t jgid_tasks, jgid_task = 0, jgid_nodes, jgid_node; H5G_info_t group_info; int ntasks,itx, tid; uint64_t *task_id; char **task_node_name; /* Node Name for each task */ char **tod = NULL; /* Date time at each sample */ char **series_name; /* Node Names */ double **all_series; /* Pointers to all sampled for each node */ double *et = NULL; /* Elapsed time at each sample */ uint64_t *series_smp; /* Number of samples in this series */ int nnodes, ndx, len, nsmp = 0, nitem = -1; char jgrp_node_name[MAX_GROUP_NAME+1]; char jgrp_task_name[MAX_GROUP_NAME+1]; char buf[MAX_GROUP_NAME+1]; void* series_data = NULL; hdf5_api_ops_t* ops; jgid_nodes = get_group(jgid_step, GRP_NODES); if (jgid_nodes < 0) fatal("Failed to open group %s", GRP_NODES); jgid_tasks = get_group(jgid_step, GRP_TASKS); if (jgid_tasks < 0) fatal("No tasks in step %d", stepx); H5Gget_info(jgid_tasks, &group_info); ntasks = (int) group_info.nlinks; if (ntasks <= 0) fatal("No tasks in step %d", stepx); task_id = xmalloc(ntasks*sizeof(uint64_t)); if (task_id == NULL) fatal("Failed to get memory for task_ids"); task_node_name = xmalloc(ntasks*sizeof(char*)); if (task_node_name == NULL) fatal("Failed to get memory for task_node_names"); for (itx = 0; itx<ntasks; itx++) { // Get the name of the group. len = H5Lget_name_by_idx(jgid_tasks, ".", H5_INDEX_NAME, H5_ITER_INC, itx, buf, MAX_GROUP_NAME, H5P_DEFAULT); if ((len > 0) && (len < MAX_GROUP_NAME)) { jgid_task = H5Gopen(jgid_tasks, buf, H5P_DEFAULT); if (jgid_task < 0) fatal("Failed to open %s", buf); } else fatal("Illegal task name %s",buf); task_id[itx] = get_int_attribute(jgid_task, ATTR_TASKID); task_node_name[itx] = get_string_attribute(jgid_task, ATTR_NODENAME); H5Gclose(jgid_task); } H5Gclose(jgid_tasks); nnodes = get_int_attribute(jgid_step, ATTR_NNODES); // allocate node arrays series_smp = (uint64_t*) xmalloc(ntasks*(sizeof(uint64_t))); if (series_smp == NULL) { fatal("Failed to get memory for node_samples"); return; /* Fix for CLANG false positive */ } series_name = (char**) xmalloc(ntasks*(sizeof(char*))); if (series_name == NULL) { fatal("Failed to get memory for series_name"); return; /* Fix for CLANG false positive */ } all_series = (double**) xmalloc(ntasks*(sizeof(double*))); if (all_series == NULL) { fatal("Failed to get memory for all_series"); return; /* Fix for CLANG false positive */ } for (ndx=0; ndx<nnodes; ndx++) { len = H5Lget_name_by_idx(jgid_nodes, ".", H5_INDEX_NAME, H5_ITER_INC, ndx, jgrp_node_name, MAX_GROUP_NAME, H5P_DEFAULT); if ((len < 0) || (len > MAX_GROUP_NAME)) fatal("Invalid node name=%s", jgrp_node_name); jgid_node = get_group(jgid_nodes, jgrp_node_name); if (jgid_node < 0) fatal("Failed to open group %s", jgrp_node_name); for (itx = 0; itx<ntasks; itx++) { if (strcmp(jgrp_node_name, task_node_name[itx]) != 0) continue; tid = task_id[itx]; series_name[itx] = xstrdup_printf("%s_%d %s", GRP_TASK,tid,jgrp_node_name); sprintf(jgrp_task_name,"%s_%d",GRP_TASK, tid); ops = NULL; nitem = 0; series_data = _get_series_data(jgid_node, jgrp_task_name, &ops, &nitem); if (series_data==NULL || nitem==0 || ops==NULL) { if (ops != NULL) xfree(ops); continue; } all_series[itx] = ops->get_series_values( params.data_item, series_data, nitem); if (!all_series[ndx]) fatal("No data item %s",params.data_item); series_smp[itx] = nitem; if (nsmp == 0) { nsmp = nitem; tod = ops->get_series_tod(series_data, nitem); et = ops->get_series_values("time", series_data, nitem); } else { if (nitem > nsmp) { // new largest number of samples _delete_string_list(tod, nsmp); xfree(et); nsmp = nitem; tod = ops->get_series_tod(series_data, nitem); et = ops->get_series_values("time", series_data, nitem); } } xfree(ops); xfree(series_data); } H5Gclose(jgid_node); } if (nsmp == 0) { // May be bad series name info("No values %s for series %s found in step %d", params.data_item,params.series, stepx); } else { _series_analysis(fp, hd, stepx, ntasks, nsmp, series_name, tod, et, all_series, series_smp); } for (itx=0; itx<ntasks; itx++) { xfree(all_series[itx]); } xfree(series_name); xfree(all_series); xfree(series_smp); _delete_string_list(tod, nsmp); xfree(et); _delete_string_list(task_node_name, ntasks); xfree(task_id); H5Gclose(jgid_nodes); }
//compute MStatus Ocio_log_convert::compute(const MPlug &plug, MDataBlock &data) { //wrong plug requested //----------------------------------------------- //----------------------------------------------- if ((plug != a_output_color) && (plug.parent() != a_output_color)) { return MStatus::kUnknownParameter; } //right plug requested //----------------------------------------------- //----------------------------------------------- //Get attributes //----------------------------------------------- //env_or_file int env_or_file = data.inputValue(a_env_or_file).asInt(); //last_env_or_file int last_env_or_file = data.inputValue(a_last_env_or_file).asInt(); //config_file_path std::string config_file_path = get_string_attribute(std::string("config_file_path")); //last_config_file_path std::string last_config_file_path = get_string_attribute(std::string("last_config_file_path")); //operation int operation = data.inputValue(a_operation).asInt(); //last_operation int last_operation = data.inputValue(a_last_operation).asInt(); //Set processor //----------------------------------------------- //first_execution if (first_execution) set_processor(env_or_file, config_file_path, operation); //env_or_file else if (env_or_file != last_env_or_file) set_processor(env_or_file, config_file_path, operation); //config_file_path else if (config_file_path.compare(last_config_file_path) != 0) set_processor(env_or_file, config_file_path, operation); //operation else if (operation != last_operation) set_processor(env_or_file, config_file_path, operation); //Color conversion //----------------------------------------------- //vec_input_color MDataHandle h_input_color = data.inputValue(a_input_color); MFloatVector& vec_input_color = h_input_color.asFloatVector(); //transform_color if (processor) color_transform(vec_input_color); //set output color set_output_color(vec_input_color, data); //Set attributes //----------------------------------------------- //last_env_or_file set_int_attribute("last_env_or_file", env_or_file); //last_config_file_path set_string_attribute("last_config_file_path", config_file_path); //last_operation set_int_attribute("last_operation", operation); //set first execution to false first_execution = false; //return success return MStatus::kSuccess; }
/* Add a key to the key source from an LDAP entry */ static void search_parse_key_from_ldap_entry (SeahorseLDAPSource *self, GcrSimpleCollection *results, LDAP *ldap, LDAPMessage *res) { const gchar *algo; long int timestamp; long int expires; gchar *fpr, *fingerprint; gchar *uidstr; gboolean revoked; gboolean disabled; int length; g_return_if_fail (ldap_msgtype (res) == LDAP_RES_SEARCH_ENTRY); fpr = get_string_attribute (ldap, res, "pgpcertid"); uidstr = get_string_attribute (ldap, res, "pgpuserid"); revoked = get_boolean_attribute (ldap, res, "pgprevoked"); disabled = get_boolean_attribute (ldap, res, "pgpdisabled"); timestamp = get_date_attribute (ldap, res, "pgpkeycreatetime"); expires = get_date_attribute (ldap, res, "pgpkeyexpiretime"); algo = get_algo_attribute (ldap, res, "pgpkeytype"); length = get_int_attribute (ldap, res, "pgpkeysize"); if (fpr && uidstr) { SeahorsePgpSubkey *subkey; SeahorsePgpKey *key; SeahorsePgpUid *uid; GList *list; guint flags; /* Build up a subkey */ subkey = seahorse_pgp_subkey_new (); seahorse_pgp_subkey_set_keyid (subkey, fpr); fingerprint = seahorse_pgp_subkey_calc_fingerprint (fpr); seahorse_pgp_subkey_set_fingerprint (subkey, fingerprint); g_free (fingerprint); seahorse_pgp_subkey_set_created (subkey, timestamp); seahorse_pgp_subkey_set_expires (subkey, expires); seahorse_pgp_subkey_set_algorithm (subkey, algo); seahorse_pgp_subkey_set_length (subkey, length); flags = SEAHORSE_FLAG_EXPORTABLE; if (revoked) flags |= SEAHORSE_FLAG_REVOKED; if (disabled) flags |= SEAHORSE_FLAG_DISABLED; seahorse_pgp_subkey_set_flags (subkey, flags); key = seahorse_pgp_key_new (); /* Build up a uid */ uid = seahorse_pgp_uid_new (key, uidstr); if (revoked) seahorse_pgp_uid_set_validity (uid, SEAHORSE_VALIDITY_REVOKED); /* Now build them into a key */ list = g_list_prepend (NULL, uid); seahorse_pgp_key_set_uids (key, list); seahorse_object_list_free (list); list = g_list_prepend (NULL, subkey); seahorse_pgp_key_set_subkeys (key, list); seahorse_object_list_free (list); g_object_set (key, "object-flags", flags, "place", self, NULL); seahorse_pgp_key_realize (key); gcr_simple_collection_add (results, G_OBJECT (key)); g_object_unref (key); } g_free (fpr); g_free (uidstr); }
static gboolean on_export_search_completed (LDAPMessage *result, gpointer user_data) { GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data); ExportClosure *closure = g_simple_async_result_get_op_res_gpointer (res); SeahorseLDAPSource *self = SEAHORSE_LDAP_SOURCE (g_async_result_get_source_object (G_ASYNC_RESULT (res))); LDAPServerInfo *sinfo; char *message; GError *error = NULL; gchar *key; int code; int type; int rc; type = ldap_msgtype (result); g_return_val_if_fail (type == LDAP_RES_SEARCH_ENTRY || type == LDAP_RES_SEARCH_RESULT, FALSE); sinfo = get_ldap_server_info (self, TRUE); /* An LDAP Entry */ if (type == LDAP_RES_SEARCH_ENTRY) { g_debug ("Server Info Result"); #ifdef WITH_DEBUG dump_ldap_entry (closure->ldap, result); #endif key = get_string_attribute (closure->ldap, result, sinfo->key_attr); if (key == NULL) { g_warning ("key server missing pgp key data"); seahorse_ldap_source_propagate_error (self, LDAP_NO_SUCH_OBJECT, &error); g_simple_async_result_take_error (res, error); g_simple_async_result_complete (res); return FALSE; } g_string_append (closure->data, key); g_string_append_c (closure->data, '\n'); g_free (key); return TRUE; /* No more entries, result */ } else { rc = ldap_parse_result (closure->ldap, result, &code, NULL, &message, NULL, NULL, 0); g_return_val_if_fail (rc == LDAP_SUCCESS, FALSE); if (seahorse_ldap_source_propagate_error (self, code, &error)) { g_simple_async_result_take_error (res, error); g_simple_async_result_complete (res); return FALSE; } ldap_memfree (message); /* Process more keys if possible */ export_retrieve_key (self, res); return FALSE; } }