sig
  exception FTP_error of exn
  exception FTP_protocol_violation of string
  type cmd_state =
    [ `Init
    | `Pass_acct_seq
    | `Perm_failure
    | `Preliminary
    | `Proto_error
    | `Rename_seq
    | `Restart_seq
    | `Success
    | `Temp_failure
    | `User_acct_seq
    | `User_pass_seq ]
  type port =
    [ `Active of string * int * Unix.file_descr
    | `Passive of string * int
    | `Unspecified ]
  type form_code = [ `ASA | `Non_print | `Telnet ]
  type representation =
    [ `ASCII of Ftp_client.form_code option
    | `EBCDIC of Ftp_client.form_code option
    | `Image ]
  type structure = [ `File_structure | `Record_structure ]
  type transmission_mode = [ `Block_mode | `Stream_mode ]
  type ftp_state = {
    cmd_state : Ftp_client.cmd_state;
    ftp_connected : bool;
    ftp_data_conn : bool;
    ftp_user : string option;
    ftp_password : string option;
    ftp_account : string option;
    ftp_logged_in : bool;
    ftp_port : Ftp_client.port;
    ftp_repr : Ftp_client.representation;
    ftp_structure : Ftp_client.structure;
    ftp_trans : Ftp_client.transmission_mode;
    ftp_dir : string list;
    ftp_features : (string * string option) list option;
    ftp_options : (string * string option) list;
  }
  type cmd =
    [ `ACCT of string
    | `ALLO of int * int option
    | `APPE of
        string * (Ftp_client.ftp_state -> Ftp_data_endpoint.local_sender)
    | `CDUP
    | `CWD of string
    | `Connect
    | `DELE of string
    | `Dummy
    | `FEAT
    | `HELP of string option
    | `LIST of
        string option *
        (Ftp_client.ftp_state -> Ftp_data_endpoint.local_receiver)
    | `MDTM of string
    | `MKD of string
    | `MODE of Ftp_client.transmission_mode
    | `NLST of
        string option *
        (Ftp_client.ftp_state -> Ftp_data_endpoint.local_receiver)
    | `NOOP
    | `OPTS of string * string option
    | `PASS of string
    | `PASV
    | `PORT
    | `PWD
    | `QUIT
    | `REIN
    | `REST of string
    | `RETR of
        string * (Ftp_client.ftp_state -> Ftp_data_endpoint.local_receiver)
    | `RMD of string
    | `RNFR of string
    | `RNTO of string
    | `SITE of string
    | `SMNT of string
    | `STAT of string option
    | `STOR of
        string * (Ftp_client.ftp_state -> Ftp_data_endpoint.local_sender)
    | `STOU of unit -> Ftp_data_endpoint.local_sender
    | `STRU of Ftp_client.structure
    | `SYST
    | `TYPE of Ftp_client.representation
    | `USER of string ]
  type reply = int * string
  class ftp_client_pi :
    ?event_system:Unixqueue.event_system ->
    ?onempty:(Ftp_client.ftp_state -> unit) ->
    ?onclose:(unit -> unit) ->
    ?onerrorstate:(exn -> unit) ->
    ?onusererror:(exn -> unit) ->
    Unix.file_descr ->
    object
      method abort : unit -> unit
      method add_cmd :
        ?onreply:(Ftp_client.ftp_state -> Ftp_client.reply -> unit) ->
        Ftp_client.cmd -> unit
      method event_system : Unixqueue.event_system
      method ftp_state : Ftp_client.ftp_state
      method is_empty : bool
      method run : unit -> unit
      method send_abort : unit -> unit
      method state : unit Uq_engines.engine_state
    end
  module Action :
    sig
      type plan
      type action = Ftp_client.Action.plan -> unit
      val ftp_state : Ftp_client.Action.plan -> Ftp_client.ftp_state
      val execute :
        onreply:(Ftp_client.ftp_state -> Ftp_client.reply -> unit) ->
        onerror:(Ftp_client.ftp_state -> Ftp_client.reply -> unit) ->
        Ftp_client.ftp_client_pi -> Ftp_client.Action.action -> unit
      val empty : Ftp_client.Action.action
      val command : Ftp_client.cmd -> Ftp_client.Action.action
      val dyn_command : (unit -> Ftp_client.cmd) -> Ftp_client.Action.action
      val seq2 :
        Ftp_client.Action.action ->
        Ftp_client.Action.action -> Ftp_client.Action.action
      val full_seq2 :
        Ftp_client.Action.action ->
        (Ftp_client.reply -> Ftp_client.Action.action) ->
        Ftp_client.Action.action
      val seq : Ftp_client.Action.action list -> Ftp_client.Action.action
      val expect :
        Ftp_client.cmd_state ->
        Ftp_client.Action.action -> Ftp_client.Action.action
      val seq2_case :
        Ftp_client.Action.action ->
        (Ftp_client.cmd_state * Ftp_client.Action.action) list ->
        Ftp_client.Action.action
    end
  class type ftp_method =
    object
      method connect : (string * int) option
      method execute : Ftp_client.Action.action
    end
  exception FTP_method_temp_failure of int * string
  exception FTP_method_perm_failure of int * string
  exception FTP_method_unexpected_reply of int * string
  class connect_method : host:string -> ?port:int -> unit -> ftp_method
  class login_method :
    user:string ->
    get_password:(unit -> string) ->
    get_account:(unit -> string) -> unit -> ftp_method
  class walk_method :
    [ `Dir of string | `File of string | `Stay ] -> ftp_method
  type filename = [ `NVFS of string | `Verbatim of string ]
  class get_method :
    file:Ftp_client.filename ->
    representation:Ftp_client.representation ->
    store:(Ftp_client.ftp_state -> Ftp_data_endpoint.local_receiver) ->
    unit -> ftp_method
  class invoke_method :
    command:Ftp_client.cmd ->
    process_result:(Ftp_client.ftp_state -> int * string -> unit) ->
    unit -> ftp_method
  class set_structure_method : Ftp_client.structure -> ftp_method
  class set_mode_method : Ftp_client.transmission_mode -> ftp_method
  class rename_method :
    file_from:Ftp_client.filename ->
    file_to:Ftp_client.filename -> unit -> ftp_method
  class mkdir_method : Ftp_client.filename -> ftp_method
  class rmdir_method : Ftp_client.filename -> ftp_method
  class delete_method : Ftp_client.filename -> ftp_method
  class list_method :
    dir:Ftp_client.filename ->
    representation:Ftp_client.representation ->
    store:(Ftp_client.ftp_state -> Ftp_data_endpoint.local_receiver) ->
    unit -> ftp_method
  class nlst_method :
    dir:Ftp_client.filename ->
    representation:Ftp_client.representation ->
    store:(Ftp_client.ftp_state -> Ftp_data_endpoint.local_receiver) ->
    unit -> ftp_method
  class mdtm_method :
    file:Ftp_client.filename ->
    process_result:(float -> unit) -> unit -> ftp_method
  class ftp_client :
    ?event_system:Unixqueue.event_system ->
    ?onempty:(unit -> unit) ->
    unit ->
    object
      method abort : unit -> unit
      method add :
        ?onsuccess:(unit -> unit) ->
        ?onerror:(exn -> unit) -> Ftp_client.ftp_method -> unit
      method event_system : Unixqueue.event_system
      method request_notification : (unit -> bool) -> unit
      method run : unit -> unit
      method state : unit Uq_engines.engine_state
    end
end