// -1 = bad, 0 = ok int cpop3_quit(CLOG_INFO* log, CPOP3* pop3) { int rval = 0; char msg[1024] = {0}; char *pmsg=msg; int plen=0; clog(log, CTRACE, "cpop3_quit(): quitting"); if(6==csocket_write(log, pop3->sock, "QUIT\r\n", 6)) { while(NULL==strstr(msg, "\n") && plen<(1023)) { rval=csocket_read(log, pop3->sock, pmsg+plen, 1023-plen); if(0>rval) { // ERROR! rval = -1; break; } if(0==rval) { break; } plen += rval; } if(0<=rval) { rval = cpop3_iserror(log, (char*)msg); } clog(log, CDEBUG, "cpop3_quit(): finished quitting"); } else { clog(log, CERROR, "cpop3_quit(): could not write all chars to server"); rval = -1; } return rval; }
// -1 = bad, 0 = ok int cpop3_user(CLOG_INFO* log, CPOP3* pop3, char *user) { char msg[1024]={0}; int length=0; int rval = 0; char * sendbuf = NULL; char *pmsg=msg; int plen=0; clog(log, CTRACE, "cpop3_user(): sending user"); if(NULL==pop3 || NULL==user) { clog(log, CERROR, "cpop3_user(): pop3 struct or user was NULL"); return -1; } length = strlen(user); sendbuf = (char*) malloc(8 + length); if(NULL==sendbuf) { clog(log, CERROR, "cpop3_user(): malloc returned NULL, could not allocate memory"); return -1; } memset(sendbuf, 0, (8 + length)); memcpy(sendbuf, "USER ", 5); memcpy(sendbuf + strlen(sendbuf), user, length); memcpy(sendbuf + strlen(sendbuf), "\r\n", 2); length = strlen(sendbuf); if(length == csocket_write(log, pop3->sock, sendbuf, length)) { while(NULL==strstr(msg, "\n") && plen<1023) { rval=csocket_read(log, pop3->sock, pmsg+plen, 1023-plen); if(0>rval) { // ERROR! rval = -1; break; } if(0==rval) { break; } plen+=rval; } if(0<=rval) { rval = cpop3_iserror(log, (char*)msg); } clog(log, CDEBUG, "cpop3_user(): finished sending user"); } else { clog(log, CERROR, "cpop3_user(): could not write all chars to server"); rval = -1; } memset(sendbuf, 0, strlen(sendbuf)); free(sendbuf); sendbuf = NULL; return rval; }
bool Client::HandleCharacterCreatePacket(const EQApplicationPacket *app) { if (GetAccountID() == 0) { clog(WORLD__CLIENT_ERR,"Account ID not set; unable to create character."); return false; } else if (app->size != sizeof(CharCreate_Struct)) { clog(WORLD__CLIENT_ERR,"Wrong size on OP_CharacterCreate. Got: %d, Expected: %d",app->size,sizeof(CharCreate_Struct)); DumpPacket(app); // the previous behavior was essentially returning true here // but that seems a bit odd to me. return true; } CharCreate_Struct *cc = (CharCreate_Struct*)app->pBuffer; if(OPCharCreate(char_name, cc) == false) { database.DeleteCharacter(char_name); EQApplicationPacket *outapp = new EQApplicationPacket(OP_ApproveName, 1); outapp->pBuffer[0] = 0; QueuePacket(outapp); safe_delete(outapp); } else { SendCharInfo(); } return true; }
std::function<float(const std::string&)> layerSearch(TextureArray &array){ return [&](const std::string &name){ clog("looking for:", name); float i = 0.f; for(const auto &it : array.content){ clog("\t", it); if(name == it) return i; i += 1.f; } return 0.f; }; }
/* void cxml_node_free(CLOG_INFO* info, void * data) { CXMLNODE *node = (CXMLNODE*) data; */ void cxml_node_free(CLOG_INFO* info, CXMLNODE **node) { dnode_t *dn = NULL; if(NULL==node || NULL==*node) { return; } clog( info, CTRACE, "XML: xml_node_free(), free the attributes"); // free the attributes if(NULL!=(*node)->att) { if(!dict_isempty((*node)->att)) { for (dn = dict_first((*node)->att); dn; dn = dict_next((*node)->att, dn)) { char *key=(char*)dnode_getkey(dn); char *data=(char*)dnode_get(dn); if(NULL!=key) free(key); key=NULL; if(NULL!=data) free(data); data=NULL; } } dict_free_nodes((*node)->att); dict_destroy((*node)->att); (*node)->att=NULL; } clog( info, CTRACE, "XML: xml_node_free(), free the name"); // free the name if(NULL!=(*node)->name) cstring_free(&((*node)->name)); clog( info, CTRACE, "XML: xml_node_free(), free the data"); // free the data if(NULL!=(*node)->data) cstring_free(&((*node)->data)); clog( info, CTRACE, "XML: xml_node_free(), free the subs"); // free the children if(NULL!=(*node)->sub) { if(!dict_isempty((*node)->sub)) { for (dn = dict_first((*node)->sub); dn; dn = dict_next((*node)->sub, dn)) { char *key=(char*)dnode_getkey(dn); CXMLNODE *data=(CXMLNODE*)dnode_get(dn); if(NULL!=key) free(key); key=NULL; cxml_node_free(info, &data); } } dict_free_nodes((*node)->sub); dict_destroy((*node)->sub); (*node)->sub=NULL; } free((*node)); (*node)=NULL; node=NULL; }
bool Client::Process() { bool ret = true; //bool sendguilds = true; sockaddr_in to; memset((char *) &to, 0, sizeof(to)); to.sin_family = AF_INET; to.sin_port = port; to.sin_addr.s_addr = ip; if (autobootup_timeout.Check()) { clog(WORLD__CLIENT_ERR, "Zone bootup timer expired, bootup failed or too slow."); ZoneUnavail(); } if(connect.Check()){ SendGuildList();// Send OPCode: OP_GuildsList SendApproveWorld(); connect.Disable(); } if (CLE_keepalive_timer.Check()) { if (cle) cle->KeepAlive(); } /************ Get all packets from packet manager out queue and process them ************/ EQApplicationPacket *app = 0; while(ret && (app = (EQApplicationPacket *)eqs->PopPacket())) { ret = HandlePacket(app); delete app; } if (!eqs->CheckState(ESTABLISHED)) { if(WorldConfig::get()->UpdateStats){ ServerPacket* pack = new ServerPacket; pack->opcode = ServerOP_LSPlayerLeftWorld; pack->size = sizeof(ServerLSPlayerLeftWorld_Struct); pack->pBuffer = new uchar[pack->size]; memset(pack->pBuffer,0,pack->size); ServerLSPlayerLeftWorld_Struct* logout =(ServerLSPlayerLeftWorld_Struct*)pack->pBuffer; strcpy(logout->key,GetLSKey()); logout->lsaccount_id = GetLSID(); loginserverlist.SendPacket(pack); safe_delete(pack); } clog(WORLD__CLIENT,"Client disconnected (not active in process)"); return false; } return ret; }
bool Client::HandleNameApprovalPacket(const EQApplicationPacket *app) { if (GetAccountID() == 0) { clog(WORLD__CLIENT_ERR,"Name approval request with no logged in account"); return false; } snprintf(char_name, 64, "%s", (char*)app->pBuffer); uchar race = app->pBuffer[64]; uchar clas = app->pBuffer[68]; clog(WORLD__CLIENT, "Name approval request. Name=%s, race=%s, class=%s", char_name, GetRaceName(race), GetEQClassName(clas)); EQApplicationPacket *outapp; outapp = new EQApplicationPacket; outapp->SetOpcode(OP_ApproveName); outapp->pBuffer = new uchar[1]; outapp->size = 1; clog(WORLD__CLIENT, "common/client.cpp line 292 pass"); bool valid = false; if (!database.CheckNameFilter(char_name)) { clog(WORLD__CLIENT, "Invalid name"); valid = false; } /* Name must begin with an upper-case letter. */ else if (islower(char_name[0])) { clog(WORLD__CLIENT, "Must begin with uppercase"); valid = false; } else if (database.ReserveName(GetAccountID(), char_name)) { clog(WORLD__CLIENT, "common/client.cpp line 304 pass"); valid = true; } else { clog(WORLD__CLIENT, "common/client.cpp line 308 pass"); valid = false; } clog(WORLD__CLIENT, "common/client.cpp line 312 pass"); outapp->pBuffer[0] = valid? 1 : 0; QueuePacket(outapp); safe_delete(outapp); clog(WORLD__CLIENT, "common/client.cpp line 316 pass"); if (!valid) memset(char_name, 0, sizeof(char_name)); clog(WORLD__CLIENT, "common/client.cpp line 320 pass"); return true; }
static void setup_idt() { extern void th_divide(); extern void th_debug(); extern void th_nmi(); extern void th_brkpt(); extern void th_oflow(); extern void th_bound(); extern void th_illop(); extern void th_device(); extern void th_dblflt(); //extern void th_coproc(); extern void th_tss(); extern void th_segnp(); extern void th_stack(); extern void th_gpflt(); extern void th_pgflt(); //extern void th_res(); extern void th_fperr(); extern void th_align(); extern void th_mchk(); extern void th_simderr(); extern void th_syscall(); //extern void th_default(); clog("th_divide = %p", th_divide); clog("th_syscall = %p", th_syscall); SETGATE(idt[T_DIVIDE], 1, GD_KT, th_divide, 0); SETGATE(idt[T_DEBUG], 1, GD_KT, th_debug, 0); SETGATE(idt[T_NMI], 0, GD_KT, th_nmi, 0); SETGATE(idt[T_BRKPT], 1, GD_KT, th_brkpt, 3); SETGATE(idt[T_OFLOW], 1, GD_KT, th_oflow, 0); SETGATE(idt[T_BOUND], 1, GD_KT, th_bound, 0); SETGATE(idt[T_ILLOP], 1, GD_KT, th_illop, 0); SETGATE(idt[T_DEVICE], 1, GD_KT, th_device, 0); SETGATE(idt[T_DBLFLT], 1, GD_KT, th_dblflt, 0); // SETGATE(idt[T_COPROC], 1, GD_KT, th_coproc, 0); SETGATE(idt[T_TSS], 1, GD_KT, th_tss, 0); SETGATE(idt[T_SEGNP], 1, GD_KT, th_segnp, 0); SETGATE(idt[T_STACK], 1, GD_KT, th_stack, 0); SETGATE(idt[T_GPFLT], 1, GD_KT, th_gpflt, 0); SETGATE(idt[T_PGFLT], 1, GD_KT, th_pgflt, 0); // SETGATE(idt[T_RES], 1, GD_KT, th_res, 0); SETGATE(idt[T_FPERR], 1, GD_KT, th_fperr, 0); SETGATE(idt[T_ALIGN], 1, GD_KT, th_align, 0); SETGATE(idt[T_MCHK], 1, GD_KT, th_mchk, 0); SETGATE(idt[T_SIMDERR], 1, GD_KT, th_simderr, 0); SETGATE(idt[T_SYSCALL], 1, GD_KT, th_syscall, 3); // SETGATE(idt[T_DEFAULT], 1, GD_KT, th_default, 0); }
static int mntmnt(int n, Rpccall *cmd, Rpccall *reply) { int i; char dom[64]; uchar *argptr = cmd->args; uchar *dataptr = reply->results; Authunix au; Xfile *xp; String root; chat("mntmnt...\n"); if(n < 8) return garbage(reply, "n too small"); argptr += string2S(argptr, &root); if(argptr != &((uchar *)cmd->args)[n]) return garbage(reply, "bad count"); clog("host=%I, port=%ld, root=\"%.*s\"...", cmd->host, cmd->port, utfnlen(root.s, root.n), root.s); if(auth2unix(&cmd->cred, &au) != 0){ chat("auth flavor=%ld, count=%ld\n", cmd->cred.flavor, cmd->cred.count); for(i=0; i<cmd->cred.count; i++) chat(" %.2ux", ((uchar *)cmd->cred.data)[i]); chat("\n"); clog("auth: bad credentials"); return error(reply, 1); } clog("auth: %ld %.*s u=%ld g=%ld", au.stamp, utfnlen(au.mach.s, au.mach.n), au.mach.s, au.uid, au.gid); for(i=0; i<au.gidlen; i++) chat(", %ld", au.gids[i]); chat("..."); if(getdom(cmd->host, dom, sizeof(dom))<0){ clog("auth: unknown ip address"); return error(reply, 1); } chat("dom=%s...", dom); xp = xfroot(root.s, root.n); if(xp == 0){ chat("xp=0..."); clog("mntmnt: no fs"); return error(reply, 3); } PLONG(0); dataptr += xp2fhandle(xp, dataptr); chat("OK\n"); return dataptr - (uchar *)reply->results; }
/* * parse user's cron file * other lines: minute hour monthday month weekday host command */ Job * readjobs(char *file, User *user) { Biobuf *b; Job *j, *jobs; Dir *d; int line; d = dirstat(file); if(!d) return nil; b = Bopen(file, OREAD); if(!b){ free(d); return nil; } jobs = nil; user->lastqid = d->qid; free(d); for(line = 1; savec = Brdline(b, '\n'); line++){ savec[Blinelen(b) - 1] = '\0'; while(*savec == ' ' || *savec == '\t') savec++; if(*savec == '#' || *savec == '\0') continue; if(strlen(savec) > 1024){ clog("%s: line %d: line too long", user->name, line); continue; } j = emalloc(sizeof *j); j->time.min = gettime(0, 59); if(j->time.min && (j->time.hour = gettime(0, 23)) && (j->time.mday = gettime(1, 31)) && (j->time.mon = gettime(1, 12)) && (j->time.wday = gettime(0, 6)) && getname(&j->host)){ j->cmd = emalloc(strlen(savec) + 1); strcpy(j->cmd, savec); j->next = jobs; jobs = j; }else{ clog("%s: line %d: syntax error", user->name, line); free(j); } } Bterm(b); return jobs; }
static int chanintr(Ctlr *ctlr, int n) { Hostchan *hc; int i; hc = &ctlr->regs->hchan[n]; if(ctlr->debugchan & (1<<n)) clog(nil, hc); if((hc->hcsplt & Spltena) == 0) return 0; i = hc->hcint; if(i == (Chhltd|Ack)){ hc->hcsplt |= Compsplt; ctlr->splitretry = 0; }else if(i == (Chhltd|Nyet)){ if(++ctlr->splitretry >= 3) return 0; }else return 0; if(hc->hcchar & Chen){ iprint("hcchar %8.8ux hcint %8.8ux", hc->hcchar, hc->hcint); hc->hcchar |= Chen | Chdis; while(hc->hcchar&Chen) ; iprint(" %8.8ux\n", hc->hcint); } hc->hcint = i; if(ctlr->regs->hfnum & 1) hc->hcchar &= ~Oddfrm; else hc->hcchar |= Oddfrm; hc->hcchar = (hc->hcchar &~ Chdis) | Chen; return 1; }
int getname(char **namep) { int c; char buf[64], *p; if(!savec) return 0; while(*savec == ' ' || *savec == '\t') savec++; for(p = buf; (c = *savec) && c != ' ' && c != '\t'; p++){ if(p >= buf+sizeof buf -1) return 0; *p = *savec++; } *p = '\0'; *namep = strdup(buf); if(*namep == 0){ clog("internal error: strdup failure"); _exits(0); } while(*savec == ' ' || *savec == '\t') savec++; return p > buf; }
int main (void) { double complex z = clog (I); // r = 1, θ = pi/2 printf ("2*log(i) = %.1f%+fi\n", creal (2 * z), cimag (2 * z)); double complex z2 = clog (sqrt (2) / 2 + sqrt (2) / 2 * I); // r = 1, θ = pi/4 printf ("4*log(sqrt(2)/2+sqrt(2)i/2) = %.1f%+fi\n", creal (4 * z2), cimag (4 * z2)); double complex z3 = clog (-1); // r = 1, θ = pi printf ("log(-1+0i) = %.1f%+fi\n", creal (z3), cimag (z3)); double complex z4 = clog (conj (-1)); // or clog(CMPLX(-1, -0.0)) in C11 printf ("log(-1-0i) (the other side of the cut) = %.1f%+fi\n", creal (z4), cimag (z4)); return 0; }
int main( int argc, char *argv[] ) { layout_t *lt, *lt2, *lt3, *lt4; bounds_t *b; object_t *rg, *btn, *fr; claro_base_init( ); claro_graphics_init( ); log_fd_set_level( CL_DEBUG, stderr ); clog( CL_INFO, "%s running using Claro!", __FILE__ ); b = new_bounds( 100, 100, 460, 230 ); w = window_widget_create( 0, b, 0 ); object_addhandler( w, "destroy", window_closed ); window_set_title( w, "Radio button example" ); lt = layout_create( w, "[][_<|set1|<|set3|<][][_<|set2|<|set4|<][]", *b, 10, 10 ); /* create a frame */ b = lt_bounds(lt,"set1"); fr = frame_widget_create_with_label( w, b, 0, "Group 1" ); lt2 = layout_create( fr, "[r1][r2][r3][_]", *b, 20, 20 ); rg = radiogroup_create( fr, 0 ); btn = radiobutton_widget_create( fr, rg, lt_bounds(lt2,"r1"), "Button 1", 0 ); btn = radiobutton_widget_create( fr, rg, lt_bounds(lt2,"r2"), "Button 2", 0 ); btn = radiobutton_widget_create( fr, rg, lt_bounds(lt2,"r3"), "Button 3", 0 ); /* create a frame */ b = lt_bounds(lt,"set2"); fr = frame_widget_create_with_label( w, b, 0, "Group 2" ); lt3 = layout_create( fr, "[r1][r2][r3][_]", *b, 20, 20 ); rg = radiogroup_create( fr, 0 ); btn = radiobutton_widget_create( fr, rg, lt_bounds(lt3,"r1"), "Button 1", 0 ); btn = radiobutton_widget_create( fr, rg, lt_bounds(lt3,"r2"), "Button 2", 0 ); btn = radiobutton_widget_create( fr, rg, lt_bounds(lt3,"r3"), "Button 3", 0 ); /* create a frame */ b = lt_bounds(lt,"set3"); fr = frame_widget_create_with_label( w, b, 0, "Group 3" ); lt4 = layout_create( fr, "[r1][r2][r3][_]", *b, 20, 20 ); btn = checkbox_widget_create_with_label( fr, lt_bounds(lt4,"r1"), 0, "Button 1" ); btn = checkbox_widget_create_with_label( fr, lt_bounds(lt4,"r2"), 0, "Button 2" ); btn = checkbox_widget_create_with_label( fr, lt_bounds(lt4,"r3"), 0, "Button 3" ); window_show( w ); window_focus( w ); block_heap_loginfo( ); claro_loop( ); return 0; }
/** * Prints Microsoft specific error messages to log */ static void mserror(const char *str) { char errbuf[300]; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, errbuf, sizeof(errbuf), NULL); clog(0, 0, "%s: (0x%08X) %s", str, GetLastError(), errbuf); }
void idt_init(void) { extern struct Segdesc gdt[]; // LAB 3: Your code here. assert(sizeof(struct Gatedesc) == SZ_GATEDESC); assert(sizeof(struct Pseudodesc) == SZ_PSEUDODESC); assert(sizeof(struct Trapframe) == SIZEOF_STRUCT_TRAPFRAME); clog("idt_pd = %u, %p", idt_pd.pd_lim, idt_pd.pd_base); //print_idt(idt); setup_idt(); //print_idt(idt); // Setup a TSS so that we get the right stack // when we trap to the kernel. ts.ts_esp0 = KSTACKTOP; ts.ts_ss0 = GD_KD; // Initialize the TSS field of the gdt. gdt[GD_TSS >> 3] = SEG16(STS_T32A, (uint32_t) (&ts), sizeof(struct Taskstate), 0); gdt[GD_TSS >> 3].sd_s = 0; // Load the TSS ltr(GD_TSS); // Load the IDT asm volatile("lidt idt_pd"); }
bool RenderShader::compileShader( GLuint shader, const std::string& source ) { Logger log = getLogger( package + ".compileShader" ); const char* src = source.c_str(); glShaderSource( shader, 1, &src, NULL ); glCompileShader( shader ); GLint status; glGetShaderiv( shader, GL_COMPILE_STATUS, &status ); GLint loglength; glGetShaderiv( shader, GL_INFO_LOG_LENGTH, &loglength ); if( (status != GL_TRUE) || (loglength>1) ) { RL_LOG_ERROR( log, "shader source:" << std::endl << source ); } if( loglength > 1 ) { std::vector<GLchar> clog( loglength ); glGetShaderInfoLog( shader, loglength, NULL, &clog[0] ); RL_LOG_ERROR( log, "compilation log:" << std::endl << &clog[0] ); } if( status != GL_TRUE ) { RL_LOG_ERROR( log, "Compilation failed" ); } CHECK_GL; return status == GL_TRUE; }
void Client::QueuePacket(const EQApplicationPacket* app, bool ack_req) { clog(WORLD__CLIENT_TRACE, "Sending EQApplicationPacket OpCode 0x%04x",app->GetOpcode()); _pkt(WORLD__CLIENT_TRACE, app); ack_req = true; // It's broke right now, dont delete this line till fix it. =P eqs->QueuePacket(app, ack_req); }
//## Complex Complex.clogl(); static KMETHOD Complex_clogl(KonohaContext *kctx, KonohaStack *sfp) { kComplex *kc = (kComplex *) sfp[0].asObject; long double _Complex zl = (long double _Complex)kc->z; long double ret = clog(zl); KReturnFloatValue(ret); }
//## Complex Complex.clogf(); static KMETHOD Complex_clogf(KonohaContext *kctx, KonohaStack *sfp) { kComplex *kc = (kComplex *) sfp[0].asObject; float _Complex zf = (float _Complex)kc->z; float ret = clog(zf); KReturnFloatValue(ret); }
Fid * newfid(Session *s) { Fid *f, *fN; chat("newfid.."); if(s->list.prev == 0){ chat("init.."); s->list.prev = &s->list; s->list.next = &s->list; s->free = s->fids; if(0 && chatty) fN = &s->fids[25]; else fN = &s->fids[nelem(s->fids)]; for(f=s->fids; f<fN; f++){ f->owner = 0; f->prev = 0; f->next = f+1; } (f-1)->next = 0; } if(s->free){ f = s->free; s->free = f->next; LINK(&s->list, f); }else{ for(f=s->list.prev; f!=&s->list; f=f->prev) if(f->owner) break; if(f == &s->list){ clog("fid leak"); return 0; } setfid(s, f); if(xmesg(s, Tclunk) < 0){ clog("clunk failed, no fids?"); /*return 0;*/ } *(f->owner) = 0; f->owner = 0; } chat("%ld...", f - s->fids); f->tstale = nfstime + staletime; return f; }
/* debug calloc: scalloc() with memory management */ void *d_calloc( size_t elsize, size_t els ) { void *p = scalloc( elsize, els ); clog( CL_DEBUG, "scalloc(%d,%d) -> %p", elsize, els, p ); return p; }
/* debug malloc: smalloc() with memory management */ void *d_malloc( size_t size ) { void *p = smalloc( size ); clog( CL_DEBUG, "smalloc(%d) -> %p", size, p ); return p; }
/* debug realloc: srealloc() with memory management */ void *d_realloc( void *oldptr, size_t newsize ) { void *p = srealloc( oldptr, newsize ); clog( CL_DEBUG, "srealloc(%p,%d) -> %p", oldptr, newsize, p ); return p; }
double complex casin(double complex z) { double complex w; double x, y; x = creal(z); y = cimag(z); w = CMPLX(1.0 - (x - y) * (x + y), -2.0 * x * y); return clog(CMPLX(-y, x) + csqrt(w)); }
void init_dlink_nodes(void) { node_heap = BlockHeapCreate(sizeof(node_t), HEAP_NODE); if (!node_heap) { clog(LG_INFO, "init_dlink_nodes(): block allocator failure."); exit(EXIT_FAILURE); } }
void Client::SendGuildList() { EQApplicationPacket *outapp; outapp = new EQApplicationPacket(OP_GuildsList); //ask the guild manager to build us a nice guild list packet OldGuildsList_Struct* guildstruct = guild_mgr.MakeOldGuildList(outapp->size); outapp->pBuffer = reinterpret_cast<uchar*>(guildstruct); //safe_delete_array(guildstruct); if(outapp->pBuffer == nullptr) { clog(GUILDS__ERROR, "Unable to make guild list!"); return; } clog(GUILDS__OUT_PACKETS, "Sending OP_GuildsList of length %d", outapp->size); _pkt(GUILDS__OUT_PACKET_TRACE, outapp); eqs->FastQueuePacket((EQApplicationPacket **)&outapp); }
bool Client::HandleNameApprovalPacket(const EQApplicationPacket *app) { if (GetAccountID() == 0) { clog(WORLD__CLIENT_ERR,"Name approval request with no logged in account"); return false; } snprintf(char_name, 64, "%s", (char*)app->pBuffer); uchar race = app->pBuffer[64]; uchar clas = app->pBuffer[68]; clog(WORLD__CLIENT,"Name approval request. Name=%s, race=%s, class=%s",char_name,GetRaceName(race),GetEQClassName(clas)); EQApplicationPacket *outapp; outapp = new EQApplicationPacket; outapp->SetOpcode(OP_ApproveName); outapp->pBuffer = new uchar[1]; outapp->size = 1; bool valid; if(!database.CheckNameFilter(char_name)) { valid = false; } else if(char_name[0] < 'A' && char_name[0] > 'Z') { //name must begin with an upper-case letter. valid = false; } else if (database.ReserveName(GetAccountID(), char_name)) { valid = true; } else { valid = false; } outapp->pBuffer[0] = valid? 1 : 0; QueuePacket(outapp); safe_delete(outapp); if(!valid) { memset(char_name, 0, sizeof(char_name)); } return true; }
// returns success (not 0) and failure (-1) int csocket_connect(CLOG_INFO* log, CSOCKET* sock) { int r=0; clog(log, CTRACE, "csocket_connect(): trying to connect"); r=connect( sock->socket, (struct sockaddr*)&(sock->sa), sizeof(struct sockaddr_in) ); if(r!=0){ clog_perror(log, CERROR, "csocket_connect()::connect()"); return -1; } clog(log, CDEBUG, "csocket_connect(): connection was successful"); return 0; }
int cxml_node_addnode(CLOG_INFO* info, CXMLNODE *parent, CXMLNODE *child) { int return_value=0; assert(NULL!=parent); assert(NULL!=child); // if the sub node is NULL create a new sub table if(NULL==parent->sub) { clog( info, CTRACE, "XML: xml_node_addnode(), creating sub node"); parent->sub = dict_create(DICTCOUNT_T_MAX, (dict_comp_t)strcmp); // allow duplicates dict_allow_dupes(parent->sub); } // if the previous stuff worked, add the name/value pair if(NULL!=parent->sub && NULL!=child->name && NULL!=child->name->string) { dnode_t *node = (parent->sub)->dict_allocnode((parent->sub)->dict_context); char *key = strdup(child->name->string); clog( info, CTRACE, "XML: xml_node_adddata(), Saving sub node name=\"%.80s\"", child->name->string); if (node) { dnode_init(node, child); dict_insert(parent->sub, node, key); // let the child know who they are child->me = node; // success! return_value=1; } } // let the child know whow their parent is if(NULL!=parent && NULL!=child) { child->parent = parent; } return return_value; }