"Fossies" - the Fresh Open Source Software Archive

Member "mod_ftp-0.9.6/modules/ftp/ftp_log.c" (28 May 2009, 3061 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_log.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 /*
   27  * callbacks for mod_log_config.
   28  *
   29  * These callbacks extend mod_log_config by adding additional
   30  * % directives as follows:
   31  *
   32  * %..M  The mode that was used to transfer the file.
   33  *       A single character is printed, a (ascii) or b (binary)
   34  * %..F  Any action that was taken on the file (concationated as needed)
   35  *         C - file was compressed.
   36  *         U - file was uncompressed.
   37  *         T - file was tarred.
   38  *         _ - no action taken.
   39  * %..d  Direction the file was sent.
   40  *         o - outgoing
   41  *         i - incoming
   42  * %..W  How the file was accessed.
   43  *         r - real
   44  *         a - anonymous
   45  *         g - guest
   46  * %..S    Service name, usually 'ftp'
   47  * %..Z    Authentication method
   48  *         0 - no auth
   49  *         1 - rfc931 auth
   50  * %..Y    Authenticated user id
   51  *         * - if not available
   52  */
   53 
   54 const char *ftp_log_transfer_mode(request_rec *r, char *a)
   55 {
   56     ftp_connection *fc = ftp_get_module_config(r->connection->conn_config);
   57     if (fc->type == TYPE_A) {
   58         return "a";
   59     }
   60     else if (fc->type == TYPE_I) {
   61         return "b";
   62     }
   63     else {
   64         return "-";
   65     }
   66 }
   67 
   68 const char *ftp_log_action_flags(request_rec *r, char *a)
   69 {
   70     return "_";
   71 }
   72 
   73 const char *ftp_log_transfer_direction(request_rec *r, char *a)
   74 {
   75     if (strcmp(r->method, "RETR") == 0) {
   76         return "o";
   77     }
   78     else if (strcmp(r->method, "STOR") == 0 || strcmp(r->method, "APPE") == 0) {
   79         return "i";
   80     }
   81     else {
   82         return "-";
   83     }
   84 }
   85 
   86 const char *ftp_log_accessed_anonymously(request_rec *r, char *a)
   87 {
   88     if (r->user) {
   89         if (strcasecmp(r->user, "anonymous") == 0) {
   90             return "a";
   91         }
   92         else if (strcasecmp(r->user, "guest") == 0) {
   93             return "g";
   94         }
   95         else {
   96             return "r";
   97         }
   98     }
   99     else {
  100         return "n";
  101     }
  102 }
  103 
  104 const char *ftp_log_service_name(request_rec *r, char *a)
  105 {
  106     return apr_pstrdup(r->pool, "ftp");
  107 }
  108 
  109 const char *ftp_log_auth_method(request_rec *r, char *a)
  110 {
  111     return "0";
  112 }
  113 
  114 const char *ftp_log_auth_user_id(request_rec *r, char *a)
  115 {
  116     return "*";
  117 }