static void master_okbutton_callback (GtkWidget *widget, GtkWidget* window) { master_check_master_addr_prefix(); master_addr_result = strdup_strip (gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (master_addr_combo)->entry))); master_name_result = strdup_strip (gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (master_name_combo)->entry))); config_set_string ("/" CONFIG_FILE "/Add Master/game", type2id (master_type)); if (!master_addr_result || !master_name_result) { dialog_ok (NULL, _("You have to specify a name and an address.")); return; } master_to_add = add_master (master_addr_result, master_name_result, master_type, NULL, TRUE, FALSE); if (!master_to_add) { dialog_ok (NULL, _("Master address \"%s\" is not valid."), master_addr_result); } else { if (master_addr_result) history_add (master_history_addr, master_addr_result); if (master_name_result) history_add (master_history_name, master_name_result); gtk_widget_destroy(window); } }
int ProcXIChangeHierarchy(ClientPtr client) { xXIAnyHierarchyChangeInfo *any; int required_len = sizeof(xXIChangeHierarchyReq); char n; int rc = Success; int flags[MAXDEVICES] = {0}; REQUEST(xXIChangeHierarchyReq); REQUEST_AT_LEAST_SIZE(xXIChangeHierarchyReq); if (!stuff->num_changes) return rc; any = (xXIAnyHierarchyChangeInfo*)&stuff[1]; while(stuff->num_changes--) { SWAPIF(swapl(&any->type, n)); SWAPIF(swaps(&any->length, n)); required_len += any->length; if ((stuff->length * 4) < required_len) return BadLength; switch(any->type) { case XIAddMaster: { xXIAddMasterInfo* c = (xXIAddMasterInfo*)any; SWAPIF(swaps(&c->name_len, n)); rc = add_master(client, c, flags); if (rc != Success) goto unwind; } break; case XIRemoveMaster: { xXIRemoveMasterInfo* r = (xXIRemoveMasterInfo*)any; rc = remove_master(client, r, flags); if (rc != Success) goto unwind; } break; case XIDetachSlave: { xXIDetachSlaveInfo* c = (xXIDetachSlaveInfo*)any; rc = detach_slave(client, c, flags); if (rc != Success) goto unwind; } break; case XIAttachSlave: { xXIAttachSlaveInfo* c = (xXIAttachSlaveInfo*)any; rc = attach_slave(client, c, flags); if (rc != Success) goto unwind; } break; } any = (xXIAnyHierarchyChangeInfo*)((char*)any + any->length * 4); } unwind: XISendDeviceHierarchyEvent(flags); return rc; }
int main(int argc, char *argv[]) { int cflag = 0, fflag = 0, Cflag = 0; char *domain, *host = NULL, *srcdomain = NULL; char *tid = NULL, *prog = NULL, *ipadd = NULL; char *port = NULL, *map = NULL; int status, xfr_status, ch, srvport; u_int32_t ordernum, new_ordernum; struct ypall_callback callback; CLIENT *client = NULL; extern char *optarg; yp_get_default_domain(&domain); while ((ch = getopt(argc, argv, "cd:fh:s:C:")) != -1) switch (ch) { case 'c': cflag++; break; case 'd': if (strchr(optarg, '/')) /* Ha ha, we are not listening */ break; domain = optarg; break; case 'f': fflag++; break; case 'h': host = optarg; break; case 's': if (strchr(optarg, '/')) /* Ha ha, we are not listening */ break; srcdomain = optarg; break; case 'C': if (optind + 3 >= argc) usage(); Cflag++; tid = optarg; prog = argv[optind++]; ipadd = argv[optind++]; port = argv[optind++]; break; default: usage(); break; } status = YPPUSH_SUCC; if (optind + 1 != argc) usage(); map = argv[optind]; if (status > 0) { ypopenlog(); yplog("ypxfr: Arguments:"); yplog("YP clear to local: %s", (cflag) ? "no" : "yes"); yplog(" Force transfer: %s", (fflag) ? "yes" : "no"); yplog(" domain: %s", domain); yplog(" host: %s", host); yplog(" source domain: %s", srcdomain); yplog(" transid: %s", tid); yplog(" prog: %s", prog); yplog(" port: %s", port); yplog(" ipadd: %s", ipadd); yplog(" map: %s", map); if (fflag != 0) { ordernum = 0; } else { status = get_local_ordernum(domain, map, &ordernum); } } if (status > 0) { yplog("Get Master"); if (host == NULL) { if (srcdomain == NULL) { status = yp_master(domain, map, &host); } else { status = yp_master(srcdomain, map, &host); } if (status == 0) { status = YPPUSH_SUCC; } else { status = -status; } } } /* XXX this is raceable if portmap has holes! */ if (status > 0) { yplog("Check for reserved port on host: %s", host); srvport = getrpcport(host, YPPROG, YPVERS, IPPROTO_TCP); if (srvport >= IPPORT_RESERVED) status = YPPUSH_REFUSED; } if (status > 0) { yplog("Connect host: %s", host); client = yp_bind_host(host, YPPROG, YPVERS, 0, 1); status = get_remote_ordernum(client, domain, map, ordernum, &new_ordernum); } if (status == YPPUSH_SUCC) { char tmpmapname[MAXPATHLEN]; int fd; /* Create temporary db */ snprintf(tmpmapname, sizeof tmpmapname, "%s/%s/ypdbXXXXXXXXXX", YP_DB_PATH, domain); fd = mkstemp(tmpmapname); if (fd == -1) status = YPPUSH_DBM; else close(fd); if (status > 0) { db = create_db(domain, map, tmpmapname); if (db == NULL) status = YPPUSH_DBM; } /* Add ORDER */ if (status > 0) status = add_order(db, new_ordernum); /* Add MASTER */ if (status > 0) status = add_master(client, domain, map, db); /* Add INTERDOMAIN */ if (status > 0) status = add_interdomain(client, domain, map, db); /* Add SECURE */ if (status > 0) status = add_secure(client, domain, map, db); if (status > 0) { callback.foreach = ypxfr_foreach; status = get_map(client, domain, map, &callback); } /* Close db */ if (db != NULL) ypdb_close(db); /* Rename db */ if (status > 0) { status = install_db(domain, map, tmpmapname); } else { unlink(tmpmapname); status = YPPUSH_SUCC; } } xfr_status = status; if (client != NULL) clnt_destroy(client); /* YP_CLEAR */ if (!cflag) { client = yp_bind_local(YPPROG, YPVERS); status = send_clear(client); clnt_destroy(client); } if (Cflag > 0) { /* Send Response */ client = yp_bind_host(ipadd, atoi(prog), 1, atoi(port), 0); status = send_reply(client, xfr_status, atoi(tid)); clnt_destroy(client); } return (0); }