--- libaitcli/src/telnet.c 2012/07/22 22:37:08 1.3 +++ libaitcli/src/telnet.c 2013/05/30 09:16:42 1.4 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: telnet.c,v 1.3 2012/07/22 22:37:08 misho Exp $ +* $Id: telnet.c,v 1.4 2013/05/30 09:16:42 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 +Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -51,7 +51,8 @@ SUCH DAMAGE. /* - * cli_telnetRecv() Telnet receive commands, negotiate with telnet peer + * cli_telnetRecv() - Telnet receive commands, negotiate with telnet peer + * * @sock = socket for communication * @attr = received attributes list, must be free after use, but if NULL receive in binary mode * @nAttr = received attributes list size, if is NULL receive in binary mode @@ -137,7 +138,7 @@ cli_telnetRecv(int sock, struct telnetAttrs **attr, in ta.ta_cmd = buf[i]; if (SB > ta.ta_cmd) { (*nAttr)++; - *attr = io_realloc(*attr, sizeof(struct telnetAttrs) * *nAttr); + *attr = e_realloc(*attr, sizeof(struct telnetAttrs) * *nAttr); if (!*attr) { LOGERR; return -1; @@ -167,7 +168,7 @@ cmd_exit: ta.ta_opt = buf[i]; if (SB != ta.ta_cmd) { (*nAttr)++; - *attr = io_realloc(*attr, sizeof(struct telnetAttrs) * *nAttr); + *attr = e_realloc(*attr, sizeof(struct telnetAttrs) * *nAttr); if (!*attr) { LOGERR; return -1; @@ -192,7 +193,7 @@ opt_exit: ta.ta_sub[ta.ta_sublen] = 0; (*nAttr)++; - *attr = io_realloc(*attr, sizeof(struct telnetAttrs) * *nAttr); + *attr = e_realloc(*attr, sizeof(struct telnetAttrs) * *nAttr); if (!*attr) { LOGERR; return -1; @@ -203,7 +204,7 @@ opt_exit: ta.ta_sub[ta.ta_sublen++] = buf[i]; } else { cli_SetErr(EPROTONOSUPPORT, "Protocol limitation in sub-option to %d!", MAX_SUB_LEN); - io_free(*attr); + e_free(*attr); *nAttr = 0; return -1; } @@ -216,7 +217,8 @@ opt_exit: #ifndef NDEBUG /* - * cli_telnet_DumpAttrs() Telnet debug attributes list, if NDEBUG defined not include + * cli_telnet_DumpAttrs() - Telnet debug attributes list, if NDEBUG defined not include + * * @attr = attributes list * @nAttr = attributes list size * return: none @@ -236,7 +238,8 @@ cli_telnet_DumpAttrs(struct telnetAttrs *attr, int nAt #endif /* - * cli_telnetSend() Telnet send commands, negotiate with telnet peer + * cli_telnetSend() - Telnet send commands, negotiate with telnet peer + * * @sock = socket for communication * @attr = send attributes list * @nAttr = send attributes list size @@ -266,7 +269,7 @@ cli_telnetSend(int sock, struct telnetAttrs *attr, int } } - buf = io_realloc(buf, pos + len); + buf = e_realloc(buf, pos + len); if (!buf) { LOGERR; return -1; @@ -290,7 +293,7 @@ cli_telnetSend(int sock, struct telnetAttrs *attr, int /* add data */ if (data && datLen) { - buf = io_realloc(buf, pos + datLen); + buf = e_realloc(buf, pos + datLen); if (!buf) { LOGERR; return -1; @@ -303,7 +306,7 @@ cli_telnetSend(int sock, struct telnetAttrs *attr, int /* add GA after end of all */ if (Term) { - buf = io_realloc(buf, pos + 2); + buf = e_realloc(buf, pos + 2); if (!buf) { LOGERR; return -1; @@ -318,20 +321,21 @@ cli_telnetSend(int sock, struct telnetAttrs *attr, int LOGERR; if (buf) - io_free(buf); + e_free(buf); return writeLen; } /* - * cli_telnet_Get_SubOpt() Telnet get sub option function + * cli_telnet_Get_SubOpt() - Telnet get sub option function + * * @attr = input attribute * @code = sub-option code for opt * @data = sub-option data * @datLen = data size set max size in input, output return copy size * return: -1 can`t get option; !=-1 option code */ -inline int +int cli_telnet_Get_SubOpt(struct telnetAttrs *attr, u_char *code, void *data, u_char *datLen) { u_char *pos, len; @@ -359,7 +363,8 @@ cli_telnet_Get_SubOpt(struct telnetAttrs *attr, u_char } /* - * cli_telnet_Set_SubOpt() Telnet set sub option function + * cli_telnet_Set_SubOpt() - Telnet set sub option function + * * @attr = output attribute * @opt = attribute option * @code = sub-option code for opt, if 0xff not specified @@ -367,7 +372,7 @@ cli_telnet_Get_SubOpt(struct telnetAttrs *attr, u_char * @datLen = data size, if 0 not specified * return: -1 can`t set sub-otion; 0 ok */ -inline int +int cli_telnet_Set_SubOpt(struct telnetAttrs *attr, u_char opt, u_char code, void *data, u_char datLen) { u_char len; @@ -398,11 +403,12 @@ cli_telnet_Set_SubOpt(struct telnetAttrs *attr, u_char } /* - * cli_telnet_GetCmd() Telnet get command + * cli_telnet_GetCmd() - Telnet get command + * * @attr = input attribute * return: -1 can`t get command; !=-1 command <<24 return sublen, <<8 return option, <<0 command */ -inline u_int +u_int cli_telnet_GetCmd(struct telnetAttrs *attr) { u_int ret = 0; @@ -426,7 +432,8 @@ cli_telnet_GetCmd(struct telnetAttrs *attr) } /* - * cli_telnet_SetCmd() Telnet set command + * cli_telnet_SetCmd() - Telnet set command + * * @attr = input attribute * @cmd = command * @opt = option, if 0xff not specified @@ -435,7 +442,7 @@ cli_telnet_GetCmd(struct telnetAttrs *attr) * @arg3 = sub-option data size, if 0 not specified data * return: -1 can`t set command; !=-1 ok */ -inline int +int cli_telnet_SetCmd(struct telnetAttrs *attr, u_char cmd, u_char opt, ...) { va_list lst; @@ -480,12 +487,13 @@ cli_telnet_SetCmd(struct telnetAttrs *attr, u_char cmd /* - * cli_telnet_Answer() Automatic generate commands answer to send from telnet + * cli_telnet_Answer() - Automatic generate commands answer to send from telnet + * * @caps = Array of capability options * @nCaps = number of capability options * @attr = input attribute * @nAttr = number of input attributes - * @ans = output answered attributes, must be io_free() after use + * @ans = output answered attributes, must be e_free() after use * @Ans = number of output answered attributes * return: -1 can`t answer; !=-1 ok */ @@ -521,7 +529,7 @@ cli_telnet_Answer(u_char *caps, int nCaps, struct teln // make attribute ... if (flg > -1) { (*Ans)++; - *ans = io_realloc(*ans, sizeof(struct telnetAttrs) * *Ans); + *ans = e_realloc(*ans, sizeof(struct telnetAttrs) * *Ans); if (!*ans) { LOGERR; return -1;