-module(gftp@status). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/gftp/status.gleam"). -export([describe/1, from_int/1, to_int/1]). -export_type([status/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC(" This module exposes all the \"standard\" error codes defined in the File transfer protocol\n"). -type status() :: restart_marker | ready_minute | already_open | about_to_send | command_ok | command_not_implemented | system | directory | file | help | name | ready | closing | data_connection_open | closing_data_connection | passive_mode | long_passive_mode | extended_passive_mode | logged_in | logged_out | logout_ack | auth_ok | requested_file_action_ok | path_created | need_password | login_need_account | request_file_pending | not_available | cannot_open_data_connection | transfer_aborted | invalid_credentials | host_unavailable | request_file_action_ignored | action_aborted | requested_action_not_taken | bad_command | bad_arguments | not_implemented | bad_sequence | not_implemented_parameter | not_logged_in | storing_need_account | file_unavailable | page_type_unknown | exceeded_storage | bad_filename | {unknown, integer()}. -file("src/gftp/status.gleam", 63). ?DOC(" Converts a status code to its descriptive string representation. This is useful for logging and debugging purposes.\n"). -spec describe(status()) -> binary(). describe(Status) -> case Status of restart_marker -> <<"restart marker reply"/utf8>>; ready_minute -> <<"service ready in (n) minutes"/utf8>>; already_open -> <<"data connection already open transfer starting"/utf8>>; about_to_send -> <<"file status okay about to open data connection"/utf8>>; command_ok -> <<"command okay"/utf8>>; command_not_implemented -> <<"command not implemented"/utf8>>; system -> <<"system status or system help reply"/utf8>>; directory -> <<"directory status"/utf8>>; file -> <<"file status"/utf8>>; help -> <<"help message"/utf8>>; name -> <<"NAME system type"/utf8>>; ready -> <<"service ready for new user"/utf8>>; closing -> <<"service closing control connection"/utf8>>; data_connection_open -> <<"data connection open; no transfer in progress"/utf8>>; closing_data_connection -> <<"closing data connection"/utf8>>; passive_mode -> <<"entering passive mode"/utf8>>; long_passive_mode -> <<"entering long passive mode"/utf8>>; extended_passive_mode -> <<"entering extended passive mode"/utf8>>; logged_in -> <<"user logged in proceed. Logged out if appropriate."/utf8>>; logged_out -> <<"user logged out; service terminated"/utf8>>; logout_ack -> <<"logout command noted will complete when transfer done"/utf8>>; auth_ok -> <<"specifies that the server accepts the authentication mechanism specified by the client"/utf8>>; requested_file_action_ok -> <<"requested file action okay"/utf8>>; path_created -> <<"pathname created"/utf8>>; need_password -> <<"user name okay need password"/utf8>>; login_need_account -> <<"need account for login"/utf8>>; request_file_pending -> <<"requested file action pending further information"/utf8>>; not_available -> <<"service not available closing control connection"/utf8>>; cannot_open_data_connection -> <<"can't open data connection"/utf8>>; transfer_aborted -> <<"connection closed; transfer aborted"/utf8>>; invalid_credentials -> <<"invalid username or password"/utf8>>; host_unavailable -> <<"requested host unavailable"/utf8>>; request_file_action_ignored -> <<"requested file action not taken"/utf8>>; action_aborted -> <<"requested action aborted"/utf8>>; requested_action_not_taken -> <<"requested action not taken"/utf8>>; bad_command -> <<"syntax error command unrecognized"/utf8>>; bad_arguments -> <<"syntax error in parameters or arguments"/utf8>>; not_implemented -> <<"command not implemented"/utf8>>; bad_sequence -> <<"bad sequence of commands"/utf8>>; not_implemented_parameter -> <<"command not implemented for that parameter"/utf8>>; not_logged_in -> <<"user not logged in"/utf8>>; storing_need_account -> <<"need account for storing files"/utf8>>; file_unavailable -> <<"requested action not taken; file unavailable"/utf8>>; page_type_unknown -> <<"requested action aborted; page type unknown"/utf8>>; exceeded_storage -> <<"requested file action aborted; exceeded storage allocation"/utf8>>; bad_filename -> <<"requested action not taken; file name not allowed"/utf8>>; {unknown, _} -> <<"unknown error code"/utf8>> end. -file("src/gftp/status.gleam", 118). ?DOC(" Converts an integer status code to its corresponding `Status` variant. If the code is not recognized, it returns `Unknown`.\n"). -spec from_int(integer()) -> status(). from_int(Code) -> case Code of 110 -> restart_marker; 120 -> ready_minute; 125 -> already_open; 150 -> about_to_send; 200 -> command_ok; 202 -> command_not_implemented; 211 -> system; 212 -> directory; 213 -> file; 214 -> help; 215 -> name; 220 -> ready; 221 -> closing; 225 -> data_connection_open; 226 -> closing_data_connection; 227 -> passive_mode; 228 -> long_passive_mode; 229 -> extended_passive_mode; 230 -> logged_in; 231 -> logged_out; 232 -> logout_ack; 234 -> auth_ok; 250 -> requested_file_action_ok; 257 -> path_created; 331 -> need_password; 332 -> login_need_account; 350 -> request_file_pending; 421 -> not_available; 425 -> cannot_open_data_connection; 426 -> transfer_aborted; 430 -> invalid_credentials; 434 -> host_unavailable; 450 -> request_file_action_ignored; 451 -> action_aborted; 452 -> requested_action_not_taken; 500 -> bad_command; 501 -> bad_arguments; 502 -> not_implemented; 503 -> bad_sequence; 504 -> not_implemented_parameter; 530 -> not_logged_in; 532 -> storing_need_account; 550 -> file_unavailable; 551 -> page_type_unknown; 552 -> exceeded_storage; 553 -> bad_filename; Code@1 -> {unknown, Code@1} end. -file("src/gftp/status.gleam", 171). ?DOC(" Converts a `Status` variant to its corresponding integer status code.\n"). -spec to_int(status()) -> integer(). to_int(Status) -> case Status of restart_marker -> 110; ready_minute -> 120; already_open -> 125; about_to_send -> 150; command_ok -> 200; command_not_implemented -> 202; system -> 211; directory -> 212; file -> 213; help -> 214; name -> 215; ready -> 220; closing -> 221; data_connection_open -> 225; closing_data_connection -> 226; passive_mode -> 227; long_passive_mode -> 228; extended_passive_mode -> 229; logged_in -> 230; logged_out -> 231; logout_ack -> 232; auth_ok -> 234; requested_file_action_ok -> 250; path_created -> 257; need_password -> 331; login_need_account -> 332; request_file_pending -> 350; not_available -> 421; cannot_open_data_connection -> 425; transfer_aborted -> 426; invalid_credentials -> 430; host_unavailable -> 434; request_file_action_ignored -> 450; action_aborted -> 451; requested_action_not_taken -> 452; bad_command -> 500; bad_arguments -> 501; not_implemented -> 502; bad_sequence -> 503; not_implemented_parameter -> 504; not_logged_in -> 530; storing_need_account -> 532; file_unavailable -> 550; page_type_unknown -> 551; exceeded_storage -> 552; bad_filename -> 553; {unknown, Code} -> Code end.