void swlib::mapstr_upper(std::map<std::string,std::string>& mapstr){ std::map<std::string,std::string> ms; ms = mapstr; mapstr.clear(); std::map<std::string,std::string>::iterator itr; for( itr = ms.begin();itr!=ms.end();itr++){ mapstr[str_upper((*itr).first)] = str_upper( (*itr).second); } }
// Wad::get_lump: Returns a pointer to the first matching lump from offset // -------------------------------------------------------------------- >> Lump* Wad::get_lump(string name, DWORD offset) { for (DWORD l = offset; l < num_lumps; l++) { if (str_upper(directory[l]->Name()) == str_upper(name)) return directory[l]; } return NULL; }
// Wad::get_lump_index: Returns the index of the first lump with the specified name // Returns -1 if no matching lump is found // ----------------------------------------------------------------------------- >> long Wad::get_lump_index(string name) { for (DWORD l = 0; l < num_lumps; l++) { if (str_upper(directory[l]->Name()) == str_upper(name)) return l; } return -1; }
// Same as above but searches from an offset // -------------------------------------- >> long Wad::get_lump_index(string name, DWORD offset) { if (num_lumps == 0) return -1; for (DWORD l = offset; l < num_lumps; l++) { if (str_upper(directory[l]->Name()) == str_upper(name)) return l; } return -1; }
/* SSCN (set secured client negotiation) */ void handle_sscn(struct vsf_session* p_sess) { str_upper(&p_sess->ftp_arg_str); if (!p_sess->control_use_ssl) { vsf_cmdio_write(p_sess, FTP_BADSSCN, "SSCN needs a secure connection."); } else if (str_equal_text(&p_sess->ftp_arg_str, "ON")) { /* SSL mode: connect to the remote host */ p_sess->is_ssl_client = 1; vsf_cmdio_write(p_sess, FTP_SSCNOK, "SSCN: Client method"); } else if (str_equal_text(&p_sess->ftp_arg_str, "OFF")) { /* SSL mode: accept connection */ p_sess->is_ssl_client = 0; vsf_cmdio_write(p_sess, FTP_SSCNOK, "SSCN: Server method"); } else if (str_equal_text(&p_sess->ftp_arg_str, "")) { vsf_cmdio_write(p_sess, FTP_SSCNOK, p_sess->is_ssl_client ? "SSCN: Client method" : "SSCN: Server method"); } }
void vsf_cmdio_get_cmd_and_arg(struct vsf_session* p_sess, struct mystr* p_cmd_str, struct mystr* p_arg_str, int set_alarm) { /* Prepare an alarm to timeout the session.. */ if (set_alarm) { vsf_cmdio_set_alarm(p_sess); } /* Blocks */ control_getline(p_cmd_str, p_sess); str_split_char(p_cmd_str, p_arg_str, ' '); str_upper(p_cmd_str); if (tunable_log_ftp_protocol) { static struct mystr s_log_str; if (str_equal_text(p_cmd_str, "PASS")) { str_alloc_text(&s_log_str, "PASS <password>"); } else { str_copy(&s_log_str, p_cmd_str); if (!str_isempty(p_arg_str)) { str_append_char(&s_log_str, ' '); str_append_str(&s_log_str, p_arg_str); } } vsf_log_line(p_sess, kVSFLogEntryFTPInput, &s_log_str); } }
void handle_auth(struct vsf_session* p_sess) { str_upper(&p_sess->ftp_arg_str); if (str_equal_text(&p_sess->ftp_arg_str, "TLS") || str_equal_text(&p_sess->ftp_arg_str, "TLS-C") || str_equal_text(&p_sess->ftp_arg_str, "SSL") || str_equal_text(&p_sess->ftp_arg_str, "TLS-P")) { vsf_cmdio_write(p_sess, FTP_AUTHOK, "Proceed with negotiation."); if (!ssl_session_init(p_sess)) { struct mystr err_str = INIT_MYSTR; str_alloc_text(&err_str, "Negotiation failed: "); str_append_text(&err_str, get_ssl_error()); vsf_cmdio_write_str(p_sess, FTP_TLS_FAIL, &err_str); vsf_sysutil_exit(0); } p_sess->control_use_ssl = 1; if (str_equal_text(&p_sess->ftp_arg_str, "SSL") || str_equal_text(&p_sess->ftp_arg_str, "TLS-P")) { p_sess->data_use_ssl = 1; } } else { vsf_cmdio_write(p_sess, FTP_BADAUTH, "Unknown AUTH type."); } }
static void handle_site(struct vsf_session* p_sess) { static struct mystr s_site_args_str; /* What SITE sub-command is it? */ str_split_char(&p_sess->ftp_arg_str, &s_site_args_str, ' '); str_upper(&p_sess->ftp_arg_str); if (tunable_write_enable && tunable_chmod_enable && str_equal_text(&p_sess->ftp_arg_str, "CHMOD")) { handle_site_chmod(p_sess, &s_site_args_str); } else if (str_equal_text(&p_sess->ftp_arg_str, "UMASK")) { handle_site_umask(p_sess, &s_site_args_str); } else if (str_equal_text(&p_sess->ftp_arg_str, "HELP")) { vsf_cmdio_write(p_sess, FTP_SITEHELP, "CHMOD UMASK HELP"); } else { vsf_cmdio_write(p_sess, FTP_BADCMD, "Unknown SITE command."); } }
static enum EVSFPrivopLoginResult handle_login(struct vsf_session* p_sess, const struct mystr* p_user_str, const struct mystr* p_pass_str) { /* Do not assume PAM can cope with dodgy input, even though it * almost certainly can. */ int anonymous_login = 0; unsigned int len = str_getlen(p_user_str); if (len == 0 || len > VSFTP_USERNAME_MAX) { return kVSFLoginFail; } /* Throw out dodgy start characters */ if (!vsf_sysutil_isalnum(str_get_char_at(p_user_str, 0))) { return kVSFLoginFail; } /* Throw out non-printable characters and space in username */ if (str_contains_space(p_user_str) || str_contains_unprintable(p_user_str)) { return kVSFLoginFail; } /* Throw out excessive length passwords */ len = str_getlen(p_pass_str); if (len > VSFTP_PASSWORD_MAX) { return kVSFLoginFail; } /* Check for an anonymous login or "real" login */ if (tunable_anonymous_enable) { struct mystr upper_str = INIT_MYSTR; str_copy(&upper_str, p_user_str); str_upper(&upper_str); if (str_equal_text(&upper_str, "FTP") || str_equal_text(&upper_str, "ANONYMOUS")) { anonymous_login = 1; } str_free(&upper_str); } { enum EVSFPrivopLoginResult result = kVSFLoginFail; if (anonymous_login) { result = handle_anonymous_login(p_sess, p_pass_str); } else { if (!tunable_local_enable) { die("unexpected local login in handle_login"); } result = handle_local_login(p_sess, p_user_str, p_pass_str); } return result; } }
void handle_prot(struct vsf_session* p_sess) { str_upper(&p_sess->ftp_arg_str); if (!p_sess->control_use_ssl) { vsf_cmdio_write(p_sess, FTP_BADPROT, "PROT needs a secure connection."); } else if (str_equal_text(&p_sess->ftp_arg_str, "C")) { p_sess->data_use_ssl = 0; vsf_cmdio_write(p_sess, FTP_PROTOK, "PROT now Clear."); } else if (str_equal_text(&p_sess->ftp_arg_str, "P")) { p_sess->data_use_ssl = 1; vsf_cmdio_write(p_sess, FTP_PROTOK, "PROT now Private."); } else if (str_equal_text(&p_sess->ftp_arg_str, "S") || str_equal_text(&p_sess->ftp_arg_str, "E")) { vsf_cmdio_write(p_sess, FTP_NOHANDLEPROT, "PROT not supported."); } else { vsf_cmdio_write(p_sess, FTP_NOSUCHPROT, "PROT not recognized."); } }
static void handle_user_command(struct vsf_session* p_sess) { /* SECURITY: If we're in anonymous only-mode, immediately reject * non-anonymous usernames in the hope we save passwords going plaintext * over the network */ int is_anon = 1; str_copy(&p_sess->user_str, &p_sess->ftp_arg_str); str_upper(&p_sess->ftp_arg_str); if (!str_equal_text(&p_sess->ftp_arg_str, "FTP") && !str_equal_text(&p_sess->ftp_arg_str, "ANONYMOUS")) { is_anon = 0; } if (!tunable_local_enable && !is_anon) { vsf_cmdio_write( p_sess, FTP_LOGINERR, "This FTP server is anonymous only."); str_empty(&p_sess->user_str); return; } if (is_anon && p_sess->control_use_ssl && !tunable_allow_anon_ssl) { vsf_cmdio_write( p_sess, FTP_LOGINERR, "Anonymous sessions may not use encryption."); str_empty(&p_sess->user_str); return; } if (tunable_ssl_enable && !is_anon && !p_sess->control_use_ssl && tunable_force_local_logins_ssl) { vsf_cmdio_write( p_sess, FTP_LOGINERR, "Non-anonymous sessions must use encryption."); str_empty(&p_sess->user_str); return; } if (!str_isempty(&p_sess->userlist_str)) { int located = str_contains_line(&p_sess->userlist_str, &p_sess->user_str); if ((located && tunable_userlist_deny) || (!located && !tunable_userlist_deny)) { vsf_cmdio_write(p_sess, FTP_LOGINERR, "Permission denied."); str_empty(&p_sess->user_str); return; } } if (is_anon && tunable_no_anon_password) { /* Fake a password */ str_alloc_text(&p_sess->ftp_arg_str, "<no password>"); handle_pass_command(p_sess); } else { vsf_cmdio_write(p_sess, FTP_GIVEPWORD, "Please specify the password."); } }
void parseconf_load_setting(const char *setting){ while(isspace(*setting)) setting++; char key[128] = {0}, value[128] = {0}; str_split(setting, key, value, '='); if(strlen(value) == 0){ fprintf(stderr, "missing value in config file for : %s\n", key); exit(EXIT_FAILURE); } { const struct parseconf_str_setting *p_str_setting = parseconf_str_array; while(p_str_setting->p_setting_name != NULL){ if(strcmp(p_str_setting->p_setting_name, key) == 0){ const char **p_cur_setting = p_str_setting->p_variable; if(*p_cur_setting) free((char*)*p_cur_setting); *p_cur_setting = strdup(value); return; } p_str_setting++; } } { const struct parseconf_bool_setting *p_bool_setting = parseconf_bool_array; while(p_bool_setting->p_setting_name != NULL){ if(strcmp(p_bool_setting->p_setting_name, key) == 0){ str_upper(value); if(strcmp(value, "YES") == 0 || strcmp(value, "TRUE") == 0 || strcmp(value, "1") == 0) *(p_bool_setting->p_variable) = 1; else if(strcmp(value, "NO") == 0 || strcmp(value, "FALSE") == 0 || strcmp(value, "0") == 0) *(p_bool_setting->p_variable) = 0; else{ fprintf(stderr, "Wrong bool value in config file for : %s\n", key); exit(EXIT_FAILURE); } return; } p_bool_setting++; } } { const struct parseconf_uint_setting *p_uint_setting = parseconf_uint_array; while(p_uint_setting->p_setting_name != NULL){ if(strcmp(p_uint_setting->p_setting_name, key) == 0){ if(value[0] == '0'){ *(p_uint_setting->p_variable) = str_octal_to_uint(value); } else{ *(p_uint_setting->p_variable) = atoi(value); } return; } p_uint_setting++; } } }
Common::SeekableReadStream *MADSResourceManager::loadResource(const char *resourceName, bool loadFlag) { Common::File hagFile; uint32 offset = 0, size = 0; // If the first character is a '@' then look for an external file if (*resourceName == '@') { ++resourceName; hagFile.open(resourceName); if (loadFlag) return hagFile.readStream(hagFile.size()); else return new Common::SeekableSubReadStream(&hagFile, 0, hagFile.size()); } // If the first character is the wildcard (resource indicator), skip over it if (*resourceName == '*') ++resourceName; char resName[20]; strcpy(resName, resourceName); str_upper(resName); hagFile.open(getResourceFilename(resName)); // Validate hag file header char headerBuffer[16]; if ((hagFile.read(headerBuffer, 16) != 16) || (strncmp(headerBuffer, madsConcatString, 10) != 0)) error("Invalid HAG file opened"); int numEntries = hagFile.readUint16LE(); int resIndex = -1; while (++resIndex < numEntries) { // Read in the details of the next resource char resourceBuffer[14]; offset = hagFile.readUint32LE(); size = hagFile.readUint32LE(); hagFile.read(resourceBuffer, 14); if (!strcmp(resName, resourceBuffer)) break; } if (resIndex == numEntries) error("Invalid resource '%s' specified", resourceName); // Get the resource, either loading it in it's entirely or getting a stream reference if (loadFlag) { hagFile.seek(offset); return hagFile.readStream(size); } else { return new Common::SeekableSubReadStream(&hagFile, offset, offset + size); } }
void handle_child(session_t *pses) { if(pses == NULL) handle_error_str("do_cmd_user: pses is NULL."); ftp_reply(pses->ctrl_fd, FTP_GREET, "(Mftp 0.1)"); //220 int iret; while(true) { memset(pses->cmdline, 0, MAX_COMMAND_LINE); memset(pses->cmd, 0, MAX_COMMAND); memset(pses->arg, 0, MAX_ARG); iret = recvline(pses->ctrl_fd, pses->cmdline, MAX_COMMAND_LINE);//接收命令行 if(iret == -1) handle_error("recvline"); else if(iret == 0) handle_error("recvline"); //去掉\r\n str_trim_crlf(pses->cmdline); //分割命令和参数 str_split(pses->cmdline, pses->cmd, pses->arg, ' '); //将命令转换成大写 str_upper(pses->cmd); #ifdef _DEBUG_ printf("cmd = [%s] arg = [%s]\n", pses->cmd,pses->arg); #endif //处理ftp命令 int len = ARRAYLEN(ctrl_cmds); int i = 0; for(i = 0; i < len; i++) { if(strcmp(ctrl_cmds[i].cmd, pses->cmd) == 0) { if(ctrl_cmds[i].cmd_handler != NULL) { (*ctrl_cmds[i].cmd_handler)(pses); //等价于ctrl_cmds[i].cmd_handler(pses); } else { ftp_reply(pses->ctrl_fd, FTP_COMMANDNOTIMPL, "Unimplement command."); //502 } break; } } if(i >= len) { //没找到命令 ftp_reply(pses->ctrl_fd, FTP_BADCMD, "Unknown command."); } } }
void FileSystem::changeExtension(char *destName, const char *sourceName, const char *extension) { if (sourceName != destName) strcpy(destName, sourceName); char *dot = strrchr(destName, '.'); if (dot != NULL) *dot = 0; sprintf(destName, "%s.%s", destName, extension); str_upper(destName); }
/* * We need to separate the share name and any path component from the URL. * URL "smb://*****:*****@server" no share name or path. * URL "smb://*****:*****@server/"no share name or path. * URL "smb://*****:*****@server/share" just a share name. * URL "smb://*****:*****@server/share/path" share name and path. * * The Share name and Path name will not begin with a slash. * smb://server/ntfs share = ntfs path = NULL * smb://ntfs/dir1/dir2 share = ntfs path = dir1/dir2 */ static int SetShareAndPathFromURL(struct smb_ctx *ctx, CFURLRef url) { CFStringRef share = NULL; CFStringRef path = NULL; CFIndex maxlen; int error; error = GetShareAndPathFromURL(url, &share, &path); if (error) { return error; } /* Since there is no share name we have nothing left to do. */ if (share == NULL) { if (path != NULL) { CFRelease(path); } return 0; } DebugLogCFString(share, "Share", __FUNCTION__, __LINE__); CreateStringByReplacingPercentEscapesUTF8(&share, CFSTR("")); if (ctx->ct_origshare) { free(ctx->ct_origshare); } if (ctx->mountPath) { CFRelease(ctx->mountPath); } ctx->mountPath = NULL; maxlen = CFStringGetMaximumSizeForEncoding(CFStringGetLength(share), kCFStringEncodingUTF8) + 1; ctx->ct_origshare = malloc(maxlen); if (!ctx->ct_origshare) { CFRelease(share); if (path != NULL) { CFRelease(path); } return ENOMEM; } CFStringGetCString(share, ctx->ct_origshare, maxlen, kCFStringEncodingUTF8); str_upper(ctx->ct_sh.ioc_share, sizeof(ctx->ct_sh.ioc_share), share); CFRelease(share); ctx->mountPath = path; return 0; }
int main(void) { printf( "geef string: "); for ( i = 0; (line[i] = getchar()) != '\n'; i++ ); line[i]='\0'; str_upper(line); for ( i = 0; line[i] != '\0'; i++ ) printf( "%c", line[i] ); printf( "\n" ); printf( "%s\n", line ); }
void handle_opts(struct vsf_session* p_sess) { str_upper(&p_sess->ftp_arg_str); if (str_equal_text(&p_sess->ftp_arg_str, "UTF8 ON") && !strcmp(tunable_remote_charset, "utf8")) { vsf_cmdio_write(p_sess, FTP_OPTSOK, "Always in UTF8 mode."); } else { vsf_cmdio_write(p_sess, FTP_BADOPTS, "Option not understood."); } }
void NM::CDiction::getwordfreq_file(std::string& filepath) { std::cout<<"filepath"<<filepath<<std::endl; std::fstream fin; fin.open(filepath.c_str()); if(!fin.is_open()) { std::cout<<filepath<<"open failed"<<std::endl; exit(0); } std::string line; std::string partiline; std::stringstream sin; std::string partiword; std::string str_upper("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); int pos; MY_LANGTRAN::CLang lang; char* utfStr = NULL; int ret = -1; while(std::getline(fin,line)) { if(line.size() == 0) continue; ret = lang.gbk2utf8(&utfStr,line.c_str()); if(ret == -1) continue; line = utfStr; lang.destroy(&utfStr); pos = 0; while( (pos = line.find_first_of(str_upper,pos)) != std::string::npos) { line[pos] = line[pos] + 'a' - 'A'; pos++; } //空格分为全角和半角空格,对于全角空格要变为半角空格 for(int i=0;i<line.size();i++) if(ispunct(line[i])) line[i]=' '; partiline = (char*)NLPIR_ParagraphProcess(line.c_str(),0); sin.str(partiline); sin.clear(); while(sin>>partiword) { if(m_set_stop.find(partiword) != m_set_stop.end()) continue; m_word_freq[partiword]++; } } fin.close(); }
char GetAnswer(const char* prompt, const char* answers, int repeatAfter, FILE* fp) { char input[500], *finder; int ntimes; while (1) { fprintf(fp, prompt); for (ntimes=0; (ntimes<repeatAfter) || !repeatAfter; ntimes++) { scanf("%499s",input); str_upper(input); if (finder=strpbrk(input, answers)) return *finder; } } }
// Wad::delete_lump: Deletes a lump // ----------------------------- >> void Wad::delete_lump(string name, DWORD offset) { long index = -1; for (DWORD l = offset; l < num_lumps; l++) { if (str_upper(directory[l]->Name()) == str_upper(name)) { index = l; break; } } if (index == -1) return; delete directory[index]; for (DWORD l = index; l < num_lumps - 1; l++) directory[l] = directory[l + 1]; num_lumps--; directory = (Lump **)realloc(directory, num_lumps * sizeof(Lump *)); }
/* * Get the workgroup and return a username CFStringRef if it exist. * First get the CFURLCopyNetLocation because it will not escape out the string. */ static CFStringRef SetWorkgroupFromURL(struct smb_ctx *ctx, CFURLRef url) { CFStringRef userString = NULL; CFStringRef wrkgrpString = NULL; userString = CopyUserAndWorkgroupFromURL(&wrkgrpString, url); if (wrkgrpString) { LogCFString(wrkgrpString, "Workgroup", __FUNCTION__, __LINE__); if (CFStringGetLength(wrkgrpString) <= SMB_MAXNetBIOSNAMELEN) { str_upper(ctx->ct_setup.ioc_domain, sizeof(ctx->ct_setup.ioc_domain), wrkgrpString); } CFRelease(wrkgrpString); } return(userString); }
void handle_child(session_t* sess) { ftp_reply(sess, FTP_GREET, "(miniftpd 0.1)"); int ret; while(1) { memset(sess->cmdline, 0, sizeof(sess->cmdline)); memset(sess->cmd, 0, sizeof(sess->cmd)); memset(sess->arg, 0, sizeof(sess->arg)); start_cmdio_alarm(); ret = readline(sess->ctrl_fd, sess->cmdline, MAX_COMMAND_LINE); if(ret == -1) ERR_EXIT("readline"); else if(ret == 0) exit(EXIT_SUCCESS); //remove \r\n //parse FTP command and ar str_trim_crlf(sess->cmdline); str_split(sess->cmdline, sess->cmd, sess->arg, ' '); str_upper(sess->cmd); int i; int size = sizeof(ctrl_cmds) / sizeof(ctrl_cmds[0]); for(i = 0; i < size; ++i) { if(strcmp(ctrl_cmds[i].cmd, sess->cmd) == 0) { if(ctrl_cmds[i].cmd_handler != NULL) ctrl_cmds[i].cmd_handler(sess); else ftp_reply(sess, FTP_COMMANDNOTIMPL, "Unimplement command"); break; } } if(i == size) ftp_reply(sess, FTP_BADCMD, "Unknown command."); } }
void Inventory::registerObject(char* name, int32 scene, int32 icon) { InventoryObject *newObject = new InventoryObject(); int newObjectIndex = 0; // Capitalize registered inventory object names str_upper(name); newObject->name = strdup(name); newObject->scene = scene; newObject->icon = icon; newObjectIndex = _inventory.size(); _inventory.push_back(newObject); if (scene == BACKPACK) addToBackpack(newObjectIndex); }
/* Switches are: (taken from the help of the original executable) -b Toggle background load status off/on. -c:char Specify sound card id letter. -f:num Specify a specific starting frame number -g Stay in graphics mode on exit. -h[:ex] Disable EMS/XMS high memory support. -i Switch sound interrupts mode off/on. -j Wait for music to finish at end. -k Keystroke jumps to end instead of abort. -m Operate in non-MADS mode. -o:xxx Specify opening special effect. -p Switch MADS path mode to CONCAT. -r[:abn] Resynch timer (always, beginning, never). -s:file Specify sound file. -u[:...] Use DMA speech [optional: addr,type,irq,drq]. -w Toggle white bars off/on. -x Exit immediately after last frame. -y Do not clear screen initially -z Display statistics after run. Opening special effects are: 0: no effect 1: fade in 2: fade in (looks to be the same as 1) 3: box in from bottom left (unused) 4: box in from bottom right (unused) 5: box in from top left (unused) 6: box in from top right (unused) 7: pan in from left to right 8: pan in from right to left 9: circle in (new scene appears in a circle that expands) Animview is ran like this from the original games: animview.exe @resfilename -c:P,220,20 -u:220,20,07,01 -p -a:mainmenu -p Note that the first -p is necessary to watch the animation, otherwise the program just exits To watch an animation within the *.res file, just run animview like this: animview.exe -x -r:b -o:2 animfilename -p */ void AnimviewView::processCommand() { char commandStr[80]; strcpy(commandStr, _currentLine + 1); str_upper(commandStr); char *param = commandStr; switch (commandStr[0]) { case 'B': // Toggle background load flag _bgLoadFlag = !_bgLoadFlag; break; case 'F': // Start animation at a specific frame ++param; assert(*param == ':'); _startFrame = atoi(++param); break; case 'O': param = param + 2; //warning(kDebugGraphics, "O:%i ", atoi(param)); _transition = atoi(param); break; case 'R': param = param + 2; //warning(kDebugGraphics, "R:%s ", param); break; case 'W': //warning(kDebugGraphics, "W "); break; case 'X': //warning(kDebugGraphics, "X "); break; default: error("Unknown response command: '%s'", commandStr); } }
void vsf_cmdio_get_cmd_and_arg(struct vsf_session* p_sess, struct mystr* p_cmd_str, struct mystr* p_arg_str, int set_alarm) { /* Prepare an alarm to timeout the session.. */ if (set_alarm) { vsf_cmdio_set_alarm(p_sess); } /* Blocks */ control_getline(p_cmd_str, p_sess); /* View a single space as a command of " ", which although a useless command, * permits the caller to distinguish input of "" from " ". */ if (str_getlen(p_cmd_str) == 1 && str_get_char_at(p_cmd_str, 0) == ' ') { str_empty(p_arg_str); } else { str_split_char(p_cmd_str, p_arg_str, ' '); } str_upper(p_cmd_str); if (tunable_log_ftp_protocol) { static struct mystr s_log_str; if (str_equal_text(p_cmd_str, "PASS")) { str_alloc_text(&s_log_str, "PASS <password>"); } else { str_copy(&s_log_str, p_cmd_str); if (!str_isempty(p_arg_str)) { str_append_char(&s_log_str, ' '); str_append_str(&s_log_str, p_arg_str); } } vsf_log_line(p_sess, kVSFLogEntryFTPInput, &s_log_str); } }
static void handle_type(struct vsf_session* p_sess) { str_upper(&p_sess->ftp_arg_str); if (str_equal_text(&p_sess->ftp_arg_str, "I") || str_equal_text(&p_sess->ftp_arg_str, "L8") || str_equal_text(&p_sess->ftp_arg_str, "L 8")) { p_sess->is_ascii = 0; vsf_cmdio_write(p_sess, FTP_TYPEOK, "Switching to Binary mode."); } else if (str_equal_text(&p_sess->ftp_arg_str, "A") || str_equal_text(&p_sess->ftp_arg_str, "A N")) { p_sess->is_ascii = 1; vsf_cmdio_write(p_sess, FTP_TYPEOK, "Switching to ASCII mode."); } else { vsf_cmdio_write(p_sess, FTP_BADCMD, "Unrecognised TYPE command."); } }
void handle_auth(struct vsf_session* p_sess) { str_upper(&p_sess->ftp_arg_str); if (str_equal_text(&p_sess->ftp_arg_str, "TLS") || str_equal_text(&p_sess->ftp_arg_str, "TLS-C") || str_equal_text(&p_sess->ftp_arg_str, "SSL") || str_equal_text(&p_sess->ftp_arg_str, "TLS-P")) { vsf_cmdio_write(p_sess, FTP_AUTHOK, "Proceed with negotiation."); ssl_control_handshake(p_sess); if (str_equal_text(&p_sess->ftp_arg_str, "SSL") || str_equal_text(&p_sess->ftp_arg_str, "TLS-P")) { p_sess->data_use_ssl = 1; } } else { vsf_cmdio_write(p_sess, FTP_BADAUTH, "Unknown AUTH type."); } }
bool MADSResourceManager::resourceExists(const char *resourceName) { Common::File hagFile; uint32 offset, size; // If the first character is the wildcard (resource indicator), skip over it if (*resourceName == '*') ++resourceName; char resName[20]; strcpy(resName, resourceName); str_upper(resName); hagFile.open(getResourceFilename(resName)); // Validate hag file header char headerBuffer[16]; if ((hagFile.read(headerBuffer, 16) != 16) || (strncmp(headerBuffer, madsConcatString, 10) != 0)) error("Invalid HAG file opened"); int numEntries = hagFile.readUint16LE(); int resIndex = -1; while (++resIndex < numEntries) { // Read in the details of the next resource char resourceBuffer[14]; offset = hagFile.readUint32LE(); size = hagFile.readUint32LE(); hagFile.read(resourceBuffer, 14); if (!strcmp(resName, resourceBuffer)) break; } if (resIndex == numEntries) return false; else return true; }
static void dispatch_line(void) { struct command* c; str_upper(&cmd); for (c = commands; c->name != 0; ++c) { if (str_diffs(&cmd, c->name) == 0) { if (line_argc == 0) { if (c->fn0 == 0) respond(0, "BAD Syntax error: command requires arguments"); else c->fn0(); } else { if (c->fn1 == 0) respond(0, "BAD Syntax error: command requires no arguments"); else c->fn1(line_argc, line_args); } return; } } respond(0, "BAD Unimplemented command"); }