static void process_image (MonoImage *image, gboolean all) { int i; const MonoTableInfo *t; MonoClass *klass; MonoMethod *entry; guint32 eptoken; if (verbose) g_print ("#processing image: %s\n", mono_image_get_name (image)); eptoken = mono_image_get_entry_point (image); if (eptoken) { entry = mono_get_method (image, eptoken, NULL); add_types_from_method (entry); } /* we always add the <Module> type */ klass = mono_class_get (image, MONO_TOKEN_TYPE_DEF | 1); handle_type (klass, all? TYPE_ALL: TYPE_BASIC); if (all) { t = mono_image_get_table_info (image, MONO_TABLE_TYPEDEF); for (i = 1; i < mono_table_info_get_rows (t); ++i) { klass = mono_class_get (image, MONO_TOKEN_TYPE_DEF | (i + 1)); handle_type (klass, all? TYPE_ALL: TYPE_BASIC); } } }
KOKKOS_INLINE_FUNCTION static handle_type assign( value_type * arg_data_ptr, track_type const & arg_tracker ) { #if defined( KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST ) // Assignment of texture = non-texture requires creation of a texture object // which can only occur on the host. In addition, 'get_record' is only valid // if called in a host execution space typedef typename Traits::memory_space memory_space ; typedef typename Impl::SharedAllocationRecord<memory_space,void> record ; record * const r = arg_tracker.template get_record< memory_space >(); #if ! defined( KOKKOS_ENABLE_CUDA_LDG_INTRINSIC ) if ( 0 == r ) { //Kokkos::abort("Cuda const random access View using Cuda texture memory requires Kokkos to allocate the View's memory"); return handle_type(); } #endif return handle_type( arg_data_ptr , r ); #else Kokkos::Impl::cuda_abort("Cannot create Cuda texture object from within a Cuda kernel"); return handle_type(); #endif }
KOKKOS_INLINE_FUNCTION static handle_type assign( value_type * arg_data_ptr, track_type const & arg_tracker ) { #if defined( KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST ) // Assignment of texture = non-texture requires creation of a texture object // which can only occur on the host. In addition, 'get_record' is only valid // if called in a host execution space return handle_type( arg_data_ptr , arg_tracker.template get_record< typename Traits::memory_space >() ); #else Kokkos::Impl::cuda_abort("Cannot create Cuda texture object from within a Cuda kernel"); return handle_type(); #endif }
/** * \brief Drop the item. */ void rp::zeppelin::drop() { if ( m_drop_item != handle_type(NULL) ) { entity* e = dynamic_cast<entity*>(m_drop_item.get()); if ( e != NULL ) e->set_combo_value(get_combo_value()); m_drop_item->clear_forced_movement(); m_drop_item = handle_type(NULL); } } // zeppelin::drop()
static void process_images (void) { int old_count, new_count; GList *item, *vmethod; new_count = g_hash_table_size (type_table); new_count += g_hash_table_size (method_table); new_count += g_hash_table_size (field_table); do { old_count = new_count; if (verbose) g_print ("#processing type table: %d\n", old_count); g_list_free (worklist); worklist = NULL; g_hash_table_foreach (type_table, collect_type, NULL); for (item = worklist; item; item = item->next) { for (vmethod = virtual_methods; vmethod; vmethod = vmethod->next) { check_vmethods (item->data, vmethod->data); } } g_list_free (worklist); worklist = NULL; g_hash_table_foreach (type_table, collect_type, NULL); for (item = worklist; item; item = item->next) { handle_type (item->data, TYPE_BASIC); } new_count = g_hash_table_size (type_table); new_count += g_hash_table_size (method_table); new_count += g_hash_table_size (field_table); } while (old_count != new_count); }
/** * \brief The item is destroyed. */ void rp::zeppelin::destroy() { if ( m_drop_item != handle_type(NULL) ) m_drop_item->kill(); super::destroy(); } // zeppelin::destroy()
/** * \brief Get the item to drop. */ bear::engine::base_item* rp::zeppelin::get_drop_item() { if ( m_drop_item != handle_type(NULL) ) return m_drop_item.get(); else return NULL; } // zeppelin::get_drop_item()
static int handle_line(struct parsedfile *config, char *line, int lineno) { char *words[10]; static char savedline[MAXLINE]; int nowords = 0, i; /* Save the input string */ strncpy(savedline, line, MAXLINE - 1); savedline[MAXLINE - 1] = (char) 0; /* Tokenize the input string */ nowords = tokenize(line, 10, words); /* Set the spare slots to an empty string to simplify */ /* processing */ for (i = nowords; i < 10; i++) words[i] = ""; if (nowords > 0) { /* Now this can either be a "path" block starter or */ /* ender, otherwise it has to be a pair (<name> = */ /* <value>) */ if (!strcmp(words[0], "path")) { handle_path(config, lineno, nowords, words); } else if (!strcmp(words[0], "}")) { handle_endpath(config, lineno, nowords, words); } else { /* Has to be a pair */ if ((nowords != 3) || (strcmp(words[1], "="))) { show_msg(MSGERR, "Malformed configuration pair " "on line %d in configuration " "file, \"%s\"\n", lineno, savedline); } else if (!strcmp(words[0], "reaches")) { handle_reaches(config, lineno, words[2]); } else if (!strcmp(words[0], "server")) { handle_server(config, lineno, words[2]); } else if (!strcmp(words[0], "server_port")) { handle_port(config, lineno, words[2]); } else if (!strcmp(words[0], "server_type")) { handle_type(config, lineno, words[2]); } else if (!strcmp(words[0], "default_user")) { handle_defuser(config, lineno, words[2]); } else if (!strcmp(words[0], "default_pass")) { handle_defpass(config, lineno, words[2]); } else if (!strcmp(words[0], "local")) { handle_local(config, lineno, words[2]); } else { show_msg(MSGERR, "Invalid pair type (%s) specified " "on line %d in configuration file, " "\"%s\"\n", words[0], lineno, savedline); } } } return(0); }
//TODO ADD OPTIMISATIONS DURING KEY MATCHING int json_parse(json_parser *parser, const char *input_buff, size_t buff_sz){ int i; //The parser looks at one char at a time. //the character is only advanced by this for loop. for (; parser->buff_offset < buff_sz && input_buff[parser->buff_offset] != '\0'; parser->buff_offset++) { char c; int res; c = input_buff[parser->buff_offset]; switch (parser->state){ case JSON_STATE_BEGIN_VAL_OR_KEY: res = handle_begin_val_or_key(parser, c); break; case JSON_STATE_INT_ELEM: res = handle_int_elem(parser, c); break; case JSON_STATE_TRUE_ELEM: case JSON_STATE_FALSE_ELEM: case JSON_STATE_NULL_ELEM: res = handle_special_elem(parser, c); break; case JSON_STATE_KEY_OR_STR: case JSON_STATE_KEY_OR_STR_ESCAPE: res = handle_key_or_str(parser, c); break; case JSON_STATE_KEY_OR_STR_END: res = handle_key_or_str_end(parser, c); break; case JSON_STATE_TYPE: res = handle_type(parser, c); break; case JSON_STATE_INT: res = handle_int(parser, c); break; case JSON_STATE_TRUE: case JSON_STATE_FALSE: case JSON_STATE_NULL: res = handle_special(parser, c); break; case JSON_STATE_STR: case JSON_STATE_STR_ESCAPE: res = handle_str(parser, c); break; case JSON_STATE_END_VAL: res = handle_end_val(parser, c); break; case JSON_STATE_START: res = handle_start(parser, c); break; //parsing stop if we are done or if there was an error if (res <= 0) return res; } } //ran out of buffer, parser is either done or needs more input if (parser->level == 0) return JSON_DONE; return JSON_CONTINUE; }
/** * \brief Set a field of type item_list. * \param name The name of the field. * \param value The new value of the field. * \return false if the field "name" is unknow, true otherwise. */ bool bear::camera_on_object::set_item_list_field ( const std::string& name, const std::vector<base_item*>& value ) { bool ok = true; if (name == "camera_on_object.items") for( std::size_t i=0; i!=value.size(); ++i ) m_objects.push_back( handle_type((universe::physical_item*)value[i]) ); else ok = super::set_item_list_field(name, value); return ok; } // camera_on_object::set_item_list_field()
/** * \brief Set a field of type \c list of item. * \param name The name of the field. * \param value The new value of the field. * \return false if the field "name" is unknow, true otherwise. */ bool ptb::on_players_activator::set_item_list_field ( const std::string& name, const std::vector<bear::engine::base_item*>& value) { bool ok = true; if (name == "on_players_activator.item") for( std::size_t i=0; i!=value.size(); ++i ) m_item.push_back( handle_type(value[i]) ); else ok = super::set_item_list_field(name, value); return ok; } // on_players_activator::set_item_list_field()
/** * \brief Create item. */ void rp::zeppelin::create_item() { base_item* const item = m_item->clone(); item->set_top_middle( get_mark_world_position("anchor") ); item->set_global( is_global() ); entity* e = dynamic_cast<entity*>( m_item ); if ( e != NULL ) item->set_z_position(get_z_position() + 1); new_item( *item ); m_drop_item = handle_type(item); bear::universe::forced_tracking mvt ( item->get_center_of_mass() - get_center_of_mass() ); mvt.set_reference_point_on_center( *this ); mvt.set_auto_remove(true); item->set_forced_movement( mvt ); } // zeppelin::create_item()
void process_post_login(struct vsf_session* p_sess) { int retval; if (p_sess->is_anonymous) { vsf_sysutil_set_umask(tunable_anon_umask); p_sess->bw_rate_max = tunable_anon_max_rate; } else { vsf_sysutil_set_umask(tunable_local_umask); p_sess->bw_rate_max = tunable_local_max_rate; } if (tunable_async_abor_enable) { vsf_sysutil_install_sighandler(kVSFSysUtilSigURG, handle_sigurg, p_sess); vsf_sysutil_activate_sigurg(VSFTP_COMMAND_FD); } /* Kitsune */ vsf_sysutil_kitsune_set_update_point("postlogin.c"); if(!kitsune_is_updating()) { /* Handle any login message */ vsf_banner_dir_changed(p_sess, FTP_LOGINOK); vsf_cmdio_write(p_sess, FTP_LOGINOK, "Login successful. Have fun."); } else { /* Set sigchld function pointer (normally done in twoprocess.c) */ vsf_sysutil_default_sig(kVSFSysUtilSigCHLD); vsf_sysutil_install_async_sighandler(kVSFSysUtilSigCHLD, twoproc_handle_sigchld); } /* End Kitsune */ while(1) { if (tunable_setproctitle_enable) { vsf_sysutil_setproctitle("IDLE"); } /* Kitsune update point */ kitsune_update("postlogin.c"); /**DSU updatepoint */ /* Blocks */ vsf_cmdio_get_cmd_and_arg(p_sess, &p_sess->ftp_cmd_str, &p_sess->ftp_arg_str, 1); if (tunable_setproctitle_enable) { struct mystr proctitle_str = INIT_MYSTR; str_copy(&proctitle_str, &p_sess->ftp_cmd_str); if (!str_isempty(&p_sess->ftp_arg_str)) { str_append_char(&proctitle_str, ' '); str_append_str(&proctitle_str, &p_sess->ftp_arg_str); } /* Suggestion from Solar */ str_replace_unprintable(&proctitle_str, '?'); vsf_sysutil_setproctitle_str(&proctitle_str); str_free(&proctitle_str); } if (str_equal_text(&p_sess->ftp_cmd_str, "QUIT")) { vsf_cmdio_write(p_sess, FTP_GOODBYE, "Goodbye."); vsf_sysutil_exit(0); } else if (str_equal_text(&p_sess->ftp_cmd_str, "PWD") || str_equal_text(&p_sess->ftp_cmd_str, "XPWD")) { handle_pwd(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "CWD") || str_equal_text(&p_sess->ftp_cmd_str, "XCWD")) { handle_cwd(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "CDUP") || str_equal_text(&p_sess->ftp_cmd_str, "XCUP")) { handle_cdup(p_sess); } else if (tunable_pasv_enable && str_equal_text(&p_sess->ftp_cmd_str, "PASV")) { handle_pasv(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "RETR")) { handle_retr(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "NOOP")) { vsf_cmdio_write(p_sess, FTP_NOOPOK, "NOOP ok."); } else if (str_equal_text(&p_sess->ftp_cmd_str, "SYST")) { vsf_cmdio_write(p_sess, FTP_SYSTOK, "UNIX Type: L8"); } else if (str_equal_text(&p_sess->ftp_cmd_str, "HELP")) { vsf_cmdio_write(p_sess, FTP_BADHELP, "Sorry, I don't have help."); } else if (str_equal_text(&p_sess->ftp_cmd_str, "LIST")) { handle_list(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "TYPE")) { handle_type(p_sess); } else if (tunable_port_enable && str_equal_text(&p_sess->ftp_cmd_str, "PORT")) { handle_port(p_sess); } else if (tunable_write_enable && (tunable_anon_upload_enable || !p_sess->is_anonymous) && str_equal_text(&p_sess->ftp_cmd_str, "STOR")) { handle_stor(p_sess); } else if (tunable_write_enable && (tunable_anon_mkdir_write_enable || !p_sess->is_anonymous) && (str_equal_text(&p_sess->ftp_cmd_str, "MKD") || str_equal_text(&p_sess->ftp_cmd_str, "XMKD"))) { handle_mkd(p_sess); } else if (tunable_write_enable && (tunable_anon_other_write_enable || !p_sess->is_anonymous) && (str_equal_text(&p_sess->ftp_cmd_str, "RMD") || str_equal_text(&p_sess->ftp_cmd_str, "XRMD"))) { handle_rmd(p_sess); } else if (tunable_write_enable && (tunable_anon_other_write_enable || !p_sess->is_anonymous) && str_equal_text(&p_sess->ftp_cmd_str, "DELE")) { handle_dele(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "REST")) { handle_rest(p_sess); } else if (tunable_write_enable && (tunable_anon_other_write_enable || !p_sess->is_anonymous) && str_equal_text(&p_sess->ftp_cmd_str, "RNFR")) { handle_rnfr(p_sess); } else if (tunable_write_enable && (tunable_anon_other_write_enable || !p_sess->is_anonymous) && str_equal_text(&p_sess->ftp_cmd_str, "RNTO")) { handle_rnto(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "NLST")) { handle_nlst(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "SIZE")) { handle_size(p_sess); } else if (!p_sess->is_anonymous && str_equal_text(&p_sess->ftp_cmd_str, "SITE")) { handle_site(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "ABOR")) { vsf_cmdio_write(p_sess, FTP_ABOR_NOCONN, "No transfer to ABOR."); } else if (tunable_write_enable && (tunable_anon_other_write_enable || !p_sess->is_anonymous) && str_equal_text(&p_sess->ftp_cmd_str, "APPE")) { handle_appe(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "MDTM")) { handle_mdtm(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "PASV") || str_equal_text(&p_sess->ftp_cmd_str, "PORT") || str_equal_text(&p_sess->ftp_cmd_str, "STOR") || str_equal_text(&p_sess->ftp_cmd_str, "MKD") || str_equal_text(&p_sess->ftp_cmd_str, "XMKD") || str_equal_text(&p_sess->ftp_cmd_str, "RMD") || str_equal_text(&p_sess->ftp_cmd_str, "XRMD") || str_equal_text(&p_sess->ftp_cmd_str, "DELE") || str_equal_text(&p_sess->ftp_cmd_str, "RNFR") || str_equal_text(&p_sess->ftp_cmd_str, "RNTO") || str_equal_text(&p_sess->ftp_cmd_str, "SITE") || str_equal_text(&p_sess->ftp_cmd_str, "APPE")) { vsf_cmdio_write(p_sess, FTP_NOPERM, "Permission denied."); } else { vsf_cmdio_write(p_sess, FTP_BADCMD, "Unknown command."); } } }
//2/ void handle_type_2(int (*handle_type)(char* s), char* s) { handle_type(s); }
void set_handle_invalid( container_type const & /*container*/, handle_type & handle, id_handle_tag ) { handle = handle_type(); }
static void load_roots (const char* filename) { FILE *file; char buf [2048]; char *p, *s; int line = 0; MonoImage *image = NULL; MonoClass *klass = NULL; MonoClassField *field; MonoMethodDesc *mdesc; MonoMethod *method; if (!(file = fopen (filename, "r"))) return; while (fgets (buf, sizeof (buf), file)) { /* FIXME: * decide on the format to use to express types, fields, methods, * maybe the same used on output from the tool, but with explicit * names and signatures instead of token indexes * add wildcard support */ ++line; s = buf; while (*s && g_ascii_isspace (*s)) ++s; switch (*s) { case 0: case '#': continue; /* comment */ case '[': p = strchr (s, ']'); if (!p) g_error ("invalid assembly format at line %d\n", line); *p = 0; p = s + 1; image = find_image (p); if (!image) g_error ("image not loaded: %s\n", p); klass = NULL; break; case 'T': if (s [1] != ':') g_error ("invalid type format at line %d\n", line); if (!image) break; klass = find_class (image, s + 2); break; case 'F': if (s [1] != ':') g_error ("invalid field format at line %d\n", line); if (!image || !klass) break; p = s + 2; if (*p == '*') { handle_type (klass, TYPE_FIELDS); break; } field = mono_class_get_field_from_name (klass, p); if (!field) g_warning ("no field '%s' at line %d\n", p, line); else add_field (field); break; case 'M': if (s [1] != ':') g_error ("invalid method format at line %d\n", line); if (!image || !klass) break; p = s + 2; if (*p == '*') { handle_type (klass, TYPE_METHODS); break; } mdesc = mono_method_desc_new (p, FALSE); if (!mdesc) { g_error ("invalid method desc at line %d\n", line); } method = mono_method_desc_search_in_class (mdesc, klass); if (!method) g_warning ("no method '%s' at line %d\n", p, line); else add_types_from_method (method); mono_method_desc_free (mdesc); break; default: g_error ("invalid format at line %d\n", line); } } fclose (file); }
/** * \brief Add a item. * \param item The item to add. */ void bear::camera_on_object::add_item( base_item* item ) { m_objects.push_back( handle_type(item) ); } // camera_on_object::add_item()
void process_post_login(struct vsf_session* p_sess) { if (p_sess->is_anonymous) { vsf_sysutil_set_umask(tunable_anon_umask); p_sess->bw_rate_max = tunable_anon_max_rate; } else { vsf_sysutil_set_umask(tunable_local_umask); p_sess->bw_rate_max = tunable_local_max_rate; } if (tunable_async_abor_enable) { vsf_sysutil_install_sighandler(kVSFSysUtilSigURG, handle_sigurg, p_sess); vsf_sysutil_activate_sigurg(VSFTP_COMMAND_FD); } /* Handle any login message */ vsf_banner_dir_changed(p_sess, FTP_LOGINOK); vsf_cmdio_write(p_sess, FTP_LOGINOK, "Login successful."); while(1) { int cmd_ok = 1; if (tunable_setproctitle_enable) { vsf_sysutil_setproctitle("IDLE"); } /* Blocks */ vsf_cmdio_get_cmd_and_arg(p_sess, &p_sess->ftp_cmd_str, &p_sess->ftp_arg_str, 1); if (tunable_setproctitle_enable) { struct mystr proctitle_str = INIT_MYSTR; str_copy(&proctitle_str, &p_sess->ftp_cmd_str); if (!str_isempty(&p_sess->ftp_arg_str)) { str_append_char(&proctitle_str, ' '); str_append_str(&proctitle_str, &p_sess->ftp_arg_str); } /* Suggestion from Solar */ str_replace_unprintable(&proctitle_str, '?'); vsf_sysutil_setproctitle_str(&proctitle_str); str_free(&proctitle_str); } /* Test command against the allowed list.. */ if (tunable_cmds_allowed) { static struct mystr s_src_str; static struct mystr s_rhs_str; str_alloc_text(&s_src_str, tunable_cmds_allowed); while (1) { str_split_char(&s_src_str, &s_rhs_str, ','); if (str_isempty(&s_src_str)) { cmd_ok = 0; break; } else if (str_equal(&s_src_str, &p_sess->ftp_cmd_str)) { break; } str_copy(&s_src_str, &s_rhs_str); } } if (!cmd_ok) { vsf_cmdio_write(p_sess, FTP_NOPERM, "Permission denied."); } else if (str_equal_text(&p_sess->ftp_cmd_str, "QUIT")) { vsf_cmdio_write(p_sess, FTP_GOODBYE, "Goodbye."); vsf_sysutil_exit(0); } else if (str_equal_text(&p_sess->ftp_cmd_str, "PWD") || str_equal_text(&p_sess->ftp_cmd_str, "XPWD")) { handle_pwd(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "CWD") || str_equal_text(&p_sess->ftp_cmd_str, "XCWD")) { handle_cwd(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "CDUP") || str_equal_text(&p_sess->ftp_cmd_str, "XCUP")) { handle_cdup(p_sess); } else if (tunable_pasv_enable && !p_sess->epsv_all && (str_equal_text(&p_sess->ftp_cmd_str, "PASV") || str_equal_text(&p_sess->ftp_cmd_str, "P@SW"))) { handle_pasv(p_sess, 0); } else if (tunable_pasv_enable && str_equal_text(&p_sess->ftp_cmd_str, "EPSV")) { handle_pasv(p_sess, 1); } else if (tunable_download_enable && str_equal_text(&p_sess->ftp_cmd_str, "RETR")) { handle_retr(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "NOOP")) { vsf_cmdio_write(p_sess, FTP_NOOPOK, "NOOP ok."); } else if (str_equal_text(&p_sess->ftp_cmd_str, "SYST")) { vsf_cmdio_write(p_sess, FTP_SYSTOK, "UNIX Type: L8"); } else if (str_equal_text(&p_sess->ftp_cmd_str, "HELP")) { handle_help(p_sess); } else if (tunable_dirlist_enable && str_equal_text(&p_sess->ftp_cmd_str, "LIST")) { handle_list(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "TYPE")) { handle_type(p_sess); } else if (tunable_port_enable && !p_sess->epsv_all && str_equal_text(&p_sess->ftp_cmd_str, "PORT")) { handle_port(p_sess); } else if (tunable_write_enable && (tunable_anon_upload_enable || !p_sess->is_anonymous) && str_equal_text(&p_sess->ftp_cmd_str, "STOR")) { handle_stor(p_sess); } else if (tunable_write_enable && (tunable_anon_mkdir_write_enable || !p_sess->is_anonymous) && (str_equal_text(&p_sess->ftp_cmd_str, "MKD") || str_equal_text(&p_sess->ftp_cmd_str, "XMKD"))) { handle_mkd(p_sess); } else if (tunable_write_enable && (tunable_anon_other_write_enable || !p_sess->is_anonymous) && (str_equal_text(&p_sess->ftp_cmd_str, "RMD") || str_equal_text(&p_sess->ftp_cmd_str, "XRMD"))) { handle_rmd(p_sess); } else if (tunable_write_enable && (tunable_anon_other_write_enable || !p_sess->is_anonymous) && str_equal_text(&p_sess->ftp_cmd_str, "DELE")) { handle_dele(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "REST")) { handle_rest(p_sess); } else if (tunable_write_enable && (tunable_anon_other_write_enable || !p_sess->is_anonymous) && str_equal_text(&p_sess->ftp_cmd_str, "RNFR")) { handle_rnfr(p_sess); } else if (tunable_write_enable && (tunable_anon_other_write_enable || !p_sess->is_anonymous) && str_equal_text(&p_sess->ftp_cmd_str, "RNTO")) { handle_rnto(p_sess); } else if (tunable_dirlist_enable && str_equal_text(&p_sess->ftp_cmd_str, "NLST")) { handle_nlst(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "SIZE")) { handle_size(p_sess); } else if (!p_sess->is_anonymous && str_equal_text(&p_sess->ftp_cmd_str, "SITE")) { handle_site(p_sess); } /* Note - the weird ABOR string is checking for an async ABOR arriving * without a SIGURG condition. */ else if (str_equal_text(&p_sess->ftp_cmd_str, "ABOR") || str_equal_text(&p_sess->ftp_cmd_str, "\377\364\377\362ABOR")) { vsf_cmdio_write(p_sess, FTP_ABOR_NOCONN, "No transfer to ABOR."); } else if (tunable_write_enable && (tunable_anon_other_write_enable || !p_sess->is_anonymous) && str_equal_text(&p_sess->ftp_cmd_str, "APPE")) { handle_appe(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "MDTM")) { handle_mdtm(p_sess); } else if (tunable_port_enable && str_equal_text(&p_sess->ftp_cmd_str, "EPRT")) { handle_eprt(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "STRU")) { str_upper(&p_sess->ftp_arg_str); if (str_equal_text(&p_sess->ftp_arg_str, "F")) { vsf_cmdio_write(p_sess, FTP_STRUOK, "Structure set to F."); } else { vsf_cmdio_write(p_sess, FTP_BADSTRU, "Bad STRU command."); } } else if (str_equal_text(&p_sess->ftp_cmd_str, "MODE")) { str_upper(&p_sess->ftp_arg_str); if (str_equal_text(&p_sess->ftp_arg_str, "S")) { vsf_cmdio_write(p_sess, FTP_MODEOK, "Mode set to S."); } else { vsf_cmdio_write(p_sess, FTP_BADMODE, "Bad MODE command."); } } else if (str_equal_text(&p_sess->ftp_cmd_str, "STOU")) { handle_stou(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "ALLO")) { vsf_cmdio_write(p_sess, FTP_ALLOOK, "ALLO command ignored."); } else if (str_equal_text(&p_sess->ftp_cmd_str, "REIN")) { vsf_cmdio_write(p_sess, FTP_COMMANDNOTIMPL, "REIN not implemented."); } else if (str_equal_text(&p_sess->ftp_cmd_str, "ACCT")) { vsf_cmdio_write(p_sess, FTP_COMMANDNOTIMPL, "ACCT not implemented."); } else if (str_equal_text(&p_sess->ftp_cmd_str, "SMNT")) { vsf_cmdio_write(p_sess, FTP_COMMANDNOTIMPL, "SMNT not implemented."); } else if (str_equal_text(&p_sess->ftp_cmd_str, "FEAT")) { vsf_cmdio_write_hyphen(p_sess, FTP_FEAT, "Features:"); vsf_cmdio_write_raw(p_sess, " MDTM\r\n"); vsf_cmdio_write_raw(p_sess, " REST STREAM\r\n"); vsf_cmdio_write_raw(p_sess, " SIZE\r\n"); vsf_cmdio_write(p_sess, FTP_FEAT, "End"); } else if (str_equal_text(&p_sess->ftp_cmd_str, "OPTS")) { vsf_cmdio_write(p_sess, FTP_BADOPTS, "Option not understood."); } else if (str_equal_text(&p_sess->ftp_cmd_str, "STAT") && str_isempty(&p_sess->ftp_arg_str)) { handle_stat(p_sess); } else if (tunable_dirlist_enable && str_equal_text(&p_sess->ftp_cmd_str, "STAT")) { handle_stat_file(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "PASV") || str_equal_text(&p_sess->ftp_cmd_str, "PORT") || str_equal_text(&p_sess->ftp_cmd_str, "STOR") || str_equal_text(&p_sess->ftp_cmd_str, "MKD") || str_equal_text(&p_sess->ftp_cmd_str, "XMKD") || str_equal_text(&p_sess->ftp_cmd_str, "RMD") || str_equal_text(&p_sess->ftp_cmd_str, "XRMD") || str_equal_text(&p_sess->ftp_cmd_str, "DELE") || str_equal_text(&p_sess->ftp_cmd_str, "RNFR") || str_equal_text(&p_sess->ftp_cmd_str, "RNTO") || str_equal_text(&p_sess->ftp_cmd_str, "SITE") || str_equal_text(&p_sess->ftp_cmd_str, "APPE") || str_equal_text(&p_sess->ftp_cmd_str, "EPSV") || str_equal_text(&p_sess->ftp_cmd_str, "EPRT") || str_equal_text(&p_sess->ftp_cmd_str, "RETR") || str_equal_text(&p_sess->ftp_cmd_str, "LIST") || str_equal_text(&p_sess->ftp_cmd_str, "NLST") || str_equal_text(&p_sess->ftp_cmd_str, "STOU") || str_equal_text(&p_sess->ftp_cmd_str, "ALLO") || str_equal_text(&p_sess->ftp_cmd_str, "REIN") || str_equal_text(&p_sess->ftp_cmd_str, "ACCT") || str_equal_text(&p_sess->ftp_cmd_str, "SMNT") || str_equal_text(&p_sess->ftp_cmd_str, "FEAT") || str_equal_text(&p_sess->ftp_cmd_str, "OPTS") || str_equal_text(&p_sess->ftp_cmd_str, "STAT")) { vsf_cmdio_write(p_sess, FTP_NOPERM, "Permission denied."); } else { vsf_cmdio_write(p_sess, FTP_BADCMD, "Unknown command."); } } }
static apr_status_t ftp_protocol_loop(struct lfd_sess * sess) { apr_status_t rc = APR_SUCCESS; int rnfrto; // "rename from" and "rename to" should go togheter char * temp_name; temp_name = NULL; rnfrto = 0; while(APR_SUCCESS == rc) { apr_pool_clear(sess->loop_pool); rc = lfd_cmdio_get_cmd_and_arg(sess, &sess->ftp_cmd_str, &sess->ftp_arg_str); if(APR_SUCCESS != rc) return rc; // special case if(lfd_cmdio_cmd_equals(sess, "RNTO")) { if(rnfrto) { rnfrto = 0; rc = handle_rnto(sess, temp_name); } else rc = handle_bad_rnto(sess); continue; } // here we treat all the other cases if(rnfrto){ rnfrto = 0; rc = handle_bad_rnto(sess); continue; } if(lfd_cmdio_cmd_equals(sess, "PASV")) { rc = handle_pasv(sess); } else if(lfd_cmdio_cmd_equals(sess, "SYST")) { rc = handle_syst(sess); } else if(lfd_cmdio_cmd_equals(sess, "USER")) { rc = handle_user(sess); } else if(lfd_cmdio_cmd_equals(sess, "PASS")) { rc = handle_pass(sess); } else if(lfd_cmdio_cmd_equals(sess, "QUIT")) { rc = handle_quit(sess); return rc; } else if(lfd_cmdio_cmd_equals(sess, "ABOR")) { rc = handle_abort(sess); } else if(lfd_cmdio_cmd_equals(sess, "PORT")) { rc = handle_port(sess); } else if(lfd_cmdio_cmd_equals(sess, "RMD")) { rc = handle_dir_remove(sess); } else if(lfd_cmdio_cmd_equals(sess, "MKD")) { rc = handle_dir_create(sess); } else if(lfd_cmdio_cmd_equals(sess, "PWD")) { rc = handle_pwd(sess); } else if(lfd_cmdio_cmd_equals(sess, "CWD")) { rc = handle_cwd(sess); } else if(lfd_cmdio_cmd_equals(sess, "CDUP")) { rc = handle_cdup(sess); } else if(lfd_cmdio_cmd_equals(sess, "RNFR")) { rc = handle_rnfr(sess, &temp_name); if(APR_SUCCESS == rc && NULL != temp_name) rnfrto = 1; } else if(lfd_cmdio_cmd_equals(sess, "TYPE")) { rc = handle_type(sess); } else if(lfd_cmdio_cmd_equals(sess, "RETR")) { rc = handle_retr(sess); } else if(lfd_cmdio_cmd_equals(sess, "STOR")) { rc = handle_stor(sess); } else if(lfd_cmdio_cmd_equals(sess, "DELE")) { rc = handle_dele(sess); } else if(lfd_cmdio_cmd_equals(sess, "STOU")) { rc = handle_stou(sess); } else if(lfd_cmdio_cmd_equals(sess, "LIST")) { rc = handle_list(sess); } else if(lfd_cmdio_cmd_equals(sess, "FEAT")) { rc = handle_feat(sess); } else if(lfd_cmdio_cmd_equals(sess, "APPE")) { rc = handle_appe(sess); } else if(lfd_cmdio_cmd_equals(sess, "SITE")) { rc = handle_site(sess); } else if(lfd_cmdio_cmd_equals(sess, "ALLO")) { rc = lfd_cmdio_write(sess, FTP_ALLOOK, "ALLO command ignored."); } else if(lfd_cmdio_cmd_equals(sess, "REIN")) { rc = lfd_cmdio_write(sess, FTP_COMMANDNOTIMPL, "REIN not implemented."); } else if(lfd_cmdio_cmd_equals(sess, "ACCT")) { rc = lfd_cmdio_write(sess, FTP_COMMANDNOTIMPL, "ACCT not implemented."); } else if(lfd_cmdio_cmd_equals(sess, "SMNT")) { rc = lfd_cmdio_write(sess, FTP_COMMANDNOTIMPL, "SMNT not implemented."); } else //default { printf("The cmd [%s] has no installed handler! \n", sess->ftp_cmd_str); if(NULL != sess->ftp_arg_str) printf("The cmd args were [%s] \n", sess->ftp_arg_str); lfd_cmdio_write(sess, FTP_COMMANDNOTIMPL, "Command not implemented."); } } return rc; }
KOKKOS_INLINE_FUNCTION static handle_type const assign( handle_type const & arg_handle , size_t offset ) { return handle_type(arg_handle,offset) ; }