herror_t soap_ctx_add_file(SoapCtx * ctx, const char *filename, const char *content_type, char *dest_href) { char cid[250]; char id[250]; part_t *part; static int counter = 1; FILE *test = fopen(filename, "r"); if (!test) return herror_new("soap_ctx_add_file", FILE_ERROR_OPEN, "Can not open file '%s'", filename); fclose(test); /* generate an id */ sprintf(id, "005512345894583%d", counter++); sprintf(dest_href, "cid:%s", id); sprintf(cid, "<%s>", id); /* add part to context */ part = part_new(cid, filename, content_type, NULL, NULL); if (!ctx->attachments) ctx->attachments = attachments_new(); attachments_add_part(ctx->attachments, part); return H_OK; }
void test_nodestore () { gint i; NodeStore *store; Part *part; Wire *wire; Node *node; Coords p_pos = {111.,22.}; Coords n_pos = {111.,33.}; Coords w_pos = {111.,7.}; Coords w_len = {0.,88.}; store = node_store_new (); part = part_new (); wire = wire_new (); // add one Pin with a offset that is on the wire when rotation N*Pi times Pin *pin = g_new (Pin, 1); pin->offset.x = n_pos.x - p_pos.x; pin->offset.y = n_pos.y - p_pos.y; GSList *list = NULL; list = g_slist_prepend (list, pin); part_set_pins (part, list); g_slist_free (list); item_data_set_pos (ITEM_DATA (part), &p_pos); item_data_set_pos (ITEM_DATA (wire), &w_pos); wire_set_length (wire, &w_len); node_store_add_part (store, part); node_store_add_wire (store, wire); { for (i=0; i<11; i++) item_data_rotate (ITEM_DATA (part), 90, NULL); item_data_set_pos (ITEM_DATA (part), &w_len); for (i=0; i<4; i++) item_data_rotate (ITEM_DATA (part), 90, NULL); item_data_set_pos (ITEM_DATA (part), &n_pos); for (i=0; i<7; i++) item_data_rotate (ITEM_DATA (part), -90, NULL); item_data_set_pos (ITEM_DATA (part), &p_pos); } g_assert (node_store_is_wire_at_pos (store, n_pos)); g_assert (node_store_is_pin_at_pos (store, n_pos)); node = node_store_get_node (store, n_pos); g_assert (!node_is_empty (node)); g_assert (node_needs_dot (node)); node_store_remove_part (store, part); node_store_remove_wire (store, wire); g_object_unref (store); }
Part * part_new_from_library_part (LibraryPart *library_part, Grid *grid) { Part *part; GSList *pins; PartPriv *priv; LibrarySymbol *symbol; g_return_val_if_fail (library_part != NULL, NULL); part = part_new (grid); if (!part) return NULL; priv = part->priv; symbol = library_get_symbol (library_part->symbol_name); if (symbol == NULL) { oregano_warning (g_strdup_printf (_("Couldn't find the requested symbol" "%s for part %s in library.\n"), library_part->symbol_name, library_part->name)); return NULL; } pins = symbol->connections; if (pins) part_set_pins (part, pins); g_object_set (G_OBJECT (part), "Part::properties", library_part->properties, "Part::labels", library_part->labels, NULL); priv->name = g_strdup (library_part->name); priv->symbol_name = g_strdup (library_part->symbol_name); priv->library = library_part->library; part_update_bbox (part); return part; }
static void doc_parts_load(GaimMimeDocument *doc, const char *boundary, const char *buf, gsize len) { char *b = (char *) buf; gsize n = len; const char *bnd; gsize bl; bnd = g_strdup_printf("--%s", boundary); bl = strlen(bnd); for(b = g_strstr_len(b, n, bnd); b; ) { char *tail; /* skip the boundary */ b += bl; n -= bl; /* skip the trailing \r\n or -- as well */ if(n >= 2) { b += 2; n -= 2; } /* find the next boundary */ tail = g_strstr_len(b, n, bnd); if(tail) { gsize sl; sl = tail - b; if(sl) { GaimMimePart *part = part_new(doc); part_load(part, b, sl); } } b = tail; } }
GaimMimePart * gaim_mime_part_new(GaimMimeDocument *doc) { g_return_val_if_fail(doc != NULL, NULL); return part_new(doc); }