static t_mailbox * mailbox_open(t_account * user, t_mbox_mode mode) { t_mailbox * rez; char * path; char const * maildir; rez=xmalloc(sizeof(t_mailbox)); maildir=prefs_get_maildir(); if (mode & mbox_mode_write) p_mkdir(maildir,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); path=xmalloc(strlen(maildir)+1+8+1); if (maildir[0]!='\0' && maildir[strlen(maildir)-1]=='/') sprintf(path,"%s%06u",maildir,account_get_uid(user)); else sprintf(path,"%s/%06u",maildir,account_get_uid(user)); if (mode & mbox_mode_write) p_mkdir(path,S_IRWXU | S_IXGRP | S_IRGRP | S_IROTH | S_IXOTH); if ((rez->maildir=p_opendir(path))==NULL) { if (mode & mbox_mode_write) eventlog(eventlog_level_error,__FUNCTION__,"error opening maildir"); xfree(path); xfree(rez); return NULL; } rez->uid=account_get_uid(user); rez->path=path; return rez; }
static int on_client_createcharreq(t_connection * c, t_packet * packet) { t_packet * rpacket, * bnpacket; char const * charname; char const * account; char * path; t_pdir * dir; t_sq * sq; unsigned int reply; unsigned short status, class; t_d2charinfo_file data; if (!(charname=packet_get_str_const(packet,sizeof(t_client_d2cs_createcharreq),MAX_CHARNAME_LEN))) { eventlog(eventlog_level_error,__FUNCTION__,"got bad character name"); return -1; } if (!(account=d2cs_conn_get_account(c))) { eventlog(eventlog_level_error,__FUNCTION__,"missing account for character %s",charname); return -1; } class=bn_short_get(packet->u.client_d2cs_createcharreq.class); status=bn_short_get(packet->u.client_d2cs_createcharreq.status); path=xmalloc(strlen(prefs_get_charinfo_dir())+1+strlen(account)+1); d2char_get_infodir_name(path,account); if (!(dir=p_opendir(path))) { eventlog(eventlog_level_info,__FUNCTION__,"(*%s) charinfo directory do not exist, building it",account); p_mkdir(path,S_IRWXU); } else p_closedir(dir); xfree(path); if (d2char_create(account,charname,class,status)<0) { eventlog(eventlog_level_warn,__FUNCTION__,"error create character %s for account %s",charname,account); reply=D2CS_CLIENT_CREATECHARREPLY_ALREADY_EXIST; } else if (d2charinfo_load(account,charname,&data)<0) {