ssize_t ClientServer::write_global(uint32_t session_id, const void *buf, size_t count) { if (_s2c.find(session_id) != _s2c.end()) { auto local_client = _s2c[session_id]; return write(local_client, buf, count); } if (!_is_child) { L.error_log("session_id " + to_string(session_id) + " not exists!"); return 0; } //同步 connect_parent(); auto channel = _parent_sock; uint32_t total_size = sizeof(uint32_t) + count + sizeof(uint32_t); auto total_size_n = htonl(total_size); auto session_id_n = htonl(session_id); write(channel, &total_size_n, sizeof(total_size_n)); write(channel, &session_id_n, sizeof(session_id_n)); write(channel, buf, count); return count;//TODO handle write failure }
GtkWidget* get_new_notebook(t_notebook_arg* args) { GtkWidget* notebook; notebook = gtk_notebook_new(); connect_parent(&args->not_parent, notebook); if (args->not_show == TRUE) gtk_widget_show(notebook); return (notebook); }
GtkWidget* get_new_entry(t_entry_arg* args) { GtkWidget* entry; entry = gtk_entry_new(); connect_signals(entry, args); connect_parent(&args->ent_parent, entry); if (args->ent_show == TRUE) gtk_widget_show(entry); return (entry); }
GtkWidget* get_new_box(t_box_arg* args) { GtkWidget* box; if (args->box_orientation == E_MY_GTK_BOX_V) box = gtk_vbox_new(args->box_homogeneous, args->box_spacing); else if (args->box_orientation == E_MY_GTK_BOX_H) box = gtk_hbox_new(args->box_homogeneous, args->box_spacing); else return (NULL); connect_parent(&args->box_parent, box); if (args->box_show == TRUE) gtk_widget_show(box); return (box); }
/** * oh_request_new_domain * @hid: a handler id that is requesting the domain * @tag: a tag to put in the domain being requested * @capabilities: capabilities of the requested domain * @pdid: make new domain with this parent? if so, has to be > 0. * @bdid: make new domain with this peer/brother? if so, has to be > 0. * * Creates a new domain and adds it to the list of domains * that the handler (@handler_id) can report events/resources on. * * Returns: domain id of new domain requested, or 0 if an error ocurred. **/ SaHpiDomainIdT oh_request_new_domain_aitimeout( unsigned int hid, SaHpiTextBufferT *tag, SaHpiDomainCapabilitiesT capabilities, SaHpiTimeoutT aitimeout, SaHpiDomainIdT pdid, SaHpiDomainIdT bdid) { SaHpiDomainIdT did = 0; if (hid < 1) { dbg("Warning - invalid handler id parameter passed."); return 0; } if (pdid == 0) { pdid = oh_get_default_domain_id(); } did = oh_create_domain(capabilities, aitimeout, tag); if (did == 0) { dbg("New domain request failed."); return 0; } oh_add_domain_to_handler(hid, did); /* Connect new domain as a child of pdid domain */ if (connect_parent(did, pdid)) { oh_destroy_domain(did); dbg("Operation failed." " Could not connect new domain to parent %d.", pdid); return 0; } /* Connect new domain as a brother of bdid domain */ if (connect_peers(did, bdid)) { oh_destroy_domain(did); dbg("Operation failed." " Could not make new domain peer of domain %d.", bdid); return 0; } return did; }