"Fossies" - the Fresh Open Source Software Archive

Member "mod_ftp-0.9.6/modules/ftp/ftp_request.c" (28 May 2009, 2744 Bytes) of package /linux/www/apache_httpd_modules/old/mod_ftp-0.9.6-beta.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ftp_request.c" see the Fossies "Dox" file reference documentation.

    1 /* Licensed to the Apache Software Foundation (ASF) under one or more
    2  * contributor license agreements.  See the NOTICE file distributed with
    3  * this work for additional information regarding copyright ownership.
    4  * The ASF licenses this file to You under the Apache License, Version 2.0
    5  * (the "License"); you may not use this file except in compliance with
    6  * the License.  You may obtain a copy of the License at
    7  *
    8  *     http://www.apache.org/licenses/LICENSE-2.0
    9  *
   10  * Unless required by applicable law or agreed to in writing, software
   11  * distributed under the License is distributed on an "AS IS" BASIS,
   12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   13  * See the License for the specific language governing permissions and
   14  * limitations under the License.
   15  */
   16 
   17 /*
   18  * Original Copyright (c) 2005 Covalent Technologies
   19  *
   20  * FTP Protocol module for Apache 2.0
   21  */
   22 
   23 #include "mod_ftp.h"
   24 #include "ftp_internal.h"
   25 
   26 #ifndef apr_time_from_sec
   27 #define apr_time_from_sec(sec) ((apr_time_t)(sec) * APR_USEC_PER_SEC)
   28 #endif
   29 
   30 /*
   31  * ftp_process_request: Called after the request is read.  This function
   32  *                      will process the request, and call the correct
   33  *                      command handler, send the response and log the
   34  *                      transaction.
   35  *
   36  * Arguments: r - The request to be processed.
   37  *            fc - The ftp connection record associated with this request.
   38  *
   39  * Returns: Nothing.
   40  */
   41 void ftp_process_request(request_rec *r)
   42 {
   43     ftp_connection *fc = ftp_get_module_config(r->connection->conn_config);
   44     ftp_server_config *fsc = ftp_get_module_config(r->server->module_config);
   45     int res;
   46 
   47     fc->traffic += r->read_length;
   48     fc->response_notes = "";
   49 
   50     apr_table_setn(r->subprocess_env, "ftp_transfer_ok", "1");
   51     res = ftp_run_cmd(r, r->method);
   52 
   53     /* If the passive connection has been open too long, close it */
   54     if ((fc->passive_created != -1) && fc->csock
   55         && (res != FTP_REPLY_DATA_CLOSE)
   56         && (res != FTP_REPLY_CONTROL_CLOSE)
   57         && (apr_time_now() - fc->passive_created
   58             > apr_time_from_sec(fsc->timeout_data))) {
   59         ap_log_error(APLOG_MARK, APLOG_WARNING, 0, r->server,
   60           "Timeout waiting to use passive port (closing data connection).");
   61         ftp_reset_dataconn(fc);
   62     }
   63 
   64     ftp_send_response(r, res);
   65 
   66     ap_run_log_transaction(r);
   67 }
   68 
   69 apr_status_t ftp_protocol_filter(ap_filter_t *f, apr_bucket_brigade *b,
   70                                 ap_input_mode_t mode, apr_read_type_e block,
   71                                               apr_off_t readbytes)
   72 {
   73     apr_bucket *eos;
   74 
   75     eos = apr_bucket_eos_create(b->bucket_alloc);
   76     APR_BRIGADE_INSERT_HEAD(b, eos);
   77 
   78     return APR_SUCCESS;
   79 }