qbool Info_Convert(ctxinfo_t *ctx, char *str) { char name[MAX_INFO_KEY], value[MAX_INFO_KEY], *start; if (!ctx) return false; for ( ; str && str[0]; ) { if (!(str = strchr(str, '\\'))) break; start = str; // start of name if (!(str = strchr(start + 1, '\\'))) // end of name break; strlcpy(name, start + 1, min(str - start, (int)sizeof(name))); start = str; // start of value str = strchr(start + 1, '\\'); // end of value strlcpy(value, start + 1, str ? min(str - start, (int)sizeof(value)) : (int)sizeof(value)); Info_Set(ctx, name, value); } return true; }
void infotest_f(void) { int i, j, cnt = atoi(Cmd_Argv(1)); char name[MAX_INFO_KEY], value[MAX_INFO_KEY]; for (i = 0; i < cnt; i++) { for (j = 0; j < MAX_INFO_KEY; j++) name[j] = 'a' + rand() % ('z' - 'a'); name[MAX_INFO_KEY-1] = 0; for (j = 0; j < MAX_INFO_KEY; j++) value[j] = 'a' + rand() % ('z' - 'a'); value[MAX_INFO_KEY-1] = 0; Info_Set(&g_ctx, name, value); } }
void SV_ParseLogin(client_t *cl) { extern cvar_t sv_forcenick; char *log1, *pass; if (Cmd_Argc() > 2) { log1 = Cmd_Argv(1); pass = Cmd_Argv(2); } else { // bah usually whole text in 'say' is put into "" log1 = pass = Cmd_Argv(1); while (*pass && *pass != ' ') pass++; if (*pass) *pass++ = 0; while (*pass == ' ') pass++; } // if login is parsed, we read just a password if (cl->login[0]) { pass = log1; log1 = cl->login; } else { strlcpy(cl->login, log1, CLIENT_LOGIN_LEN); } if (!*pass) { strlcpy(cl->login, log1, CLIENT_LOGIN_LEN); MSG_WriteByte (&cl->netchan.message, svc_print); MSG_WriteByte (&cl->netchan.message, PRINT_HIGH); MSG_WriteString (&cl->netchan.message, va("Password for %s:\n", cl->login)); return; } cl->logged = checklogin(log1, pass, cl - svs.clients + 1, use_log); switch (cl->logged) { case -2: MSG_WriteByte (&cl->netchan.message, svc_print); MSG_WriteByte (&cl->netchan.message, PRINT_HIGH); MSG_WriteString (&cl->netchan.message, "Login blocked\n"); cl->logged = 0; cl->login[0] = 0; break; case -1: MSG_WriteByte (&cl->netchan.message, svc_print); MSG_WriteByte (&cl->netchan.message, PRINT_HIGH); MSG_WriteString (&cl->netchan.message, "Login in use!\ntry again:\n"); cl->logged = 0; cl->login[0] = 0; break; case 0: MSG_WriteByte (&cl->netchan.message, svc_print); MSG_WriteByte (&cl->netchan.message, PRINT_HIGH); MSG_WriteString (&cl->netchan.message, va("Access denied\nPassword for %s:\n", cl->login)); break; default: Sys_Printf("%s logged in as %s\n", cl->name, cl->login); MSG_WriteByte (&cl->netchan.message, svc_print); MSG_WriteByte (&cl->netchan.message, PRINT_HIGH); MSG_WriteString (&cl->netchan.message, va("Welcome %s\n", log1)); //VVD: forcenick -> if ((int)sv_forcenick.value && cl->login) { char oldval[MAX_EXT_INFO_STRING]; strlcpy (oldval, cl->name, MAX_EXT_INFO_STRING); Info_Set (&cl->_userinfo_ctx_, "name", cl->login); ProcessUserInfoChange (cl, "name", oldval); // Change name cvar in client MSG_WriteByte (&cl->netchan.message, svc_stufftext); MSG_WriteString (&cl->netchan.message, va("name %s\n", cl->login)); } //<- MSG_WriteByte (&cl->netchan.message, svc_stufftext); MSG_WriteString (&cl->netchan.message, "cmd new\n"); } }
void infoset_f(void) { qbool set = Info_Set(&g_ctx, Cmd_Argv(1), Cmd_Argv(2)); Sys_Printf("info '%s' %sset to '%s'\n", Cmd_Argv(1), set ? "" : "not ", Cmd_Argv(2)); }