fixed picky compiler warnings, unused arguments, const at proper places and

I also indented the source code to fit curl "standard"
This commit is contained in:
Daniel Stenberg 2001-08-14 08:30:08 +00:00
parent 0c063f85fc
commit 3d4bb3be22
1 changed files with 185 additions and 188 deletions

View File

@ -47,6 +47,10 @@
#include <string.h>
#include <krb.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> /* for getpid() */
#endif
#include "ftp.h"
#include "sendf.h"
@ -105,6 +109,7 @@ size_t strlcpy (char *dst, const char *src, size_t dst_sz);
static int
krb4_check_prot(void *app_data, int level)
{
app_data = NULL; /* prevent compiler warning */
if(level == prot_confidential)
return -1;
return 0;
@ -137,6 +142,10 @@ krb4_decode(void *app_data, void *buf, int len, int level,
static int
krb4_overhead(void *app_data, int level, int len)
{
/* no arguments are used, just init them to prevent compiler warnings */
app_data = NULL;
level = 0;
len = 0;
return 31;
}
@ -249,7 +258,7 @@ struct sec_server_mech krb4_server_mech = {
static int
mk_auth(struct krb4_data *d, KTEXT adat,
char *service, char *host, int checksum)
const char *service, char *host, int checksum)
{
int ret;
CREDENTIALS cred;
@ -287,7 +296,7 @@ krb4_auth(void *app_data, struct connectdata *conn)
struct sockaddr_in *remoteaddr = (struct sockaddr_in *)REMOTE_ADDR;
#endif
char *host = conn->hp->h_name;
size_t nread;
ssize_t nread;
int l = sizeof(local_addr);
if(getsockname(conn->firstsocket,
@ -319,10 +328,8 @@ krb4_auth(void *app_data, struct connectdata *conn)
localaddr->sin_addr = natAddr;
/*
* This not the best place to do this, but it
* is here we know that (probably) NAT is in
* use!
*/
* This not the best place to do this, but it is here we know that
* (probably) NAT is in use! */
/*passivemode = 1;***/
/*printf("Setting: Passive mode on.\n");***/
@ -338,9 +345,9 @@ krb4_auth(void *app_data, struct connectdata *conn)
printf("Out of memory base64-encoding.\n");
return AUTH_CONTINUE;
}
/*ret = command("ADAT %s", p)*/
Curl_ftpsendf(conn->firstsocket, conn, "ADAT %s", p);
/* wait for feedback */
nread = Curl_GetFTPResponse(conn->firstsocket,
conn->data->buffer, conn, NULL);
if(nread < 0)
@ -352,7 +359,7 @@ krb4_auth(void *app_data, struct connectdata *conn)
return AUTH_ERROR;
}
p = strstr(/*reply_string*/conn->data->buffer, "ADAT=");
p = strstr(conn->data->buffer, "ADAT=");
if(!p){
printf("Remote host didn't send adat reply.\n");
return AUTH_ERROR;
@ -403,15 +410,15 @@ void krb_kauth(struct connectdata *conn)
char *p;
char passwd[100];
int tmp;
size_t nread;
ssize_t nread;
int save;
save = set_command_prot(conn, prot_private);
/*ret = command("SITE KAUTH %s", name);***/
Curl_ftpsendf(conn->firstsocket, conn,
"SITE KAUTH %s", conn->data->user);
/* wait for feedback */
nread = Curl_GetFTPResponse(conn->firstsocket, conn->data->buffer,
conn, NULL);
if(nread < 0)
@ -422,44 +429,35 @@ void krb_kauth(struct connectdata *conn)
/*code = -1;***/
return;
}
p = strstr(/*reply_string***/conn->data->buffer, "T=");
p = strstr(conn->data->buffer, "T=");
if(!p) {
printf("Bad reply from server.\n");
set_command_prot(conn, save);
/*code = -1;***/
return;
}
p += 2;
tmp = Curl_base64_decode(p, &tkt.dat);
if(tmp < 0) {
printf("Failed to decode base64 in reply.\n");
set_command_prot(conn, save);
/*code = -1;***/
return;
}
tkt.length = tmp;
tktcopy.length = tkt.length;
p = strstr(/*reply_string***/conn->data->buffer, "P=");
p = strstr(conn->data->buffer, "P=");
if(!p) {
printf("Bad reply from server.\n");
set_command_prot(conn, save);
/*code = -1;***/
return;
}
name = p + 2;
for(; *p && *p != ' ' && *p != '\r' && *p != '\n'; p++);
*p = 0;
#if 0
snprintf(buf, sizeof(buf), "Password for %s:", name);
if (des_read_pw_string (passwd, sizeof(passwd)-1, buf, 0))
*passwd = '\0';
des_string_to_key (passwd, &key);
#else
des_string_to_key (conn->data->passwd, &key);
#endif
des_key_sched(&key, schedule);
des_pcbc_encrypt((des_cblock*)tkt.dat, (des_cblock*)tktcopy.dat,
@ -468,7 +466,7 @@ void krb_kauth(struct connectdata *conn)
if (strcmp ((char*)tktcopy.dat + 8,
KRB_TICKET_GRANTING_TICKET) != 0) {
afs_string_to_key (passwd,
krb_realmofhost(/*hostname***/conn->hp->h_name),
krb_realmofhost(/*hostname*/conn->hp->h_name),
&key);
des_key_sched (&key, schedule);
des_pcbc_encrypt((des_cblock*)tkt.dat, (des_cblock*)tktcopy.dat,
@ -481,14 +479,13 @@ void krb_kauth(struct connectdata *conn)
if(Curl_base64_encode(tktcopy.dat, tktcopy.length, &p) < 0) {
failf(conn->data, "Out of memory base64-encoding.\n");
set_command_prot(conn, save);
/*code = -1;***/
return;
}
memset (tktcopy.dat, 0, tktcopy.length);
/*ret = command("SITE KAUTH %s %s", name, p);***/
Curl_ftpsendf(conn->firstsocket, conn,
"SITE KAUTH %s %s", name, p);
/* wait for feedback */
nread = Curl_GetFTPResponse(conn->firstsocket, conn->data->buffer,
conn, NULL);
if(nread < 0)