Roxen.git / server / plugins / protocols / ftp.pike

version» Context lines:

Roxen.git/server/plugins/protocols/ftp.pike:1:   // This is a roxen protocol module.   // Copyright © 1997 - 2001, Roxen IS.      /*    * FTP protocol mk 2    * -  * $Id: ftp.pike,v 2.88 2004/04/04 00:01:59 mani Exp $ +  * $Id: ftp.pike,v 2.89 2004/04/04 14:24:52 mani Exp $    *    * Henrik Grubbström <grubba@roxen.com>    */      /*    * TODO:    *    * How much is supposed to be logged?    */   
Roxen.git/server/plugins/protocols/ftp.pike:141:    void send_result(mapping|void result)    {    if (mappingp(result) && my_fd && my_fd->done) {    my_fd->done(result);    return;    }       error("Async sending with send_result() not supported yet.\n");    }    -  object(RequestID2) clone_me() +  RequestID2 clone_me()    { -  object(RequestID2) o = this_object(); -  return(object_program(o)(o)); +  return this_program(this);    }       void end()    {    }       constant __num = ({ 0 });    int _num;       void destroy()
Roxen.git/server/plugins/protocols/ftp.pike:171:    void create(object|void m_rid)    {   #ifdef FTP_REQUESTID_DEBUG    _num = ++__num[0];    report_debug("REQUESTID: New request id #%d.\n", _num);   #else    DWRITE("REQUESTID: New request id.\n");   #endif       if (m_rid) { -  object o = this_object(); +  this_program o = this;    foreach(indices(m_rid), string var) {    if (!(< "create", "connection", "configuration",    "__INIT", "clone_me", "end", "ready_to_receive",    "send", "scan_for_query", "send_result", "misc",    "url_base", "set_response_header",    "add_response_header", "set_output_charset",    "adjust_for_config_path", "PrefLanguages",    "destroy", "_num", "__num">)[var]) {   #ifdef FTP2_DEBUG    if (catch {
Roxen.git/server/plugins/protocols/ftp.pike:1924:    if (file->data) {    file->data = replace(file->data,    ({ "\r\n", "\n", "\r" }),    ({ "\r\n", "\r\n", "\r\n" }));    }    if(objectp(file->file) && file->file->set_nonblocking)    {    // The list_stream object doesn't support nonblocking I/O,    // but converts to ASCII anyway, so we don't have to do    // anything about it. -  file->file = ToAsciiWrapper(file->file, 0, this_object()); +  file->file = ToAsciiWrapper(file->file, 0, this);    }    break;    case "E":    // EBCDIC handling here.    if (file->data) {    object conv = Locale.Charset.encoder("EBCDIC-US", "");    file->data = conv->feed(file->data)->drain();    }    if(objectp(file->file) && file->file->set_nonblocking)    {    // The list_stream object doesn't support nonblocking I/O,    // but converts to ASCII anyway, so we don't have to do    // anything about it.    // But EBCDIC doen't work... -  file->file = ToEBCDICWrapper(file->file, 0, this_object()); +  file->file = ToEBCDICWrapper(file->file, 0, this);    }    break;    default:    // "I" and "L"    // Binary -- no conversion needed.    if (objectp(file->file) && file->file->set_nonblocking) { -  file->file = BinaryWrapper(file->file, 0, this_object()); +  file->file = BinaryWrapper(file->file, 0, this);    }    break;    }       object throttler=session->throttler;    object pipe;    pipe = core.get_shuffler( fd );    if( conf ) -  conf->connection_add( this_object(), pipe ); +  conf->connection_add( this, pipe );       if( throttler || conf->throttler )    pipe->set_throttler( throttler || conf->throttler );       pipe->set_done_callback(    lambda( Shuffler.Shuffle r, int reason ) {    send_done_callback( fd, session, r->sent_data() );    } );    master_session->file = session->file = file;    if(stringp(file->data)) {
Roxen.git/server/plugins/protocols/ftp.pike:1996:    modes[mode], args) }));    } else {    send(425, ({ "Can't build data connect: Connection refused." }));    return;    }       data = data && sizeof(data) && data;       switch(mode) {    case "A": -  fd = FromAsciiWrapper(fd, data, this_object()); +  fd = FromAsciiWrapper(fd, data, this);    break;    case "E": -  fd = FromEBCDICWrapper(fd, data, this_object()); +  fd = FromEBCDICWrapper(fd, data, this);    return;    default: // "I" and "L"    // Binary, no need to do anything. -  fd = BinaryWrapper(fd, data, this_object()); +  fd = BinaryWrapper(fd, data, this);    break;    }       object session = RequestID2(master_session);    session->method = "PUT"; -  session->my_fd = PutFileWrapper(fd, session, this_object()); +  session->my_fd = PutFileWrapper(fd, session, this);    session->misc->len = 0x7fffffff;       if (open_file(args, session, "STOR")) {    if (!(session->file->pipe)) {    if (fd) {    BACKEND_CLOSE(fd);    }    switch(session->file->error) {    case 401:    send(530, ({ sprintf("%s: Need account for storing files.", args)}));
Roxen.git/server/plugins/protocols/ftp.pike:2428:    flags &= ~LS_FLAG_R;    }    if (flags & (LS_FLAG_f|LS_FLAG_C|LS_FLAG_m)) {    flags &= ~LS_FLAG_l;    }    if (flags & LS_FLAG_C) {    flags &= ~LS_FLAG_m;    }       file->file = LSFile(cwd, argv[1..], flags, session, -  file->mode, this_object()); +  file->mode, this);    }       if (!file->full_path) {    file->full_path = argv[0];    }    session->file = file;    connect_and_send(file, session);    }       /*
Roxen.git/server/plugins/protocols/ftp.pike:3345:    }       send(200, ({ "Ok, gottcha!"}));    master_session->client = args/" " - ({ "" });    }       void ftp_FEAT(string args)    {    array a = sort(Array.filter(indices(cmd_help),    lambda(string s) { -  return(this_object()["ftp_"+s]); +  return(this["ftp_"+s]);    }));    a = Array.map(a,    lambda(string s) {    return(([ "REST":"REST STREAM",    "MLST":"MLST UNIX.mode;size;type;modify;charset;media-type",    "MLSD":"",    ])[s] || s);    }) - ({ "" });       send(211, ({ "The following features are supported:" }) + a +
Roxen.git/server/plugins/protocols/ftp.pike:3469:    }       void ftp_HELP(string args)    {    if ((< "", 0 >)[args]) {    send(214, ({    "The following commands are recognized (* =>'s unimplemented):",    @(sprintf(" %#70s", sort(Array.map(indices(cmd_help),    lambda(string s) {    return(upper_case(s)+ -  (this_object()["ftp_"+s]? +  (this["ftp_"+s]?    " ":"* "));    }))*"\n")/"\n"),    @(FTP2_XTRA_HELP),    }));    } else if ((args/" ")[0] == "SITE") {    array(string) a = (upper_case(args)/" ")-({""});    if (sizeof(a) == 1) {    send(214, ({ "The following SITE commands are recognized:",    @(sprintf(" %#70s", sort(indices(site_help))*"\n")/"\n")    }));    } else if (site_help[a[1]]) {    send(214, ({ sprintf("Syntax: SITE %s %s", a[1], site_help[a[1]]) }));    } else {    send(504, ({ sprintf("Unknown SITE command %s.", a[1]) }));    }    } else {    args = upper_case(args);    if (cmd_help[args]) {    send(214, ({ sprintf("Syntax: %s %s%s", args,    cmd_help[args], -  (this_object()["ftp_"+args]? +  (this["ftp_"+args]?    "":"; unimplemented")) }));    } else {    send(504, ({ sprintf("Unknown command %s.", args) }));    }    }    }       void ftp_SITE(string args)    {    // Extended commands.
Roxen.git/server/plugins/protocols/ftp.pike:3518:       array a = (args/" ") - ({ "" });       if (!sizeof(a)) {    ftp_HELP("SITE");    return;    }    a[0] = upper_case(a[0]);    if (!site_help[a[0]]) {    send(502, ({ sprintf("Bad SITE command: '%s'", a[0]) })); -  } else if (this_object()["ftp_SITE_"+a[0]]) { -  this_object()["ftp_SITE_"+a[0]](a[1..]); +  } else if (this["ftp_SITE_"+a[0]]) { +  this["ftp_SITE_"+a[0]](a[1..]);    } else {    send(502, ({ sprintf("SITE command '%s' is not currently supported.",    a[0]) }));    }    }       void ftp_SITE_CHMOD(array(string) args)    {    if (sizeof(args) < 2) {    send(501, ({ sprintf("'SITE CHMOD %s': incorrect arguments",
Roxen.git/server/plugins/protocols/ftp.pike:3692:       if (cmd_help[cmd]) {    if (!logged_in) {    if (!(< "REIN", "USER", "PASS", "SYST",    "ACCT", "QUIT", "ABOR", "HELP" >)[cmd]) {    send(530, ({ "You need to login first." }));       return;    }    } -  if (this_object()["ftp_"+cmd]) { +  if (this["ftp_"+cmd]) {    conf->requests++;   #if 1    mixed err;    if (err = catch { -  this_object()["ftp_"+cmd](args); +  this["ftp_"+cmd](args);    }) {    report_error("Internal server error in FTP2\n"    "Handling command %O\n%s\n",    line, describe_backtrace(err));    }   #else    core->handle(lambda(function f, string args, string line) {    mixed err;    if (err = catch {    f(args);    }) {    report_error("Internal server error in FTP2\n"    "Handling command %O\n%s\n",    line, describe_backtrace(err));    } -  }, this_object()["ftp_"+cmd], args, line); +  }, this["ftp_"+cmd], args, line);   #endif    } else {    send(502, ({ sprintf("'%s' is not currently supported.", cmd) }));    }    } else {    send(502, ({ sprintf("Unknown command '%s'.", cmd) }));    }       touch_me();    }