* @ @ / 000000b01 *)
(* @ /// procedure t_ftp.WndProc (var Msg: TMessage); *) procedure t_ftp.WndProc (var Msg: TMessage); var temp_socket: TSocket; sockinfo: TSockAddr; begin if msg.msg <> uwm_socketevent 1 then inherited WndProc (Msg) else begin if msg.lparamhi = socket_error then else begin case msg.lparamlo of (* @ /// fd_accept: *) fd_accept: begin temp_socket: = f_socket; self.f_socket: = accept_socket_in (f_socket, sockinfo) ; close_socket (temp_socket); end; (* @ /// 0000000401 *) (* @ /// fd_write: *) fd_write: begin case f_mode_intern of tftp_download, tftp_getdir:; tftp_upload: do_write; end; end; (* @ / // 000000010B *) (* @ /// fd_read: *) fd_read: begin case f_mode_intern of tftp_download, tftp_getdir: do_read; tftp_upload:; end; end; (* @ /// 0000000201 *) fd_connect:; (* can be Ignored, A fd_write will come *) (* @ /// fd_close: *) fd_close: begin {case f_mode_intern of} {tftp_download;} {tftp_getdir: finish_getdd Ir;} {tftp_upload: finish_upload;} {end;} end; (* @ @ @ @ @ @ @ @ e; end; (* @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ 聽 000 000c01 *)
(* @ /// function t_ftp.getdirentry: t_filedata; *) function t_ftp.getdirentry: t_filedata; begin result: = empty_filedata; while (f_cur_dir_index (* @ /// function t_ftp.read_line_comm: string; *) function t_ftp.read_line_comm: string; begin result: = read_line (f_comm_socket); end; (* @ /// 0000000401 *) (* @ /// procedure t_ftp .Sendcommand; *) procedure t_ftp.sendcommand (const s: string); begin write_s (f_comm_socket, s # 13 # 10); if Assigned (f_tracer) THEN F_Tracer (s, tt_proto_sent); end; * @ @ @ @ @ @ @ @ @ 聽 000000c01 *) {TIME, REXEC, LPR - THE MOST USEFUL UNIX Services} (* @ /// Class T_TIME (T_TCPIP) *) (* @ /// constructor t_time.Create (Aowner: TComponent); *) constructor t_time.Create (Aowner: TComponent); begin inherited create (AOwner); f_Socket_number: = 37; f_time: = 0; f_timemode: = tzUTC; end; (* @ // / 0000000601 *) (* @ /// procedure t_time.action; *) procedure t_time.action; var ok: integer; b: byte; bias: integer; begin login; f_time: = 0; While Not Eof (f_socket) do begin read_var (f_socket) , B, 1, OK); IF OK = 1 THEN F_TIME: = f_TIME * 256 B; End; f_time: = f_TIME / 86400 Encodedate (1900, 1, 1); if f_timemode <> tzutc THEN Begin (* Alternative : Use systemtimeTotzspecificLocaltime, But Only Works in nt *) Bias: = timezonebias; f_time: = f_TIME-BIAS / 1440; (* Bias IN minutes *) end; end; (* @ @ @ @ @ @ @ @ / // 0000000310 *) (* @ /// class T_RCommon (t_tcpip) *) (* @ /// procedure t_rcommon.open_socket_out (var socket: TSocket; socket_number: smallint; ip_address: longint); *) procedure t_rcommon.open_socket_out ( var socket: TSocket; socket_number: smallint; ip_address: longint); begin close_socket (socket); socket: = create_Socket; bind_socket (socket, 512,1023); connect_socket (socket, socket_number, ip_address); end; (* @ // / 0000000113 *) (* @ /// procedure t_rcommon.action; *) procedure t_rcommon.action; var P: POINTER; OK, OK2: Inteder; Begin Login; While Not Eof (F_Socket) Do Begin Read_var (f_socket, f_buffer ^, buf_size, ok); p: = f_buffer; while ok> 0 do begin (* Just to Be Sure Everything Goes Into THE Stream *) ok2: = f_stream.write (p ^, ok); DEC (OK, OK2); P: = POINTER (longint (p) ok2); end; end; f_stream.seek (0, 0); * set the stream back to start *) logout; end; (* @ @ @ @ @ @ @ @ c cs @ @ rm) *) (* @ /// Constructor t_rexec.create (aowner: t_rexec.create (Aowner: tComponent); begin inherited create (aowner); f_socket_number: = 512; (* REXEC *) end; (* @ @ /// advancedure t_rexec.login; *) procedure t_rexec.login; begin inherited login; self.write_s (f_socket, f_user # 0); self.write_s (f_socket, f_pass # 0); Self.write_s (f_socket, f_command # 0); END; (* @ @ @ @ @ @ @ @ @ @ c c c ts *) (* @ /// constructor t_rsh.Create (Aowner: TComponent); *) constructor t_rsh.Create (Aowner: TComponent); begin inherited create (AOwner); f_Socket_number: = 514; (* rsh *) end; (* @ /// 0000000401 *) (* @ /// procedure t_rsh.login; *) procedure t_rsh.login; begin inherited login; self.write_s (f_socket, '0' # 0); (* port for stderr, nyi *) (* Must Be a Listening Port On The Client's Side, Withnin The Reserved Port Range 512..1023 *) Self.write_s (f_socket, f_user_r # 0); (* remote *) Self.Write_S (f_socket, f_user_l # 0); (* local *) Self.write_s (f_socket, f_command # 0); (* Command to Execute *) end; (* @ @ @ @ @ @ @ @ @ /// Class T_LPR (T_TCPIP) *) (* @ /// Constructor T_Lpr.create (Aowner: Tcomponent); *) Constructor T_lpr.create (Aowner: Tcomponent); Begin Inherited Create (Aowner); F_Socket_Number: = 515; F_PrinTType: = LP_ASCII; f_count: = 1; End; (* @ @ @ @ @ @ @ 000000060E *) (* @ /// procedure t_lpr.open_socket_out (var socket: TSocket; Socket_number: smallint; ip_address: longint); *) procedure t_lpr.open_socket_out (var socket: TSocket; Socket_number: smallint; ip_address: longint); begin close_socket (socket ); socket: = create_Socket; bind_socket (socket, 512,1023); connect_socket (socket, socket_number, ip_address); end; (* @ /// 0000000501 *) (* @ /// procedure t_lpr.action; *) procedure T_lpr.action; begin login; sendprintdata; logout; end; (* @ /// 0000000501 *) (* @ /// procedure t_lpr.sendprintdata; *) Procedure t_lpr.sendprintData; var OK: integer; i: integer; s : string; job_name: string; config_stream: tmemorystream; begin (* sanity checks *) ife (f_quence = ') or (f_count = 0) or (f_user =') THEN EXIT; S : = # 02 f_queue # 10; Write_s (f_socket, s); self.response; job_name: = INTOSTR (LPR_COUNT 1000); Job_Name: = COPY (JOB_NAME, LENGTH (JOB_NAME) -2, 3) my_hostname; * @ /// Collect and send the description data *) config_stream: = nil; try config_stream: = tmemorystream.c Reate; (* @ /// h originating host *) s: = 'h' ip2string (my_ip_address) # 10; stream_write_s (config_stream, s); (* @ /// 0000000120 *) (* @ /// P Responsible user *) s: = 'p' copy (f_user, 1, 31) # 10; stream_write_s (config_stream, s); (* @ /// *) (* @ /// m address to send the Mail to *) if f_user_mail <> '' TENBEGIN S: = 'm' f_user_mail # 10; stream_write_s (config_stream, s); end; (* @ @ @ @ /// j jobname (* @ /// j jobname For banner *) if f_jobname <> '' TENBEGIN S: = 'M' COPY (f_jobname, 1,99) # 10; stream_write_s (config_stream, s); End; (* @ @ @ @ @ /// C class name = host name of sender *) s: = 'c' copy (my_hostname, 1,99) # 10; stream_write_s (config_stream, s ); (* @ //// *) if f_banner dam s: = 'L' f_user # 10; stream_write_s (config_stream, s); end; (* @ // / 0000000303 *) (* @ /// t title (for lp_pr only) *) if f_title <> '' Then Begin s: = 't' copy (f_title, 1,79) # 10; stream_write_s (config_stream, s); end; (* @ @ @ @ @ @ @ /// THE PRINT Command itself *) case f_printtype of lp_plain: s: = 'l'; lp_ascii: s: = 'f'; lp_dvi: s : = 'd'; lp_plot: s: = 'g'; lp_ditroff: s: = 'n'; lp_ps: s: = 'o'; lp_pr: s: = 'p'; lp_fortran: s: = 'r' LP_TROFF: S: = 'T'; LP_RASTER: S: = 'V'; LP_CIF: S: = 'C'; END; S: = S JOB_NAME # 10; for i: = 1 to f_count do stream_write_s (config_stream , s); (* @ ////) (* @ /// u unlink the file after the printing *) s: = 'u' jobname # 10; stream_write_s (config_stream, s); (* @ // / *) (* @ /// send the data *) config_stream.seek (0, 0); (* set the stream back to start *) s: = # 02 INT Tostr (config_stream.size) # 10; Write_S (f_socket, s); self.response; ok: = 1; while ok> 0 do begin ok: = config_stream.read (f_buffer ^, buf_size); Write_buf (f_socket, f_buffer ^, ok); end; write_s (f_socket, # 0); (* finish the config data *) (* @ /// *) Finally config_stream.free; end; * (* @ /// send the data to print *) s: = # 03 INTOSTR (stream.size) 'DFA' JOB_NAME # 10; Write_S (f_socket, s); self.response; f_stream.seek (0); (* set the stream back to start *) OK: = 1; while ok> 0 do beg: = f_stream.read (f_buffer ^, buf_size); Write_buf (f_socket, f_buffer ^, ok); end; write_s (f_socket, # 0); (* finish the plot *) (* @ @ @ @) Inc (lpr_count); (* @ /// 0000001001001 *) (* @ /// procedure t_lpr.getQueuesttus (Detailed: boolean); *) Procedure T_lpr.getQueuesttus (Detailed: Boolean); VAR P: Pointer; OK, OK2: Integer; s: String; begin if (f_queue = '') THEN EXIT; if Detailed Then S: = # 04 f_queue # 10 else s: = # 03 f_queue # 10; Write_S (f_socket, s); while not eof (f_socket) DO Begin read_var (f_socket, f_buffer ^, buf_size, ok); p: = f_buffer; while ok> 0 do begin = f_stream.write (P ^, OK); DEC (OK, OK2); P: = POINTER (longint (p) ok2); end; end; f_stream.seek (0, 0); (* set the stream back to start *) end; (* @ // / 0000001503 * (* @ /// procedure t_lpr.response; *) procedure t_lpr.response; var B: BYTE; OK: Inteder; Begin Read_var (F_Socket, B, 1, OK); IF (OK <> 1) or (B <> 0) Then Raise EPROTOCOLERROR.CREATE ('Lpr', '', 999); End; (* @ @ @ @ @ {{j} {get status} (* @ @ @ @ @ @ @ @ @ @ 00 00 00