mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
Various application fixes by Jan Roeloffzen, bug #5182, part 3
arp: Remove unused variables ftp: tabs->spaces, remove unused variables nslookup: Remove unused variables svn path=/trunk/; revision=47460
This commit is contained in:
parent
81d25d5267
commit
ad964bddb1
4 changed files with 92 additions and 112 deletions
|
@ -170,9 +170,7 @@ INT DisplayArpEntries(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
|
||||||
|
|
||||||
ZeroMemory(pIpNetTable, sizeof(*pIpNetTable));
|
ZeroMemory(pIpNetTable, sizeof(*pIpNetTable));
|
||||||
|
|
||||||
iRet = GetIpNetTable(pIpNetTable, &Size, TRUE);
|
if (GetIpNetTable(pIpNetTable, &Size, TRUE) != NO_ERROR)
|
||||||
|
|
||||||
if (iRet != NO_ERROR)
|
|
||||||
{
|
{
|
||||||
_tprintf(_T("failed to allocate memory for GetIpNetTable\n"));
|
_tprintf(_T("failed to allocate memory for GetIpNetTable\n"));
|
||||||
DoFormatMessage();
|
DoFormatMessage();
|
||||||
|
@ -201,9 +199,7 @@ INT DisplayArpEntries(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
|
||||||
|
|
||||||
ZeroMemory(pIpAddrTable, sizeof(*pIpAddrTable));
|
ZeroMemory(pIpAddrTable, sizeof(*pIpAddrTable));
|
||||||
|
|
||||||
iRet = GetIpAddrTable(pIpAddrTable, &Size, TRUE);
|
if ((iRet = GetIpAddrTable(pIpAddrTable, &Size, TRUE)) != NO_ERROR)
|
||||||
|
|
||||||
if (iRet != NO_ERROR)
|
|
||||||
{
|
{
|
||||||
_tprintf(_T("GetIpAddrTable failed: %d\n"), iRet);
|
_tprintf(_T("GetIpAddrTable failed: %d\n"), iRet);
|
||||||
DoFormatMessage();
|
DoFormatMessage();
|
||||||
|
@ -272,7 +268,7 @@ INT Addhost(PTCHAR pszInetAddr, PTCHAR pszEthAddr, PTCHAR pszIfAddr)
|
||||||
PMIB_IPNETTABLE pIpNetTable = NULL;
|
PMIB_IPNETTABLE pIpNetTable = NULL;
|
||||||
DWORD dwIpAddr = 0;
|
DWORD dwIpAddr = 0;
|
||||||
ULONG Size = 0;
|
ULONG Size = 0;
|
||||||
INT iRet, i, val, c;
|
INT i, val, c;
|
||||||
|
|
||||||
/* error checking */
|
/* error checking */
|
||||||
|
|
||||||
|
@ -320,9 +316,7 @@ INT Addhost(PTCHAR pszInetAddr, PTCHAR pszEthAddr, PTCHAR pszIfAddr)
|
||||||
|
|
||||||
ZeroMemory(pIpNetTable, sizeof(*pIpNetTable));
|
ZeroMemory(pIpNetTable, sizeof(*pIpNetTable));
|
||||||
|
|
||||||
iRet = GetIpNetTable(pIpNetTable, &Size, TRUE);
|
if (GetIpNetTable(pIpNetTable, &Size, TRUE) != NO_ERROR)
|
||||||
|
|
||||||
if (iRet != NO_ERROR)
|
|
||||||
{
|
{
|
||||||
_tprintf(_T("failed to allocate memory for GetIpNetTable\n"));
|
_tprintf(_T("failed to allocate memory for GetIpNetTable\n"));
|
||||||
DoFormatMessage();
|
DoFormatMessage();
|
||||||
|
@ -382,7 +376,7 @@ INT Addhost(PTCHAR pszInetAddr, PTCHAR pszEthAddr, PTCHAR pszIfAddr)
|
||||||
|
|
||||||
|
|
||||||
/* Add the ARP entry */
|
/* Add the ARP entry */
|
||||||
if ((iRet = SetIpNetEntry(pAddHost)) != NO_ERROR)
|
if (SetIpNetEntry(pAddHost) != NO_ERROR)
|
||||||
{
|
{
|
||||||
DoFormatMessage();
|
DoFormatMessage();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -415,7 +409,6 @@ INT Deletehost(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
|
||||||
PMIB_IPNETTABLE pIpNetTable = NULL;
|
PMIB_IPNETTABLE pIpNetTable = NULL;
|
||||||
ULONG Size = 0;
|
ULONG Size = 0;
|
||||||
DWORD dwIpAddr = 0;
|
DWORD dwIpAddr = 0;
|
||||||
INT iRet;
|
|
||||||
BOOL bFlushTable = FALSE;
|
BOOL bFlushTable = FALSE;
|
||||||
|
|
||||||
/* error checking */
|
/* error checking */
|
||||||
|
@ -449,9 +442,7 @@ INT Deletehost(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
|
||||||
|
|
||||||
ZeroMemory(pIpNetTable, sizeof(*pIpNetTable));
|
ZeroMemory(pIpNetTable, sizeof(*pIpNetTable));
|
||||||
|
|
||||||
iRet = GetIpNetTable(pIpNetTable, &Size, TRUE);
|
if (GetIpNetTable(pIpNetTable, &Size, TRUE) != NO_ERROR)
|
||||||
|
|
||||||
if (iRet != NO_ERROR)
|
|
||||||
{
|
{
|
||||||
_tprintf(_T("failed to allocate memory for GetIpNetTable\n"));
|
_tprintf(_T("failed to allocate memory for GetIpNetTable\n"));
|
||||||
DoFormatMessage();
|
DoFormatMessage();
|
||||||
|
@ -485,7 +476,7 @@ INT Deletehost(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
|
||||||
if (bFlushTable == TRUE)
|
if (bFlushTable == TRUE)
|
||||||
{
|
{
|
||||||
/* delete arp cache */
|
/* delete arp cache */
|
||||||
if ((iRet = FlushIpNetTable(pDelHost->dwIndex)) != NO_ERROR)
|
if (FlushIpNetTable(pDelHost->dwIndex) != NO_ERROR)
|
||||||
{
|
{
|
||||||
DoFormatMessage();
|
DoFormatMessage();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -501,7 +492,7 @@ INT Deletehost(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
|
||||||
pDelHost->dwAddr = dwIpAddr;
|
pDelHost->dwAddr = dwIpAddr;
|
||||||
|
|
||||||
/* Add the ARP entry */
|
/* Add the ARP entry */
|
||||||
if ((iRet = DeleteIpNetEntry(pDelHost)) != NO_ERROR)
|
if (DeleteIpNetEntry(pDelHost) != NO_ERROR)
|
||||||
{
|
{
|
||||||
DoFormatMessage();
|
DoFormatMessage();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
|
@ -29,10 +29,10 @@ int checkRecv(SOCKET s)
|
||||||
|
|
||||||
void blkfree(char **av0)
|
void blkfree(char **av0)
|
||||||
{
|
{
|
||||||
register char **av = av0;
|
register char **av = av0;
|
||||||
|
|
||||||
while (*av)
|
while (*av)
|
||||||
free(*av++);
|
free(*av++);
|
||||||
}
|
}
|
||||||
|
|
||||||
char **glob(register char *v)
|
char **glob(register char *v)
|
||||||
|
@ -52,16 +52,16 @@ int herror(char *string)
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
int gettimeofday(struct timeval *timenow,
|
int gettimeofday(struct timeval *timenow,
|
||||||
struct timezone *zone)
|
struct timezone *zone)
|
||||||
{
|
{
|
||||||
time_t t;
|
time_t t;
|
||||||
|
|
||||||
t = clock();
|
t = clock();
|
||||||
|
|
||||||
timenow->tv_usec = t;
|
timenow->tv_usec = t;
|
||||||
timenow->tv_sec = t / CLK_TCK;
|
timenow->tv_sec = t / CLK_TCK;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fgetcSocket(int s)
|
int fgetcSocket(int s)
|
||||||
|
@ -100,13 +100,13 @@ int fgetcSocket(int s)
|
||||||
total = recv(s, buffer, sizeof(buffer), 0);
|
total = recv(s, buffer, sizeof(buffer), 0);
|
||||||
|
|
||||||
if (total == SOCKET_ERROR)
|
if (total == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
total = 0;
|
total = 0;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (total == 0)
|
if (total == 0)
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
return buffer[index++];
|
return buffer[index++];
|
||||||
}
|
}
|
||||||
|
@ -142,29 +142,29 @@ int fputcSocket(int s, char putChar)
|
||||||
buffer[1] = '\0';
|
buffer[1] = '\0';
|
||||||
|
|
||||||
if(SOCKET_ERROR==send(s, buffer, 1, 0)) {
|
if(SOCKET_ERROR==send(s, buffer, 1, 0)) {
|
||||||
int iret=WSAGetLastError ();
|
int iret=WSAGetLastError ();
|
||||||
fprintf(stdout,"fputcSocket: %d\n",iret);
|
fprintf(stdout,"fputcSocket: %d\n",iret);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return putChar;
|
return putChar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int fputSocket(int s, char *buffer, int len)
|
int fputSocket(int s, char *buffer, int len)
|
||||||
{
|
{
|
||||||
int iret;
|
int iret;
|
||||||
while(len) {
|
while(len) {
|
||||||
if(SOCKET_ERROR==(iret=send(s, buffer, len, 0)))
|
if(SOCKET_ERROR==(iret=send(s, buffer, len, 0)))
|
||||||
{
|
{
|
||||||
iret=WSAGetLastError ();
|
iret=WSAGetLastError ();
|
||||||
fprintf(stdout,"fputcSocket: %d\n",iret);
|
fprintf(stdout,"fputcSocket: %d\n",iret);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return len-=iret;
|
return len-=iret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *fgetsSocket(int s, char *string)
|
char *fgetsSocket(int s, char *string)
|
||||||
|
@ -180,31 +180,31 @@ char *fgetsSocket(int s, char *string)
|
||||||
|
|
||||||
if (count == SOCKET_ERROR)
|
if (count == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
printf("Error in fgetssocket");
|
printf("Error in fgetssocket");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
{
|
{
|
||||||
string[i] = buffer[0];
|
string[i] = buffer[0];
|
||||||
|
|
||||||
if (i == MAX_ASCII - 3)
|
if (i == MAX_ASCII - 3)
|
||||||
{
|
{
|
||||||
count = 0;
|
count = 0;
|
||||||
string[++i] = '\n';
|
string[++i] = '\n';
|
||||||
string[++i] = '\0';
|
string[++i] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string[i] = '\n';
|
string[i] = '\n';
|
||||||
string[i + 1] = '\0'; // This is risky
|
string[i + 1] = '\0'; // This is risky
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,44 +250,44 @@ char *getpass (const char * prompt)
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (istty)
|
if (istty)
|
||||||
{
|
{
|
||||||
if (GetConsoleMode (in, &old_flags))
|
if (GetConsoleMode (in, &old_flags))
|
||||||
SetConsoleMode (in, ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT);
|
SetConsoleMode (in, ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT);
|
||||||
else
|
else
|
||||||
istty = 0;
|
istty = 0;
|
||||||
}
|
}
|
||||||
/* Need to read line one byte at time to avoid blocking, if not a
|
/* Need to read line one byte at time to avoid blocking, if not a
|
||||||
tty, so always do it this way. */
|
tty, so always do it this way. */
|
||||||
count = 0;
|
count = 0;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
DWORD dummy;
|
DWORD dummy;
|
||||||
char one_char;
|
char one_char;
|
||||||
|
|
||||||
rc = ReadFile (in, &one_char, 1, &dummy, NULL);
|
rc = ReadFile (in, &one_char, 1, &dummy, NULL);
|
||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
break;
|
break;
|
||||||
if (one_char == '\r')
|
if (one_char == '\r')
|
||||||
{
|
{
|
||||||
/* CR is always followed by LF if reading from tty. */
|
/* CR is always followed by LF if reading from tty. */
|
||||||
if (istty)
|
if (istty)
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (one_char == '\n')
|
if (one_char == '\n')
|
||||||
break;
|
break;
|
||||||
/* Silently truncate password string if overly long. */
|
/* Silently truncate password string if overly long. */
|
||||||
if (count < sizeof (input) - 1)
|
if (count < sizeof (input) - 1)
|
||||||
input[count++] = one_char;
|
input[count++] = one_char;
|
||||||
}
|
}
|
||||||
input[count] = '\0';
|
input[count] = '\0';
|
||||||
|
|
||||||
WriteFile (err, "\r\n", 2, &count, NULL);
|
WriteFile (err, "\r\n", 2, &count, NULL);
|
||||||
if (istty)
|
if (istty)
|
||||||
SetConsoleMode (in, old_flags);
|
SetConsoleMode (in, old_flags);
|
||||||
if (rc)
|
if (rc)
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -345,7 +345,7 @@ getreply(expecteof)
|
||||||
cp = reply_string;
|
cp = reply_string;
|
||||||
while ((c = fgetcSocket(cin)) != '\n') {
|
while ((c = fgetcSocket(cin)) != '\n') {
|
||||||
if (c == IAC) { /* handle telnet commands */
|
if (c == IAC) { /* handle telnet commands */
|
||||||
switch (c = fgetcSocket(cin)) {
|
switch (fgetcSocket(cin)) {
|
||||||
case WILL:
|
case WILL:
|
||||||
case WONT:
|
case WONT:
|
||||||
c = fgetcSocket(cin);
|
c = fgetcSocket(cin);
|
||||||
|
@ -745,7 +745,7 @@ void recvrequest(const char *cmd, const char *local, const char *remote, const c
|
||||||
long bytes = 0, hashbytes = HASHBYTES;
|
long bytes = 0, hashbytes = HASHBYTES;
|
||||||
// struct
|
// struct
|
||||||
fd_set mask;
|
fd_set mask;
|
||||||
register int c, d;
|
register int c;
|
||||||
struct timeval start, stop;
|
struct timeval start, stop;
|
||||||
// struct stat st;
|
// struct stat st;
|
||||||
|
|
||||||
|
@ -781,6 +781,7 @@ null();// (void) signal(SIGINT, oldintr);
|
||||||
null();// oldintr = signal(SIGINT, abortrecv);
|
null();// oldintr = signal(SIGINT, abortrecv);
|
||||||
if (strcmp(local, "-") && *local != '|') {
|
if (strcmp(local, "-") && *local != '|') {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
register int d;
|
||||||
// This whole thing is a problem... access Won't work on non-existent files
|
// This whole thing is a problem... access Won't work on non-existent files
|
||||||
if (access(local, 2) < 0) {
|
if (access(local, 2) < 0) {
|
||||||
char *dir = rindex(local, '/');
|
char *dir = rindex(local, '/');
|
||||||
|
@ -919,7 +920,7 @@ null();// oldintp = signal(SIGPIPE, SIG_IGN);
|
||||||
(*closefunc)(fout);
|
(*closefunc)(fout);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
errno = d = 0;
|
errno = 0;
|
||||||
// while ((c = recv(din, buf, bufsize, 1)) > 0) {
|
// while ((c = recv(din, buf, bufsize, 1)) > 0) {
|
||||||
// if ((d = write(fileno(fout), buf, c)) != c)
|
// if ((d = write(fileno(fout), buf, c)) != c)
|
||||||
// if ((d = write(fileno(fout), buf, c)) != c)
|
// if ((d = write(fileno(fout), buf, c)) != c)
|
||||||
|
@ -1106,10 +1107,10 @@ null();// (void) signal(SIGINT,oldintr);
|
||||||
lostpeer();
|
lostpeer();
|
||||||
}
|
}
|
||||||
if (din && FD_ISSET(din, &mask)) {
|
if (din && FD_ISSET(din, &mask)) {
|
||||||
while ((c = recv(din, buf, bufsize, 0)) > 0)
|
while (recv(din, buf, bufsize, 0) > 0)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
if ((c = getreply(0)) == ERROR && code == 552) { /* needed for nic style abort */
|
if (getreply(0) == ERROR && code == 552) { /* needed for nic style abort */
|
||||||
if (data >= 0) {
|
if (data >= 0) {
|
||||||
(void) close(data);
|
(void) close(data);
|
||||||
data = -1;
|
data = -1;
|
||||||
|
|
|
@ -90,11 +90,7 @@ BOOL PerformInternalLookup( PCHAR pAddr, PCHAR pResult )
|
||||||
BOOL bOk = FALSE;
|
BOOL bOk = FALSE;
|
||||||
|
|
||||||
/* Makes things easier when parsing the response packet. */
|
/* Makes things easier when parsing the response packet. */
|
||||||
UCHAR Header1, Header2;
|
|
||||||
USHORT NumQuestions;
|
USHORT NumQuestions;
|
||||||
USHORT NumAnswers;
|
|
||||||
USHORT NumAuthority;
|
|
||||||
USHORT NumAdditional;
|
|
||||||
USHORT Type;
|
USHORT Type;
|
||||||
|
|
||||||
if( (strlen( pAddr ) + 1) > 255 ) return FALSE;
|
if( (strlen( pAddr ) + 1) > 255 ) return FALSE;
|
||||||
|
@ -198,12 +194,7 @@ BOOL PerformInternalLookup( PCHAR pAddr, PCHAR pResult )
|
||||||
if( !bOk ) goto cleanup;
|
if( !bOk ) goto cleanup;
|
||||||
|
|
||||||
/* Start parsing the received packet. */
|
/* Start parsing the received packet. */
|
||||||
Header1 = RecBuffer[2];
|
|
||||||
Header2 = RecBuffer[3];
|
|
||||||
NumQuestions = ntohs( ((PSHORT)&RecBuffer[4])[0] );
|
NumQuestions = ntohs( ((PSHORT)&RecBuffer[4])[0] );
|
||||||
NumAnswers = ntohs( ((PSHORT)&RecBuffer[6])[0] );
|
|
||||||
NumAuthority = ntohs( ((PUSHORT)&RecBuffer[8])[0] );
|
|
||||||
NumAdditional = ntohs( ((PUSHORT)&RecBuffer[10])[0] );
|
|
||||||
|
|
||||||
k = 12;
|
k = 12;
|
||||||
|
|
||||||
|
@ -257,11 +248,10 @@ void PerformLookup( PCHAR pAddr )
|
||||||
BOOL bOk = FALSE;
|
BOOL bOk = FALSE;
|
||||||
|
|
||||||
/* Makes things easier when parsing the response packet. */
|
/* Makes things easier when parsing the response packet. */
|
||||||
UCHAR Header1, Header2;
|
UCHAR Header2;
|
||||||
USHORT NumQuestions;
|
USHORT NumQuestions;
|
||||||
USHORT NumAnswers;
|
USHORT NumAnswers;
|
||||||
USHORT NumAuthority;
|
USHORT NumAuthority;
|
||||||
USHORT NumAdditional;
|
|
||||||
USHORT Type;
|
USHORT Type;
|
||||||
|
|
||||||
if( (strlen( pAddr ) + 1) > 255 ) return;
|
if( (strlen( pAddr ) + 1) > 255 ) return;
|
||||||
|
@ -368,19 +358,17 @@ void PerformLookup( PCHAR pAddr )
|
||||||
((PSHORT)&Buffer[i])[0] = htons( ClassNametoClassID( State.Class ) );
|
((PSHORT)&Buffer[i])[0] = htons( ClassNametoClassID( State.Class ) );
|
||||||
|
|
||||||
/* Ship off the request to the DNS server. */
|
/* Ship off the request to the DNS server. */
|
||||||
bOk = SendRequest( Buffer,
|
bOk = SendRequest( Buffer,
|
||||||
BufferLength,
|
BufferLength,
|
||||||
RecBuffer,
|
RecBuffer,
|
||||||
&RecBufferLength );
|
&RecBufferLength );
|
||||||
if( !bOk ) goto cleanup;
|
if( !bOk ) goto cleanup;
|
||||||
|
|
||||||
/* Start parsing the received packet. */
|
/* Start parsing the received packet. */
|
||||||
Header1 = RecBuffer[2];
|
|
||||||
Header2 = RecBuffer[3];
|
Header2 = RecBuffer[3];
|
||||||
NumQuestions = ntohs( ((PSHORT)&RecBuffer[4])[0] );
|
NumQuestions = ntohs( ((PSHORT)&RecBuffer[4])[0] );
|
||||||
NumAnswers = ntohs( ((PSHORT)&RecBuffer[6])[0] );
|
NumAnswers = ntohs( ((PSHORT)&RecBuffer[6])[0] );
|
||||||
NumAuthority = ntohs( ((PUSHORT)&RecBuffer[8])[0] );
|
NumAuthority = ntohs( ((PUSHORT)&RecBuffer[8])[0] );
|
||||||
NumAdditional = ntohs( ((PUSHORT)&RecBuffer[10])[0] );
|
|
||||||
Type = 0;
|
Type = 0;
|
||||||
|
|
||||||
/* Check the RCODE for failure. */
|
/* Check the RCODE for failure. */
|
||||||
|
|
Loading…
Reference in a new issue