1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 08:08:50 -05:00

Added lots of consts

This commit is contained in:
Dan Fandrich 2007-08-29 05:36:53 +00:00
parent 5cb2ee878c
commit 1b66c1da6c
6 changed files with 29 additions and 28 deletions

View File

@ -172,16 +172,13 @@ Curl_cookie_add(struct SessionHandle *data,
struct CookieInfo *c, struct CookieInfo *c,
bool httpheader, /* TRUE if HTTP header-style line */ bool httpheader, /* TRUE if HTTP header-style line */
char *lineptr, /* first character of the line */ char *lineptr, /* first character of the line */
char *domain, /* default domain */ const char *domain, /* default domain */
char *path) /* full path used when this cookie is set, const char *path) /* full path used when this cookie is set,
used to get default path for the cookie used to get default path for the cookie
unless set */ unless set */
{ {
struct Cookie *clist; struct Cookie *clist;
char *what;
char name[MAX_NAME]; char name[MAX_NAME];
char *ptr;
char *semiptr;
struct Cookie *co; struct Cookie *co;
struct Cookie *lastc=NULL; struct Cookie *lastc=NULL;
time_t now = time(NULL); time_t now = time(NULL);
@ -199,7 +196,10 @@ Curl_cookie_add(struct SessionHandle *data,
if(httpheader) { if(httpheader) {
/* This line was read off a HTTP-header */ /* This line was read off a HTTP-header */
char *sep; const char *ptr;
const char *sep;
const char *semiptr;
char *what;
what = malloc(MAX_COOKIE_LINE); what = malloc(MAX_COOKIE_LINE);
if(!what) { if(!what) {
@ -228,7 +228,7 @@ Curl_cookie_add(struct SessionHandle *data,
name, what)) { name, what)) {
/* this is a <name>=<what> pair */ /* this is a <name>=<what> pair */
char *whatptr; const char *whatptr;
/* Strip off trailing whitespace from the 'what' */ /* Strip off trailing whitespace from the 'what' */
size_t len=strlen(what); size_t len=strlen(what);
@ -428,6 +428,7 @@ Curl_cookie_add(struct SessionHandle *data,
else { else {
/* This line is NOT a HTTP header style line, we do offer support for /* This line is NOT a HTTP header style line, we do offer support for
reading the odd netscape cookies-file format here */ reading the odd netscape cookies-file format here */
char *ptr;
char *firstptr; char *firstptr;
char *tok_buf; char *tok_buf;
int fields; int fields;
@ -655,7 +656,7 @@ Curl_cookie_add(struct SessionHandle *data,
* *
****************************************************************************/ ****************************************************************************/
struct CookieInfo *Curl_cookie_init(struct SessionHandle *data, struct CookieInfo *Curl_cookie_init(struct SessionHandle *data,
char *file, const char *file,
struct CookieInfo *inc, struct CookieInfo *inc,
bool newsession) bool newsession)
{ {
@ -734,7 +735,8 @@ struct CookieInfo *Curl_cookie_init(struct SessionHandle *data,
****************************************************************************/ ****************************************************************************/
struct Cookie *Curl_cookie_getlist(struct CookieInfo *c, struct Cookie *Curl_cookie_getlist(struct CookieInfo *c,
char *host, char *path, bool secure) const char *host, const char *path,
bool secure)
{ {
struct Cookie *newco; struct Cookie *newco;
struct Cookie *co; struct Cookie *co;
@ -937,7 +939,7 @@ static char *get_netscape_format(const struct Cookie *co)
* *
* The function returns non-zero on write failure. * The function returns non-zero on write failure.
*/ */
int Curl_cookie_output(struct CookieInfo *c, char *dumphere) int Curl_cookie_output(struct CookieInfo *c, const char *dumphere)
{ {
struct Cookie *co; struct Cookie *co;
FILE *out; FILE *out;

View File

@ -84,17 +84,18 @@ struct SessionHandle;
*/ */
struct Cookie *Curl_cookie_add(struct SessionHandle *data, struct Cookie *Curl_cookie_add(struct SessionHandle *data,
struct CookieInfo *, bool header, char *line, struct CookieInfo *, bool header, char *lineptr,
char *domain, char *path); const char *domain, const char *path);
struct CookieInfo *Curl_cookie_init(struct SessionHandle *data, struct CookieInfo *Curl_cookie_init(struct SessionHandle *data,
char *, struct CookieInfo *, bool); const char *, struct CookieInfo *, bool);
struct Cookie *Curl_cookie_getlist(struct CookieInfo *, char *, char *, bool); struct Cookie *Curl_cookie_getlist(struct CookieInfo *, const char *,
const char *, bool);
void Curl_cookie_freelist(struct Cookie *); void Curl_cookie_freelist(struct Cookie *);
void Curl_cookie_clearall(struct CookieInfo *cookies); void Curl_cookie_clearall(struct CookieInfo *cookies);
void Curl_cookie_clearsess(struct CookieInfo *cookies); void Curl_cookie_clearsess(struct CookieInfo *cookies);
void Curl_cookie_cleanup(struct CookieInfo *); void Curl_cookie_cleanup(struct CookieInfo *);
int Curl_cookie_output(struct CookieInfo *, char *); int Curl_cookie_output(struct CookieInfo *, const char *);
#if defined(CURL_DISABLE_HTTP) || defined(CURL_DISABLE_COOKIES) #if defined(CURL_DISABLE_HTTP) || defined(CURL_DISABLE_COOKIES)
#define Curl_cookie_list(x) NULL #define Curl_cookie_list(x) NULL

View File

@ -192,7 +192,7 @@ CURLcode Curl_file_done(struct connectdata *conn,
static CURLcode file_upload(struct connectdata *conn) static CURLcode file_upload(struct connectdata *conn)
{ {
struct FILEPROTO *file = conn->data->reqdata.proto.file; struct FILEPROTO *file = conn->data->reqdata.proto.file;
char *dir = strchr(file->path, DIRSEP); const char *dir = strchr(file->path, DIRSEP);
FILE *fp; FILE *fp;
CURLcode res=CURLE_OK; CURLcode res=CURLE_OK;
struct SessionHandle *data = conn->data; struct SessionHandle *data = conn->data;
@ -202,7 +202,7 @@ static CURLcode file_upload(struct connectdata *conn)
curl_off_t bytecount = 0; curl_off_t bytecount = 0;
struct timeval now = Curl_tvnow(); struct timeval now = Curl_tvnow();
struct_stat file_stat; struct_stat file_stat;
char* buf2; const char* buf2;
/* /*
* Since FILE: doesn't do the full init, we need to provide some extra * Since FILE: doesn't do the full init, we need to provide some extra
@ -372,11 +372,11 @@ CURLcode Curl_file(struct connectdata *conn, bool *done)
return result; return result;
if(fstated) { if(fstated) {
struct tm *tm; const struct tm *tm;
time_t clock = (time_t)statbuf.st_mtime; time_t clock = (time_t)statbuf.st_mtime;
#ifdef HAVE_GMTIME_R #ifdef HAVE_GMTIME_R
struct tm buffer; struct tm buffer;
tm = (struct tm *)gmtime_r(&clock, &buffer); tm = (const struct tm *)gmtime_r(&clock, &buffer);
#else #else
tm = gmtime(&clock); tm = gmtime(&clock);
#endif #endif

View File

@ -111,7 +111,7 @@ Curl_hash_alloc(int slots,
static struct curl_hash_element * static struct curl_hash_element *
mk_hash_element(void *key, size_t key_len, const void *p) mk_hash_element(const void *key, size_t key_len, const void *p)
{ {
struct curl_hash_element *he = struct curl_hash_element *he =
(struct curl_hash_element *) malloc(sizeof(struct curl_hash_element)); (struct curl_hash_element *) malloc(sizeof(struct curl_hash_element));
@ -275,8 +275,8 @@ Curl_hash_destroy(struct curl_hash *h)
size_t Curl_hash_str(void* key, size_t key_length, size_t slots_num) size_t Curl_hash_str(void* key, size_t key_length, size_t slots_num)
{ {
char* key_str = (char *) key; const char* key_str = (const char *) key;
char *end = (char *) key_str + key_length; const char *end = key_str + key_length;
unsigned long h = 5381; unsigned long h = 5381;
while (key_str < end) { while (key_str < end) {

View File

@ -114,7 +114,7 @@ typedef enum {
TFTP_ERR_ILLEGAL, TFTP_ERR_ILLEGAL,
TFTP_ERR_UNKNOWNID, TFTP_ERR_UNKNOWNID,
TFTP_ERR_EXISTS, TFTP_ERR_EXISTS,
TFTP_ERR_NOSUCHUSER, TFTP_ERR_NOSUCHUSER, /* This will never be triggered by this code */
TFTP_ERR_TIMEOUT, TFTP_ERR_TIMEOUT,
TFTP_ERR_NORESPONSE TFTP_ERR_NORESPONSE
} tftp_error_t; } tftp_error_t;
@ -148,7 +148,6 @@ typedef struct tftp_state_data {
/* Forward declarations */ /* Forward declarations */
static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event) ; static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event) ;
static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event) ; static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event) ;
void tftp_set_timeouts(tftp_state_data_t *state) ;
/********************************************************** /**********************************************************
* *
@ -160,7 +159,7 @@ void tftp_set_timeouts(tftp_state_data_t *state) ;
* *
* *
**********************************************************/ **********************************************************/
void tftp_set_timeouts(tftp_state_data_t *state) static void tftp_set_timeouts(tftp_state_data_t *state)
{ {
struct SessionHandle *data = state->conn->data; struct SessionHandle *data = state->conn->data;
@ -240,12 +239,12 @@ static void setpacketblock(tftp_packet_t *packet, unsigned short num)
packet->data[3] = (unsigned char)(num & 0xff); packet->data[3] = (unsigned char)(num & 0xff);
} }
static unsigned short getrpacketevent(tftp_packet_t *packet) static unsigned short getrpacketevent(const tftp_packet_t *packet)
{ {
return (unsigned short)((packet->data[0] << 8) | packet->data[1]); return (unsigned short)((packet->data[0] << 8) | packet->data[1]);
} }
static unsigned short getrpacketblock(tftp_packet_t *packet) static unsigned short getrpacketblock(const tftp_packet_t *packet)
{ {
return (unsigned short)((packet->data[2] << 8) | packet->data[3]); return (unsigned short)((packet->data[2] << 8) | packet->data[3]);
} }

View File

@ -104,7 +104,6 @@ void idn_free (void *ptr); /* prototype from idn-free.h, not provided by
#include "netrc.h" #include "netrc.h"
#include "formdata.h" #include "formdata.h"
#include "base64.h"
#include "sslgen.h" #include "sslgen.h"
#include "hostip.h" #include "hostip.h"
#include "transfer.h" #include "transfer.h"