3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 unsigned login_msg_len
;
41 /*int tty_update (client_t *c)
45 for (i = 0; i < 2000; i ++)
46 tty[i] = c->tty[(i*2)+1];
53 login_msg
= (char *) malloc (sizeof (char) * 100);
58 memcpy (login_msg
, "�����!", 6);
59 memcpy (login_msg
+6, "ZeX/OS telnet deamon\n�\n", 23);
67 buf
= (char *) malloc (sizeof (char) * 128);
73 tty
= (char *) malloc (sizeof (char) * 101);
79 tty2
= (char *) malloc (sizeof (char) * 101);
89 int console_motd (client_t
*c
)
91 client_send (c
, login_msg
, login_msg_len
);
93 c
->state
= CLIENT_STATE_LOGIN
;
98 int console_login (client_t
*c
)
105 /* int ret = client_recv (c, login_buf, login_buf_len);
108 memcpy (buf+c->buf_len, login_buf, ret);
110 buf[c->buf_len] = '\0';
117 int cislo = login_buf[0];
119 itoa (cislo, tty, 10);
121 if (login_buf[1] == 0 && login_buf[0] == 13)
126 if (buf[c->buf_len-1] == '\n' || log) {
127 buf[c->buf_len-1] = '\0';
129 puts ("nekdo zadal login: '");
130 puts (buf+c->buf_len-6);
133 if (!strcmp (buf+c->buf_len-6, "root")) {
134 puts ("New user was succefully logged !\n");
136 //c->tty = (char *) tty_init ();
139 // c->state = CLIENT_STATE_DONE;
143 c->state = CLIENT_STATE_READY;
150 c
->state
= CLIENT_STATE_READY
;
155 int console_handler (client_t
*c
)
157 int ret
= client_recv (c
, tty
, 100);
160 puts ("Some client was disconnected\n");
161 c
->state
= CLIENT_STATE_DONE
;
167 for (i
= 0; i
< (unsigned) ret
; i
++) {
168 /*int cislo = tty[i];
170 itoa (cislo, tty2, 10);
171 puts (tty2); puts ("|");*/
172 if (tty
[i
] == 13 && tty
[i
+1] == 10) {
187 unsigned len
= read (1, tty2
, 100);
190 /*if (!strncmp (tty2, tty, ret))
191 clients_send (tty2+ret, len-ret);
193 /*if (strlen (tty2)) {
201 clients_send (tty2
, len
);