void inherit_attributes(umlclasslist parents, umlattrlist umla) { umlattrlist pumla; while (parents != NULL) { pumla = parents->key->attributes; insert_attribute(copy_attributes(pumla), umla); parents = parents->next; } }
papi_status_t papiPrinterListJobs(papi_service_t handle, char *name, char **requested_attrs, int type_mask, int max_num_jobs, papi_job_t **jobs) { papi_status_t status, result = PAPI_INTERNAL_ERROR; service_t *svc = handle; papi_attribute_t **request = NULL, **op = NULL, **response = NULL; void *iter = NULL; if ((svc == NULL) || (name == NULL)) return (PAPI_BAD_ARGUMENT); /* if we are already connected, use that connection. */ if (svc->connection == NULL) if ((result = service_connect(svc, name)) != PAPI_OK) return (result); ipp_initialize_request(svc, &request, OPID_GET_JOBS); ipp_initialize_operational_attributes(svc, &op, name, -1); if (requested_attrs != NULL) { int i; for (i = 0; requested_attrs[i] != NULL; i++) papiAttributeListAddString(&op, PAPI_ATTR_APPEND, "requested-attributes", requested_attrs[i]); } papiAttributeListAddCollection(&request, PAPI_ATTR_REPLACE, "operational-attributes-group", op); papiAttributeListFree(op); result = ipp_send_request(svc, request, &response); papiAttributeListFree(request); op = NULL; for (status = papiAttributeListGetCollection(response, &iter, "job-attributes-group", &op); status == PAPI_OK; status = papiAttributeListGetCollection(response, &iter, NULL, &op)) { job_t *j = NULL; if ((j = calloc(1, sizeof (*j))) == NULL) return (PAPI_TEMPORARY_ERROR); copy_attributes(&j->attributes, op); op = NULL; list_append(jobs, j); } papiAttributeListFree(response); return (result); }
// The relation handler is called for each node in the input data. void relation(const osmium::Relation& relation) { { osmium::builder::RelationBuilder builder{m_buffer}; copy_attributes(builder, relation); copy_tags(builder, relation.tags()); // Copy the relation member list over to the new way. builder.add_item(relation.members()); } m_buffer.commit(); }
// The way handler is called for each node in the input data. void way(const osmium::Way& way) { { osmium::builder::WayBuilder builder{m_buffer}; copy_attributes(builder, way); copy_tags(builder, way.tags()); // Copy the node list over to the new way. builder.add_item(way.nodes()); } m_buffer.commit(); }
papi_status_t papiPrintersList(papi_service_t handle, char **requested_attrs, papi_filter_t *filter, papi_printer_t **printers) { papi_status_t status, result = PAPI_INTERNAL_ERROR; service_t *svc = handle; papi_attribute_t **request = NULL, **op = NULL, **response = NULL; void *iter = NULL; if ((svc == NULL) || (printers == NULL)) return (PAPI_BAD_ARGUMENT); /* if we are already connected, use that connection. */ if (svc->connection == NULL) if ((result = service_connect(svc, DEFAULT_DEST)) != PAPI_OK) return (result); ipp_initialize_request(svc, &request, OPID_CUPS_GET_PRINTERS); ipp_initialize_operational_attributes(svc, &op, NULL, -1); if (requested_attrs != NULL) { int i; for (i = 0; requested_attrs[i] != NULL; i++) papiAttributeListAddString(&op, PAPI_ATTR_APPEND, "requested-attributes", requested_attrs[i]); } papiAttributeListAddCollection(&request, PAPI_ATTR_REPLACE, "operational-attributes-group", op); papiAttributeListFree(op); result = ipp_send_request(svc, request, &response); papiAttributeListFree(request); op = NULL; for (status = papiAttributeListGetCollection(response, &iter, "printer-attributes-group", &op); status == PAPI_OK; status = papiAttributeListGetCollection(response, &iter, NULL, &op)) { printer_t *p = NULL; if ((p = calloc(1, sizeof (*p))) == NULL) return (PAPI_TEMPORARY_ERROR); copy_attributes(&p->attributes, op); op = NULL; list_append(printers, p); } papiAttributeListFree(response); return (result); }
DsLogAdmin::Log_ptr TAO_RTEventLog_i::copy_with_id (DsLogAdmin::LogId id) { RTEventLogAdmin::EventLogFactory_var eventLogFactory = RTEventLogAdmin::EventLogFactory::_narrow (factory_.in ()); RTEventLogAdmin::EventLog_var log = eventLogFactory->create_with_id (id, DsLogAdmin::halt, 0, thresholds_); copy_attributes (log.in ()); return log._retn (); }
papi_status_t papiPrinterQuery(papi_service_t handle, char *name, char **requested_attrs, papi_attribute_t **job_attributes, papi_printer_t *printer) { papi_status_t result = PAPI_INTERNAL_ERROR; service_t *svc = handle; printer_t *p = NULL; papi_attribute_t **request = NULL, **op = NULL, **response = NULL; if ((svc == NULL) || (name == NULL) || (printer == NULL)) return (PAPI_BAD_ARGUMENT); /* if we are already connected, use that connection. */ if (svc->connection == NULL) if ((result = service_connect(svc, name)) != PAPI_OK) return (result); if ((*printer = p = calloc(1, sizeof (*p))) == NULL) return (PAPI_TEMPORARY_ERROR); ipp_initialize_request(svc, &request, OPID_GET_PRINTER_ATTRIBUTES); ipp_initialize_operational_attributes(svc, &op, name, -1); if (requested_attrs != NULL) { int i; for (i = 0; requested_attrs[i] != NULL; i++) papiAttributeListAddString(&op, PAPI_ATTR_APPEND, "requested-attributes", requested_attrs[i]); } papiAttributeListAddCollection(&request, PAPI_ATTR_REPLACE, "operational-attributes-group", op); papiAttributeListFree(op); result = ipp_send_request(svc, request, &response); papiAttributeListFree(request); op = NULL; papiAttributeListGetCollection(response, NULL, "printer-attributes-group", &op); copy_attributes(&p->attributes, op); papiAttributeListFree(response); return (result); }
/* PUBLIC */ Topform term_to_topform2(Term t) { Formula f = term_to_formula(t); Topform tf; if (clausal_formula(f)) { tf = formula_to_clause(f); tf->attributes = copy_attributes(f->attributes); zap_formula(f); clause_set_variables(tf, MAX_VARS); } else { tf = get_topform(); tf->is_formula = TRUE; tf->attributes = f->attributes; f->attributes = NULL; tf->formula = universal_closure(f); } return tf; } /* term_to_topform2 */
// The node handler is called for each node in the input data. void node(const osmium::Node& node) { // Open a new scope, because the NodeBuilder we are creating has to // be destructed, before we can call commit() below. { // To create a node, we need a NodeBuilder object. It will create // the node in the given buffer. osmium::builder::NodeBuilder builder{m_buffer}; // Copy common object attributes over to the new node. copy_attributes(builder, node); // Copy the location over to the new node. builder.set_location(node.location()); // Copy (changed) tags. copy_tags(builder, node.tags()); } // Once the object is written to the buffer completely, we have to call // commit(). m_buffer.commit(); }
/* * When the PAPI supports papiJobCreate(), papiJobStreamAdd() and * papiJobClose(), this will be much cleaner and more efficient, but in the * meantime, we are using a private, non-standard interface to do this. */ papi_status_t ipp_send_document(papi_service_t svc, papi_attribute_t **request, papi_attribute_t ***response, ipp_reader_t iread, void *fd) { papi_status_t status; papi_stream_t s = NULL; papi_job_t j = NULL; papi_attribute_t **operational = NULL; papi_attribute_t **job_attributes = NULL; char *queue = NULL; ssize_t rc; int id = -1; char buf[BUFSIZ]; char last = PAPI_FALSE; char *keys[] = { "attributes-natural-language", "attributes-charset", "printer-uri", "job-id", "job-uri", "last-document", NULL }; /* Get operational attributes from the request */ (void) papiAttributeListGetCollection(request, NULL, "operational-attributes-group", &operational); /* * the operational-attributes-group must contain: * job-uri (or printer-uri/job-id) * last-document */ get_printer_id(operational, &queue, &id); if (id < 0) { ipp_set_status(response, PAPI_BAD_REQUEST, "missing job-uri or job-id"); return (PAPI_BAD_REQUEST); } else if (queue == NULL) { ipp_set_status(response, PAPI_BAD_REQUEST, "missing printer-uri or job-uri"); return (PAPI_BAD_REQUEST); } status = papiAttributeListGetBoolean(operational, NULL, "last-document", &last); if (status != PAPI_OK) { ipp_set_status(response, status, "last-document: %s", papiStatusString(status)); return (PAPI_BAD_REQUEST); } /* * the operational-attributes-group may contain: * document-name * compression * document-format * document-natural-language * Simply copy the entire contents of the operational-attributes-group * for the PAPI call's possible use. */ split_and_copy_attributes(keys, operational, NULL, &job_attributes); /* copy any job-attributes-group attributes for the PAPI call */ if (papiAttributeListGetCollection(request, NULL, "job-attributes-group", &operational) == PAPI_OK) copy_attributes(&job_attributes, operational); /* create a stream to write the document data on */ status = papiJobStreamAdd(svc, queue, id, &s); papiAttributeListFree(job_attributes); if (status != PAPI_OK) { ipp_set_status(response, status, "job submission: %s", ipp_svc_status_mesg(svc, status)); return (status); } /* copy the document data from the IPP connection to the stream */ while ((status == PAPI_OK) && ((rc = iread(fd, buf, sizeof (buf))) > 0)) status = papiJobStreamWrite(svc, s, buf, rc); if (status != PAPI_OK) { ipp_set_status(response, status, "write job data: %s", ipp_svc_status_mesg(svc, status)); return (status); } /* close the stream */ status = papiJobStreamClose(svc, s, &j); if (status != PAPI_OK) { ipp_set_status(response, status, "close job stream: %s", ipp_svc_status_mesg(svc, status)); papiJobFree(j); /* we shouldn't have a job, but just in case */ return (status); } /* if it's the last document, commit the job */ if (last == PAPI_TRUE) { status = papiJobCommit(svc, queue, id); } /* add the job attributes to the response in a job-attributes-group */ if (j != NULL) { papi_to_ipp_job_group(response, request, PAPI_ATTR_REPLACE, j); papiJobFree(j); } return (status); }
papi_status_t ipp_validate_job(papi_service_t svc, papi_attribute_t **request, papi_attribute_t ***response, ipp_reader_t iread, void *fd) { papi_status_t status; papi_job_t j = NULL; papi_attribute_t **operational = NULL; papi_attribute_t **job_attributes = NULL; char *queue = NULL; char *files[] = { "/etc/syslog.conf", NULL }; ssize_t rc; char buf[BUFSIZ]; char *keys[] = { "attributes-natural-language", "attributes-charset", "printer-uri", NULL }; /* Get operational attributes from the request */ (void) papiAttributeListGetCollection(request, NULL, "operational-attributes-group", &operational); /* * The operational-attributes-group must contain: * printer-uri */ get_printer_id(operational, &queue, NULL); if (queue == NULL) { ipp_set_status(response, status, "printer-uri: %s", papiStatusString(status)); return (PAPI_BAD_REQUEST); } /* * The operational-attributes-group may contain: * job-name * ipp-attribute-fidelity * document-name * compression * document-format * document-natural-language * job-k-octets * job-impressions * job-media-sheets * Simply copy the entire contents of the operational-attributes-group * for the PAPI call's possible use. */ split_and_copy_attributes(keys, operational, NULL, &job_attributes); /* copy any job-attributes-group attributes for the PAPI call */ if (papiAttributeListGetCollection(request, NULL, "job-attributes-group", &operational) == PAPI_OK) copy_attributes(&job_attributes, operational); /* request job validation */ status = papiJobValidate(svc, queue, job_attributes, NULL, files, &j); papiAttributeListFree(job_attributes); if (status != PAPI_OK) { ipp_set_status(response, status, "validating job: %s", ipp_svc_status_mesg(svc, status)); papiJobFree(j); /* we shouldn't have a job, but just in case */ return (status); } /* add the job attributes to the response in a job-attributes-group */ if (j != NULL) { papi_to_ipp_job_group(response, request, PAPI_ATTR_REPLACE, j); papiJobFree(j); } return (status); }
status_t CopyFile(const entry_ref& source, const entry_ref& dest) { copy_data(source, dest); copy_attributes(source, dest); return B_OK; }
static void edit (const char *filename, const char *root) { CLEANUP_FREE char *filename_to_free = NULL; CLEANUP_FREE char *tmpdir = guestfs_get_tmpdir (g); char tmpfile[strlen (tmpdir) + 32]; sprintf (tmpfile, "%s/virteditXXXXXX", tmpdir); int fd; char fdbuf[32]; CLEANUP_FREE char *upload_from = NULL; CLEANUP_FREE char *newname = NULL; CLEANUP_FREE char *backupname = NULL; /* Windows? Special handling is required. */ if (is_windows (g, root)) filename = filename_to_free = windows_path (g, root, filename); /* Download the file to a temporary. */ fd = mkstemp (tmpfile); if (fd == -1) { perror ("mkstemp"); exit (EXIT_FAILURE); } snprintf (fdbuf, sizeof fdbuf, "/dev/fd/%d", fd); if (guestfs_download (g, filename, fdbuf) == -1) goto error; if (close (fd) == -1) { perror (tmpfile); goto error; } if (!perl_expr) upload_from = edit_interactively (tmpfile); else upload_from = edit_non_interactively (tmpfile); /* We don't always need to upload: upload_from could be NULL because * the user closed the editor without changing the file. */ if (upload_from) { /* Upload to a new file in the same directory, so if it fails we * don't end up with a partially written file. Give the new file * a completely random name so we have only a tiny chance of * overwriting some existing file. */ newname = generate_random_name (filename); if (guestfs_upload (g, upload_from, newname) == -1) goto error; /* Set the permissions, UID, GID and SELinux context of the new * file to match the old file (RHBZ#788641). */ if (copy_attributes (filename, newname) == -1) goto error; /* Backup or overwrite the file. */ if (backup_extension) { backupname = generate_backup_name (filename); if (guestfs_mv (g, filename, backupname) == -1) goto error; } if (guestfs_mv (g, newname, filename) == -1) goto error; } unlink (tmpfile); return; error: unlink (tmpfile); exit (EXIT_FAILURE); }
static Const fold_op(Node node) /*;fold_op*/ { Node opn, arg1, arg2, oplist; Const result, op1, op2, tryc; Symbol sym, op_name; int *uint; int rm; Tuple tup; int res, overflow; opn = N_AST1(node); oplist = N_AST2(node); tup = N_LIST(oplist); arg1 = (Node) tup[1]; arg2 = (Node) tup[2]; op1 = const_fold(arg1); op2 = const_fold(arg2); op_name = N_UNQ(opn); /* If either operand raises and exception, so does the operation */ if (N_KIND(arg1) == as_raise) { copy_attributes(arg1, node); return const_new(CONST_OM); } if (N_KIND(arg2) == as_raise && op_name != symbol_andthen && op_name != symbol_orelse) { copy_attributes(arg2, node); return const_new(CONST_OM); } if (is_const_om(op1) || (is_const_om(op2) && (op_name != symbol_in || op_name != symbol_notin))) { return const_new(CONST_OM); } sym = op_name; if ( sym == symbol_addi || sym == symbol_addfl) { if (sym == symbol_addi) { res = word_add(INTV(op1), INTV(op2), &overflow); if (overflow) { create_raise(node, symbol_constraint_error); result = const_new(CONST_OM); } else result = int_const(res); } else result = real_const(REALV(op1) + REALV(op2)); } else if ( sym == symbol_addfx) { const_check(op1, CONST_RAT); const_check(op2, CONST_RAT); result= rat_const(rat_add(RATV(op1), RATV(op2))); } else if ( sym == symbol_subi) { if (is_const_int(op1)) { if (is_const_int(op2)) { res = word_sub(INTV(op1), INTV(op2), &overflow); if (overflow) { create_raise(node, symbol_constraint_error); result = const_new(CONST_OM); } else result = int_const(res); } else { chaos("fold_op: subi operand types"); } } } else if (sym == symbol_subfl) { result = real_const(REALV(op1) - REALV(op2)); } else if ( sym == symbol_subfx) { const_check(op1, CONST_RAT); const_check(op2, CONST_RAT); result= rat_const(rat_sub(RATV(op1), RATV(op2))); } else if ( sym == symbol_muli) { #ifdef TBSL -- need to check for overflow and convert result back to int if not -- note that low-level setl is missing calls to check_overflow that -- are present in high-level and should be in low-level as well result = int_mul(int_fri(op1), int_fri(op2)); #endif /* until overflow check in */ const_check(op1, CONST_INT); const_check(op2, CONST_INT); res = word_mul(INTV(op1), INTV(op2), &overflow); if (overflow) { create_raise(node, symbol_constraint_error); result = const_new(CONST_OM); } else result = int_const(res); }