int shell(struct params *params) { PcsRes pcsres; const char *cookie_file; Pcs pcs; if (params->cookie) cookie_file = params->cookie; else cookie_file = get_default_cookie_file(params->username); printf("COOKIE FILE: %s\n", cookie_file); /* 创建一个Pcs对象 */ pcs = pcs_create(cookie_file); /* 设定如何获取验证码 */ if (params->use_urlc) { pcs_setopt(pcs, PCS_OPTION_CAPTCHA_FUNCTION, cb_get_verify_code_byurlc); } else { pcs_setopt(pcs, PCS_OPTION_CAPTCHA_FUNCTION, cb_get_verify_code); } if (params->is_verbose) { pcs_setopt(pcs, PCS_OPTION_HTTP_RESPONSE_FUNCTION, cb_pcs_http_response); } pcs_setopts(pcs, PCS_OPTION_PROGRESS_FUNCTION, cb_upload_progress, PCS_OPTION_PROGRESS, PcsFalse, PCS_OPTION_END); if ((pcsres = pcs_islogin(pcs)) != PCS_LOGIN) { if (!params->username) { printf("Your session is time out, please restart with -u option\n"); pcs_destroy(pcs); return -1; } pcs_setopt(pcs, PCS_OPTION_USERNAME, params->username); if (!params->password) { char password[50]; printf("Password: "******"Login Failed: %s\n", pcs_strerror(pcs)); pcs_destroy(pcs); return -1; } } else { if (params->username && pcs_utils_strcmpi(pcs_sysUID(pcs), params->username) != 0) { char flag[8] = {0}; printf("You have been logged in with %s, but you specified %s,\ncontinue?(yes|no): \n", pcs_sysUID(pcs), params->username); get_string_from_std_input(flag, 4); if (pcs_utils_strcmpi(flag, "yes") && pcs_utils_strcmpi(flag, "y")) { pcs_destroy(pcs); return -1; } } } printf("UID: %s\n", pcs_sysUID(pcs)); show_quota(pcs); exec_cmd(pcs, params); pcs_destroy(pcs); return 0; }
void do_quota ( dbref executor, dbref caller, dbref enactor, int eval, int key, int nargs, UTF8 *arg1, UTF8 *arg2, const UTF8 *cargs[], int ncargs ) { UNUSED_PARAMETER(caller); UNUSED_PARAMETER(enactor); UNUSED_PARAMETER(eval); UNUSED_PARAMETER(nargs); UNUSED_PARAMETER(cargs); UNUSED_PARAMETER(ncargs); if (!(mudconf.quotas || Quota(executor))) { notify_quiet(executor, T("Quotas are not enabled.")); return; } if ((key & QUOTA_TOT) && (key & QUOTA_REM)) { notify_quiet(executor, T("Illegal combination of switches.")); return; } dbref who; int value = 0, i; bool set = false; // Show or set all quotas if requested. // if (key & QUOTA_ALL) { if (arg1 && *arg1) { value = mux_atol(arg1); set = true; } else if (key & (QUOTA_SET | QUOTA_FIX)) { value = 0; set = true; } if (set) { STARTLOG(LOG_WIZARD, "WIZ", "QUOTA"); log_name(executor); log_text(T(" changed everyone\xE2\x80\x99s quota")); ENDLOG; } DO_WHOLE_DB(i) { if (isPlayer(i)) { if (set) { mung_quotas(i, key, value); } show_quota(executor, i); } } return; } // Find out whose quota to show or set. // if (!arg1 || *arg1 == '\0') { who = Owner(executor); } else { who = lookup_player(executor, arg1, true); if (!Good_obj(who)) { notify_quiet(executor, T("Not found.")); return; } } // Make sure we have permission to do it. // if (!Quota(executor)) { if (arg2 && *arg2) { notify_quiet(executor, NOPERM_MESSAGE); return; } if (Owner(executor) != who) { notify_quiet(executor, NOPERM_MESSAGE); return; } } if (arg2 && *arg2) { set = true; value = mux_atol(arg2); } else if (key & QUOTA_FIX) { set = true; value = 0; } if (set) { STARTLOG(LOG_WIZARD, "WIZ", "QUOTA"); log_name(executor); log_text(T(" changed the quota of ")); log_name(who); ENDLOG; mung_quotas(who, key, value); } show_quota(executor, who); }