diff --git a/doc/exit_codes.txt b/doc/exit_codes.txt new file mode 100644 index 0000000..9071454 --- /dev/null +++ b/doc/exit_codes.txt @@ -0,0 +1,11 @@ +The exit codes of rdesktop are: + +0 Everything went well. Specifically, the server sent a + RDP_PDU_DEACTIVATE which seems to be a signal that the + session has ended normally. + +1 Usage error, i.e. wrong commandline option, invalid hostname + or similar. + +2 End of connection by other reason than received + RDP_PDU_DEACTIVATE. \ No newline at end of file diff --git a/proto.h b/proto.h index 95c47b8..0364a10 100644 --- a/proto.h +++ b/proto.h @@ -75,7 +75,7 @@ void process_colour_pointer_pdu(STREAM s); void process_cached_pointer_pdu(STREAM s); void process_bitmap_updates(STREAM s); void process_palette(STREAM s); -void rdp_main_loop(void); +BOOL rdp_main_loop(void); BOOL rdp_connect(char *server, uint32 flags, char *domain, char *password, char *command, char *directory); void rdp_disconnect(void); diff --git a/rdesktop.c b/rdesktop.c index 4170764..6bfcd33 100644 --- a/rdesktop.c +++ b/rdesktop.c @@ -149,7 +149,7 @@ main(int argc, char *argv[]) char password[16]; char shell[128]; char directory[32]; - BOOL prompt_password; + BOOL prompt_password, rdp_retval = False; struct passwd *pw; uint32 flags; char *p; @@ -366,6 +366,7 @@ main(int argc, char *argv[]) #ifdef RDP2VNC rdp2vnc_connect(server, flags, domain, password, shell, directory); + return 0; #else if (!ui_init()) @@ -384,7 +385,7 @@ main(int argc, char *argv[]) if (ui_create_window()) { - rdp_main_loop(); + rdp_retval = rdp_main_loop(); ui_destroy_window(); } @@ -392,9 +393,13 @@ main(int argc, char *argv[]) rdp_disconnect(); ui_deinit(); + if (True == rdp_retval) + return 0; + else + return 2; + #endif - return 0; } #ifdef EGD_SOCKET diff --git a/rdp.c b/rdp.c index e362097..314f781 100644 --- a/rdp.c +++ b/rdp.c @@ -849,7 +849,7 @@ process_data_pdu(STREAM s) } /* Process incoming packets */ -void +BOOL rdp_main_loop(void) { uint8 type; @@ -864,6 +864,8 @@ rdp_main_loop(void) break; case RDP_PDU_DEACTIVATE: + DEBUG(("RDP_PDU_DEACTIVATE\n")); + return True; break; case RDP_PDU_DATA: @@ -877,6 +879,7 @@ rdp_main_loop(void) unimpl("PDU %d\n", type); } } + return False; } /* Establish a connection up to the RDP layer */