void FilterGraph::addFilter (const PluginDescription* desc, double x, double y) { if (desc != nullptr) { AudioProcessorGraph::Node* node = nullptr; String errorMessage; // UID generation going on here if (AudioPluginInstance* instance = formatManager.createPluginInstance (*desc, graph.getSampleRate(), graph.getBlockSize(), errorMessage)) { int nodeId = generate_uid(uid_chklist); node = graph.addNode (instance, nodeId); } if (node != nullptr) { node->properties.set ("x", x); node->properties.set ("y", y); sendChangeMessage(); } else { AlertWindow::showMessageBox (AlertWindow::WarningIcon, String("Couldn't create filter"), errorMessage); } } }
/* * format: * $owner-uid;nr-spells;spell1-name;spell1-uid;spell2-name;spell2-uid;...;\n */ void instance::draw_spells(puppet_ptr inPuppet, int inNrOfSpells) { if (!inPuppet) inPuppet = active_puppet_; const int mMaxSpellsInHand = 6; drawn_spells_.str(""); drawn_spells_ << "[draw];" << inNrOfSpells << "\n"; drawn_spells_ << "$" << inPuppet->getUID() << ";"; // create nrSpellsPerTurn spells from the hero's deck Deck* lDeck = inPuppet->getDeck(); int i; for (i=0; i< inNrOfSpells; ++i) { Spell* lSpell = lDeck->drawSpell(); // assign UID and attach to puppet lSpell->setUID(generate_uid()); inPuppet->attachSpell(lSpell); pass_to_lua("Spells.onDrawSpell", 2, "Pixy::Puppet", inPuppet.get(), "Pixy::Spell", lSpell); drawn_spells_ << lSpell->getName() << ";" << lSpell->getUID() << ";"; lSpell = 0; } drawn_spells_ << "\n"; // tell it to drop some spells if its hand is overflown drawn_spells_ << "[drop];"; int nrOverflow = inPuppet->nrSpellsInHand() - mMaxSpellsInHand; //~ std::cout << "Puppet has " << inPuppet->nrSpellsInHand() << " spells in hand, an overflow of= " << nrOverflow << "\n"; if (nrOverflow > 0) { drawn_spells_ << nrOverflow << "\n$" << inPuppet->getUID() << ";"; } else drawn_spells_ << 0; Entity::spells_t const& lHand = inPuppet->getHand(); while (inPuppet->nrSpellsInHand() > mMaxSpellsInHand) { Spell* lSpell = lHand.front(); drawn_spells_ << lSpell->getUID() << ";"; pass_to_lua("Spells.onDropSpell", 2, "Pixy::Puppet", inPuppet.get(), "Pixy::Spell", lSpell); inPuppet->detachSpell(lSpell->getUID()); lSpell = 0; } drawn_spells_ << "\n"; //~ log_->infoStream() << "sending drawn spells to Puppet " << inPuppet->getName(); std::cout << "drawn spells:\n" << drawn_spells_.str() << "\n"; // broadcast the data Event evt(EventUID::DrawSpells, EventFeedback::Ok, Event::NoFormat); evt.setProperty("Data", drawn_spells_.str()); broadcast(evt); }
void instance::subscribe(player_cptr player) { // validate player before hooking them if (!player->is_online()) { log_->warnStream() << "an offline player attempted to join the instance"; throw std::runtime_error("an offline player attempted to join the instance"); } //players_.push_back(player); assert(player->get_puppet()); player->get_puppet()->setUID(generate_uid()); player->get_puppet()->live(); puppets_.push_back(player->get_puppet()); // attach them to this instance ((Player*)player.get())->set_instance(shared_from_this()); ((Player*)player.get())->set_in_lobby(false); log_->debugStream() << "a puppet named " << player->get_puppet()->getName() << "(" << player->get_puppet()->getUID() << ")" << " has joined the instance"; }
void mta_session(struct mta_relay *relay, struct mta_route *route) { struct mta_session *s; struct timeval tv; mta_session_init(); s = xcalloc(1, sizeof *s, "mta_session"); s->id = generate_uid(); s->relay = relay; s->route = route; s->io.sock = -1; if (relay->flags & RELAY_SSL && relay->flags & RELAY_AUTH) s->flags |= MTA_USE_AUTH; if (relay->pki_name) s->flags |= MTA_USE_CERT; if (relay->flags & RELAY_LMTP) s->flags |= MTA_LMTP; switch (relay->flags & (RELAY_SSL|RELAY_TLS_OPTIONAL)) { case RELAY_SSL: s->flags |= MTA_FORCE_ANYSSL; s->flags |= MTA_WANT_SECURE; break; case RELAY_SMTPS: s->flags |= MTA_FORCE_SMTPS; s->flags |= MTA_WANT_SECURE; break; case RELAY_STARTTLS: s->flags |= MTA_FORCE_TLS; s->flags |= MTA_WANT_SECURE; break; case RELAY_TLS_OPTIONAL: /* do not force anything, try tls then smtp */ break; default: s->flags |= MTA_FORCE_PLAIN; } log_debug("debug: mta: %p: spawned for relay %s", s, mta_relay_to_text(relay)); stat_increment("mta.session", 1); if (route->dst->ptrname || route->dst->lastptrquery) { /* We want to delay the connection since to always notify * the relay asynchronously. */ tv.tv_sec = 0; tv.tv_usec = 0; evtimer_set(&s->io.ev, mta_start, s); evtimer_add(&s->io.ev, &tv); } else if (waitq_wait(&route->dst->ptrname, mta_on_ptr, s)) { dns_query_ptr(s->id, s->route->dst->sa); tree_xset(&wait_ptr, s->id, s); s->flags |= MTA_WAIT; } }
static int mr_authenticate(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct Client *agent_p = NULL; /* They really should use CAP for their own sake. */ if(!IsCapable(source_p, CLICAP_SASL)) return 0; if (strlen(client_p->id) == 3) { exit_client(client_p, client_p, client_p, "Mixing client and server protocol"); return 0; } if(source_p->preClient->sasl_complete) { sendto_one(source_p, form_str(ERR_SASLALREADY), me.name, EmptyString(source_p->name) ? "*" : source_p->name); return 0; } if(strlen(parv[1]) > 400) { sendto_one(source_p, form_str(ERR_SASLTOOLONG), me.name, EmptyString(source_p->name) ? "*" : source_p->name); return 0; } if(!*source_p->id) { /* Allocate a UID. */ strcpy(source_p->id, generate_uid()); add_to_id_hash(source_p->id, source_p); } if(*source_p->preClient->sasl_agent) agent_p = find_id(source_p->preClient->sasl_agent); if(agent_p == NULL) { if (!strcmp(parv[1], "EXTERNAL") && source_p->certfp != NULL) sendto_server(NULL, NULL, CAP_TS6|CAP_ENCAP, NOCAPS, ":%s ENCAP * SASL %s * S %s %s", me.id, source_p->id, parv[1], source_p->certfp); else sendto_server(NULL, NULL, CAP_TS6|CAP_ENCAP, NOCAPS, ":%s ENCAP * SASL %s * S %s", me.id, source_p->id, parv[1]); } else sendto_one(agent_p, ":%s ENCAP %s SASL %s %s C %s", me.id, agent_p->servptr->name, source_p->id, agent_p->id, parv[1]); source_p->preClient->sasl_out++; return 0; }
static struct mta_route * mta_route_for(struct envelope *e) { struct ssl ssl; struct mta_route key, *route; bzero(&key, sizeof key); key.flags = e->agent.mta.relay.flags; if (e->agent.mta.relay.flags & ROUTE_BACKUP) { key.hostname = e->dest.domain; key.backupname = e->agent.mta.relay.hostname; } else if (e->agent.mta.relay.hostname[0]) { key.hostname = e->agent.mta.relay.hostname; key.flags |= ROUTE_MX; } else key.hostname = e->dest.domain; key.port = e->agent.mta.relay.port; key.cert = e->agent.mta.relay.cert; if (!key.cert[0]) key.cert = NULL; key.auth = e->agent.mta.relay.authmap; if (!key.auth[0]) key.auth = NULL; if ((route = SPLAY_FIND(mta_route_tree, &routes, &key)) == NULL) { route = xcalloc(1, sizeof *route, "mta_route"); TAILQ_INIT(&route->tasks); route->id = generate_uid(); route->flags = key.flags; route->hostname = xstrdup(key.hostname, "mta: hostname"); route->backupname = key.backupname ? xstrdup(key.backupname, "mta: backupname") : NULL; route->port = key.port; route->cert = key.cert ? xstrdup(key.cert, "mta: cert") : NULL; route->auth = key.auth ? xstrdup(key.auth, "mta: auth") : NULL; if (route->cert) { strlcpy(ssl.ssl_name, route->cert, sizeof(ssl.ssl_name)); route->ssl = SPLAY_FIND(ssltree, env->sc_ssl, &ssl); } SPLAY_INSERT(mta_route_tree, &routes, route); route->maxconn = MTA_MAXCONN; route->maxmail = MTA_MAXMAIL; route->maxrcpt = MTA_MAXRCPT; log_trace(TRACE_MTA, "mta: new %s", mta_route_to_text(route)); stat_increment("mta.route", 1); } else { log_trace(TRACE_MTA, "mta: reusing %s", mta_route_to_text(route)); } return (route); }
Unit* instance::_create_unit(std::string model, Puppet& owner) { if (owner.getUnits().size() >= 10) return 0; Unit* unit_ = rmgr_.getUnit(model, owner.getRace()); assert(unit_); unit_->setUID(generate_uid()); owner.attachUnit(unit_); Event evt(EventUID::CreateUnit); unit_->toEvent(evt); broadcast(evt); log_->debugStream() << "creating unit named " << model << ", owner now has " << owner.getUnits().size() << " units under control"; unit_->live(); //unit_ = 0; return unit_; }
void mta_session(struct mta_route *route) { struct mta_session *session; session = xcalloc(1, sizeof *session, "mta_session"); session->id = generate_uid(); session->route = route; session->state = MTA_INIT; session->io.sock = -1; tree_xset(&sessions, session->id, session); TAILQ_INIT(&session->hosts); if (route->flags & ROUTE_MX) session->flags |= MTA_FORCE_MX; if (route->flags & ROUTE_SSL && route->flags & ROUTE_AUTH) session->flags |= MTA_USE_AUTH; if (route->cert) session->flags |= MTA_USE_CERT; switch (route->flags & ROUTE_SSL) { case ROUTE_SSL: session->flags |= MTA_FORCE_ANYSSL; break; case ROUTE_SMTPS: session->flags |= MTA_FORCE_SMTPS; break; case ROUTE_STARTTLS: /* STARTTLS is tried by default */ break; default: session->flags |= MTA_ALLOW_PLAIN; } log_debug("mta: %p: spawned for %s", session, mta_route_to_text(route)); stat_increment("mta.session", 1); mta_enter_state(session, MTA_INIT); }
static int m_authenticate(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct Client *agent_p = NULL; struct Client *saslserv_p = NULL; /* They really should use CAP for their own sake. */ if(!IsCapable(source_p, CLICAP_SASL)) return 0; if (strlen(client_p->id) == 3) { exit_client(client_p, client_p, client_p, "Mixing client and server protocol"); return 0; } saslserv_p = find_named_client(ConfigFileEntry.sasl_service); if (saslserv_p == NULL || !IsService(saslserv_p)) { sendto_one(source_p, form_str(ERR_SASLABORTED), me.name, EmptyString(source_p->name) ? "*" : source_p->name); return 0; } if(source_p->localClient->sasl_complete) { *source_p->localClient->sasl_agent = '\0'; source_p->localClient->sasl_complete = 0; } if(strlen(parv[1]) > 400) { sendto_one(source_p, form_str(ERR_SASLTOOLONG), me.name, EmptyString(source_p->name) ? "*" : source_p->name); return 0; } if(!*source_p->id) { /* Allocate a UID. */ strcpy(source_p->id, generate_uid()); add_to_id_hash(source_p->id, source_p); } if(*source_p->localClient->sasl_agent) agent_p = find_id(source_p->localClient->sasl_agent); if(agent_p == NULL) { sendto_one(saslserv_p, ":%s ENCAP %s SASL %s %s H %s %s", me.id, saslserv_p->servptr->name, source_p->id, saslserv_p->id, source_p->host, source_p->sockhost); if (source_p->certfp != NULL) sendto_one(saslserv_p, ":%s ENCAP %s SASL %s %s S %s %s", me.id, saslserv_p->servptr->name, source_p->id, saslserv_p->id, parv[1], source_p->certfp); else sendto_one(saslserv_p, ":%s ENCAP %s SASL %s %s S %s", me.id, saslserv_p->servptr->name, source_p->id, saslserv_p->id, parv[1]); rb_strlcpy(source_p->localClient->sasl_agent, saslserv_p->id, IDLEN); } else sendto_one(agent_p, ":%s ENCAP %s SASL %s %s C %s", me.id, agent_p->servptr->name, source_p->id, agent_p->id, parv[1]); source_p->localClient->sasl_out++; return 0; }
int enqueue(int argc, char *argv[]) { int i, ch, tflag = 0, noheader; char *fake_from = NULL, *buf; struct passwd *pw; FILE *fp, *fout; size_t len; char *line; int dotted; int inheaders = 0; bzero(&msg, sizeof(msg)); time(×tamp); while ((ch = getopt(argc, argv, "A:B:b:E::e:F:f:iJ::L:mo:p:qtvx")) != -1) { switch (ch) { case 'f': fake_from = optarg; break; case 'F': msg.fromname = optarg; break; case 't': tflag = 1; break; case 'v': verbose = 1; break; /* all remaining: ignored, sendmail compat */ case 'A': case 'B': case 'b': case 'E': case 'e': case 'i': case 'L': case 'm': case 'o': case 'p': case 'x': break; case 'q': /* XXX: implement "process all now" */ return (0); default: usage(); } } argc -= optind; argv += optind; if (gethostname(host, sizeof(host)) == -1) err(1, "gethostname"); if ((pw = getpwuid(getuid())) == NULL) user = "******"; if (pw != NULL && (user = strdup(pw->pw_name)) == NULL) err(1, "strdup"); build_from(fake_from, pw); while(argc > 0) { rcpt_add(argv[0]); argv++; argc--; } signal(SIGALRM, sighdlr); alarm(300); fp = tmpfile(); if (fp == NULL) err(1, "tmpfile"); noheader = parse_message(stdin, fake_from == NULL, tflag, fp); if (msg.rcpt_cnt == 0) errx(1, "no recipients"); /* init session */ rewind(fp); if ((msg.fd = open_connection()) == -1) errx(1, "server too busy"); fout = fdopen(msg.fd, "a+"); if (fout == NULL) err(1, "fdopen"); /* * We need to call get_responses after every command because we don't * support PIPELINING on the server-side yet. */ /* banner */ get_responses(fout, 1); fprintf(fout, "EHLO localhost\n"); get_responses(fout, 1); fprintf(fout, "MAIL FROM: <%s>\n", msg.from); get_responses(fout, 1); for (i = 0; i < msg.rcpt_cnt; i++) { fprintf(fout, "RCPT TO: <%s>\n", msg.rcpts[i]); get_responses(fout, 1); } fprintf(fout, "DATA\n"); get_responses(fout, 1); /* add From */ if (!msg.saw_from) fprintf(fout, "From: %s%s<%s>\n", msg.fromname ? msg.fromname : "", msg.fromname ? " " : "", msg.from); /* add Date */ if (!msg.saw_date) fprintf(fout, "Date: %s\n", time_to_text(timestamp)); /* add Message-Id */ if (!msg.saw_msgid) fprintf(fout, "Message-Id: <%"PRIu64".enqueue@%s>\n", generate_uid(), host); if (msg.need_linesplit) { /* we will always need to mime encode for long lines */ if (!msg.saw_mime_version) fprintf(fout, "MIME-Version: 1.0\n"); if (!msg.saw_content_type) fprintf(fout, "Content-Type: text/plain; charset=unknown-8bit\n"); if (!msg.saw_content_disposition) fprintf(fout, "Content-Disposition: inline\n"); if (!msg.saw_content_transfer_encoding) fprintf(fout, "Content-Transfer-Encoding: quoted-printable\n"); } if (!msg.saw_user_agent) fprintf(fout, "User-Agent: OpenSMTPD enqueuer (Demoosh)\n"); /* add separating newline */ if (noheader) fprintf(fout, "\n"); else inheaders = 1; for (;;) { buf = fgetln(fp, &len); if (buf == NULL && ferror(fp)) err(1, "fgetln"); if (buf == NULL && feof(fp)) break; /* newlines have been normalized on first parsing */ if (buf[len-1] != '\n') errx(1, "expect EOL"); dotted = 0; if (buf[0] == '.') { fputc('.', fout); dotted = 1; } line = buf; if (msg.saw_content_transfer_encoding || noheader || inheaders || !msg.need_linesplit) { fprintf(fout, "%.*s", (int)len, line); if (inheaders && buf[0] == '\n') inheaders = 0; continue; } /* we don't have a content transfer encoding, use our default */ do { if (len < LINESPLIT) { qp_encoded_write(fout, line, len); break; } else { qp_encoded_write(fout, line, LINESPLIT - 2 - dotted); fprintf(fout, "=\n"); line += LINESPLIT - 2 - dotted; len -= LINESPLIT - 2 - dotted; } } while (len); } fprintf(fout, ".\n"); get_responses(fout, 1); fprintf(fout, "QUIT\n"); get_responses(fout, 1); fclose(fp); fclose(fout); exit(0); }
int enqueue(int argc, char *argv[]) { int i, ch, tflag = 0, noheader; char *fake_from = NULL, *buf; struct passwd *pw; FILE *fp, *fout; size_t len, envid_sz = 0; int fd; char sfn[] = "/tmp/smtpd.XXXXXXXXXX"; char *line; int dotted; int inheaders = 0; int save_argc; char **save_argv; memset(&msg, 0, sizeof(msg)); time(×tamp); save_argc = argc; save_argv = argv; while ((ch = getopt(argc, argv, "A:B:b:E::e:F:f:iJ::L:mN:o:p:qR:tvV:x")) != -1) { switch (ch) { case 'f': fake_from = optarg; break; case 'F': msg.fromname = optarg; break; case 'N': msg.dsn_notify = optarg; break; case 'R': msg.dsn_ret = optarg; break; case 't': tflag = 1; break; case 'v': verbose = 1; break; case 'V': msg.dsn_envid = optarg; break; /* all remaining: ignored, sendmail compat */ case 'A': case 'B': case 'b': case 'E': case 'e': case 'i': case 'L': case 'm': case 'o': case 'p': case 'x': break; case 'q': /* XXX: implement "process all now" */ return (EX_SOFTWARE); default: usage(); } } argc -= optind; argv += optind; if (getmailname(host, sizeof(host)) == -1) err(EX_NOHOST, "getmailname"); if ((user = getlogin()) != NULL && *user != '\0') pw = getpwnam(user); else if ((pw = getpwuid(getuid())) == NULL) user = "******"; user = xstrdup(pw ? pw->pw_name : user, "enqueue"); build_from(fake_from, pw); while (argc > 0) { rcpt_add(argv[0]); argv++; argc--; } if ((fd = mkstemp(sfn)) == -1 || (fp = fdopen(fd, "w+")) == NULL) { int saved_errno = errno; if (fd != -1) { unlink(sfn); close(fd); } errc(EX_UNAVAILABLE, saved_errno, "mkstemp"); } unlink(sfn); noheader = parse_message(stdin, fake_from == NULL, tflag, fp); if (msg.rcpt_cnt == 0) errx(EX_SOFTWARE, "no recipients"); /* init session */ rewind(fp); /* try to connect */ /* If the server is not running, enqueue the message offline */ if (!srv_connect()) return (enqueue_offline(save_argc, save_argv, fp)); if ((msg.fd = open_connection()) == -1) errx(EX_UNAVAILABLE, "server too busy"); fout = fdopen(msg.fd, "a+"); if (fout == NULL) err(EX_UNAVAILABLE, "fdopen"); /* * We need to call get_responses after every command because we don't * support PIPELINING on the server-side yet. */ /* banner */ get_responses(fout, 1); send_line(fout, verbose, "EHLO localhost\n"); get_responses(fout, 1); if (msg.dsn_envid != NULL) envid_sz = strlen(msg.dsn_envid); send_line(fout, verbose, "MAIL FROM:<%s> %s%s %s%s\n", msg.from, msg.dsn_ret ? "RET=" : "", msg.dsn_ret ? msg.dsn_ret : "", envid_sz ? "ENVID=" : "", envid_sz ? msg.dsn_envid : ""); get_responses(fout, 1); for (i = 0; i < msg.rcpt_cnt; i++) { send_line(fout, verbose, "RCPT TO:<%s> %s%s\n", msg.rcpts[i], msg.dsn_notify ? "NOTIFY=" : "", msg.dsn_notify ? msg.dsn_notify : ""); get_responses(fout, 1); } send_line(fout, verbose, "DATA\n"); get_responses(fout, 1); /* add From */ if (!msg.saw_from) send_line(fout, 0, "From: %s%s<%s>\n", msg.fromname ? msg.fromname : "", msg.fromname ? " " : "", msg.from); /* add Date */ if (!msg.saw_date) send_line(fout, 0, "Date: %s\n", time_to_text(timestamp)); /* add Message-Id */ if (!msg.saw_msgid) send_line(fout, 0, "Message-Id: <%"PRIu64".enqueue@%s>\n", generate_uid(), host); if (msg.need_linesplit) { /* we will always need to mime encode for long lines */ if (!msg.saw_mime_version) send_line(fout, 0, "MIME-Version: 1.0\n"); if (!msg.saw_content_type) send_line(fout, 0, "Content-Type: text/plain; " "charset=unknown-8bit\n"); if (!msg.saw_content_disposition) send_line(fout, 0, "Content-Disposition: inline\n"); if (!msg.saw_content_transfer_encoding) send_line(fout, 0, "Content-Transfer-Encoding: " "quoted-printable\n"); } /* add separating newline */ if (noheader) send_line(fout, 0, "\n"); else inheaders = 1; for (;;) { buf = fgetln(fp, &len); if (buf == NULL && ferror(fp)) err(EX_UNAVAILABLE, "fgetln"); if (buf == NULL && feof(fp)) break; /* newlines have been normalized on first parsing */ if (buf[len-1] != '\n') errx(EX_SOFTWARE, "expect EOL"); dotted = 0; if (buf[0] == '.') { fputc('.', fout); dotted = 1; } line = buf; if (msg.saw_content_transfer_encoding || noheader || inheaders || !msg.need_linesplit) { if (inheaders) send_header(fout, line, len); else send_line(fout, 0, "%.*s", (int)len, line); if (inheaders && buf[0] == '\n') inheaders = 0; continue; } /* we don't have a content transfer encoding, use our default */ do { if (len < LINESPLIT) { qp_encoded_write(fout, line, len); break; } else { qp_encoded_write(fout, line, LINESPLIT - 2 - dotted); send_line(fout, 0, "=\n"); line += LINESPLIT - 2 - dotted; len -= LINESPLIT - 2 - dotted; } } while (len); } send_line(fout, verbose, ".\n"); get_responses(fout, 1); send_line(fout, verbose, "QUIT\n"); get_responses(fout, 1); fclose(fp); fclose(fout); exit(EX_OK); }
int parse(char*toParse, char*ret_buffer, char**uid) { char command = -1, *pCur, *pPrev; int ix, Bound = TK__LAST; taim_session *ses; pCur = toParse; for(ix = 0; ix < Bound; ix++) { if(!strncmp(pCur, g_commands[ix], strlen(g_commands[ix]))) { command = ix; pCur += strlen(g_commands[ix]); break; } } switch(command) { case TK_UID: if(*pCur == ' ') { pCur++; pPrev = pCur; while(*pCur > 32) { pCur ++; } *uid = (char*) malloc(pCur - pPrev); memcpy(*uid, pPrev, pCur - pPrev); (*uid)[pCur - pPrev] = 0; } else { *uid = 0; do { if(*uid != 0) { free(*uid); } *uid = (char*) malloc(KEY_LENGTH + 1); memcpy(*uid, generate_uid(), KEY_LENGTH); } while(uid_addsession(*uid) == 0); } memcpy(ret_buffer, *uid, strlen(*uid)); sprintf(ret_buffer + strlen(*uid) + 1, "\n"); return RET_NODATA; break; case TK_USER: pCur++; pPrev = pCur; while(*pCur > 32 ) { pCur++; } *uid = (char*)malloc(pCur - pPrev + 1); memcpy(*uid, pPrev, pCur - pPrev); (*uid)[pCur - pPrev] = 0; ses = uid_find(*uid); pCur ++; { char *username = pCur; for( ix = 0; username[ix] > ' '; ix++); username[ix] = 0; GList *iter = purple_plugins_get_protocols(); PurplePlugin *plugin = iter->data; PurplePluginInfo *info = plugin->info; printf("<%x>", (unsigned int)ses); fflush(0); if(ses->pses->account == 0) { taim_new_account(ses); } d(username); ses->pses->account->account = purple_account_new(username, info->id); } return RET_NODATA; break; case TK_PASS: pCur++; pPrev = pCur; while(*pCur > 32 ) { pCur++; } *uid = (char*)malloc(pCur - pPrev + 1); memcpy(*uid, pPrev, pCur - pPrev); (*uid)[pCur - pPrev] = 0; pCur ++; ses = uid_find(*uid); { PurpleSavedStatus *status; char *password = pCur, hash[20]; for(ix = 0; password[ix] > ' '; ix++); password[ix] = 0; if(ses->pses->account->hash_have == 1) { // See if the hashes match if(!memcmp(SHA1(password, strlen(password), hash), ses->pses->account->hash, 20)) { // If so, then bond the stuff } else // Otherwise, try to auth anyway { strcpy(ses->pses->account->password_try, password); } purple_account_set_password(ses->pses->account->account, password); purple_account_set_enabled(ses->pses->account->account, UI_ID, TRUE); // Either way, this password is replaced with the new one } else { strcpy(ses->pses->account->password_try, password); purple_account_set_password(ses->pses->account->account, password); purple_account_set_enabled(ses->pses->account->account, UI_ID, TRUE); } // Now, to connect the account(s), create a status and activate it. status = purple_savedstatus_new(NULL, PURPLE_STATUS_AVAILABLE); purple_savedstatus_activate(status); pthread_mutex_unlock(&g_mutex_init); } return RET_NODATA; break; case TK_GET: pCur++; pPrev = pCur; while(*pCur > 32 ) { pCur++; } *uid = (char*)malloc(pCur - pPrev + 1); memcpy(*uid, pPrev, pCur - pPrev); (*uid)[pCur - pPrev] = 0; pCur ++; if((*uid)[0]) { d(*uid); drecurse(g_blist->root, *uid); return RET_DATA; } else { return RET_NODATA; } break; case TK_SEND: pCur++; pPrev = pCur; while(*pCur > 32 ) { pCur++; } *uid = (char*)malloc(pCur - pPrev + 1); memcpy(*uid, pPrev, pCur - pPrev); (*uid)[pCur - pPrev] = 0; pCur ++; pCur[strlen(pCur) - 1] = 0; taim_send(pCur, *uid, ret_buffer); return RET_NODATA; break; case TK_QUIT: do_exit(); break; default: return RET_ERROR; // unknown command break; } return RET_ERROR; }