int main(void) { switch_t s; chan_t c; packet_t p; path_t in; int sock; crypt_init(); s = switch_new(0); if(util_loadjson(s) != 0 || (sock = util_server(0,1000)) <= 0) { printf("failed to startup %s or %s\n", strerror(errno), crypt_err()); return -1; } printf("loaded hashname %s\n",s->id->hexname); // create/send a ping packet c = chan_new(s, bucket_get(s->seeds, 0), "link", 0); p = chan_packet(c); chan_send(c, p); util_sendall(s,sock); in = path_new("ipv4"); while(util_readone(s, sock, in) == 0) { switch_loop(s); while((c = switch_pop(s))) { printf("channel active %d %s %s\n",c->state,c->hexid,c->to->hexname); if(util_cmp(c->type,"connect") == 0) ext_connect(c); if(util_cmp(c->type,"link") == 0) ext_link(c); if(util_cmp(c->type,"path") == 0) ext_path(c); while((p = chan_pop(c))) { printf("unhandled channel packet %.*s\n", p->json_len, p->json); packet_free(p); } if(c->state == ENDED) chan_free(c); } util_sendall(s,sock); } perror("exiting"); return 0; }
MuxMessagePart* mux_message_part_new (const char *path, GMimeObject *mobj) { MuxMessagePart *self; g_return_val_if_fail (path, NULL); g_return_val_if_fail (GMIME_IS_OBJECT(mobj), NULL); self = MUX_MESSAGE_PART(g_object_new(MUX_TYPE_MESSAGE_PART, NULL)); self->path = ext_path (path); self->content_type = g_mime_object_get_content_type (mobj); self->content_id = g_mime_object_get_content_id (mobj); self->content_disposition = g_mime_object_get_content_disposition (mobj); if (GMIME_IS_PART (mobj)) self->file_name = g_mime_part_get_filename ((GMimePart*)mobj); self->mime_object = g_object_ref (mobj); return self; }