Merge pull request #287 from Cruel/const-lyfe

Some const correctness in sslc/httpc inputs
This commit is contained in:
fincs 2016-05-20 01:46:53 +02:00
commit 9489aadb5a
4 changed files with 35 additions and 35 deletions

View File

@ -43,7 +43,7 @@ void httpcExit(void);
* @param url URL to connect to. * @param url URL to connect to.
* @param use_defaultproxy Whether the default proxy should be used (0 for default) * @param use_defaultproxy Whether the default proxy should be used (0 for default)
*/ */
Result httpcOpenContext(httpcContext *context, HTTPC_RequestMethod method, char* url, u32 use_defaultproxy); Result httpcOpenContext(httpcContext *context, HTTPC_RequestMethod method, const char* url, u32 use_defaultproxy);
/** /**
* @brief Closes a HTTP context. * @brief Closes a HTTP context.
@ -57,7 +57,7 @@ Result httpcCloseContext(httpcContext *context);
* @param name Name of the field. * @param name Name of the field.
* @param value Value of the field. * @param value Value of the field.
*/ */
Result httpcAddRequestHeaderField(httpcContext *context, char* name, char* value); Result httpcAddRequestHeaderField(httpcContext *context, const char* name, const char* value);
/** /**
* @brief Adds a POST form field to a HTTP context. * @brief Adds a POST form field to a HTTP context.
@ -65,7 +65,7 @@ Result httpcAddRequestHeaderField(httpcContext *context, char* name, char* value
* @param name Name of the field. * @param name Name of the field.
* @param value Value of the field. * @param value Value of the field.
*/ */
Result httpcAddPostDataAscii(httpcContext *context, char* name, char* value); Result httpcAddPostDataAscii(httpcContext *context, const char* name, const char* value);
/** /**
* @brief Adds a POST body to a HTTP context. * @brief Adds a POST body to a HTTP context.
@ -73,7 +73,7 @@ Result httpcAddPostDataAscii(httpcContext *context, char* name, char* value);
* @param data The data to be passed as raw into the body of the post request. * @param data The data to be passed as raw into the body of the post request.
* @param len Length of data passed by data param. * @param len Length of data passed by data param.
*/ */
Result httpcAddPostDataRaw(httpcContext *context, u32* data, u32 len); Result httpcAddPostDataRaw(httpcContext *context, const u32* data, u32 len);
/** /**
* @brief Begins a HTTP request. * @brief Begins a HTTP request.
@ -119,7 +119,7 @@ Result httpcGetResponseStatusCode(httpcContext *context, u32* out, u64 delay);
* @param value Pointer to output the value of the field to. * @param value Pointer to output the value of the field to.
* @param valuebuf_maxsize Maximum size of the value buffer. * @param valuebuf_maxsize Maximum size of the value buffer.
*/ */
Result httpcGetResponseHeader(httpcContext *context, char* name, char* value, u32 valuebuf_maxsize); Result httpcGetResponseHeader(httpcContext *context, const char* name, char* value, u32 valuebuf_maxsize);
/** /**
* @brief Adds a trusted RootCA cert to a HTTP context. * @brief Adds a trusted RootCA cert to a HTTP context.
@ -127,7 +127,7 @@ Result httpcGetResponseHeader(httpcContext *context, char* name, char* value, u3
* @param cert Pointer to DER cert. * @param cert Pointer to DER cert.
* @param certsize Size of the DER cert. * @param certsize Size of the DER cert.
*/ */
Result httpcAddTrustedRootCA(httpcContext *context, u8 *cert, u32 certsize); Result httpcAddTrustedRootCA(httpcContext *context, const u8 *cert, u32 certsize);
/** /**
* @brief Adds a default RootCA cert to a HTTP context. * @brief Adds a default RootCA cert to a HTTP context.
@ -151,7 +151,7 @@ Result httpcSelectRootCertChain(httpcContext *context, u32 RootCertChain_context
* @param privk Pointer to the DER private key. * @param privk Pointer to the DER private key.
* @param privk_size Size of the privk. * @param privk_size Size of the privk.
*/ */
Result httpcSetClientCert(httpcContext *context, u8 *cert, u32 certsize, u8 *privk, u32 privk_size); Result httpcSetClientCert(httpcContext *context, const u8 *cert, u32 certsize, const u8 *privk, u32 privk_size);
/** /**
* @brief Sets the default clientcert for a HTTP context. * @brief Sets the default clientcert for a HTTP context.
@ -202,7 +202,7 @@ Result httpcDestroyRootCertChain(u32 RootCertChain_contexthandle);
* @param certsize Size of the DER cert. * @param certsize Size of the DER cert.
* @param cert_contexthandle Optional output ptr for the cert contexthandle(this can be NULL). * @param cert_contexthandle Optional output ptr for the cert contexthandle(this can be NULL).
*/ */
Result httpcRootCertChainAddCert(u32 RootCertChain_contexthandle, u8 *cert, u32 certsize, u32 *cert_contexthandle); Result httpcRootCertChainAddCert(u32 RootCertChain_contexthandle, const u8 *cert, u32 certsize, u32 *cert_contexthandle);
/** /**
* @brief Adds a default RootCA cert to a RootCertChain. * @brief Adds a default RootCA cert to a RootCertChain.
@ -227,7 +227,7 @@ Result httpcRootCertChainRemoveCert(u32 RootCertChain_contexthandle, u32 cert_co
* @param privk_size Size of the privk. * @param privk_size Size of the privk.
* @param ClientCert_contexthandle Output ClientCert context handle. * @param ClientCert_contexthandle Output ClientCert context handle.
*/ */
Result httpcOpenClientCertContext(u8 *cert, u32 certsize, u8 *privk, u32 privk_size, u32 *ClientCert_contexthandle); Result httpcOpenClientCertContext(const u8 *cert, u32 certsize, const u8 *privk, u32 privk_size, u32 *ClientCert_contexthandle);
/** /**
* @brief Opens a ClientCert-context with a default clientclient. Up to 2 ClientCert-contexts can be open under this user-process. * @brief Opens a ClientCert-context with a default clientclient. Up to 2 ClientCert-contexts can be open under this user-process.

View File

@ -60,7 +60,7 @@ Result sslcDestroyRootCertChain(u32 RootCertChain_contexthandle);
* @param cert Pointer to the DER cert. * @param cert Pointer to the DER cert.
* @param certsize Size of the DER cert. * @param certsize Size of the DER cert.
*/ */
Result sslcAddTrustedRootCA(u32 RootCertChain_contexthandle, u8 *cert, u32 certsize, u32 *cert_contexthandle); Result sslcAddTrustedRootCA(u32 RootCertChain_contexthandle, const u8 *cert, u32 certsize, u32 *cert_contexthandle);
/** /**
* @brief Adds a default RootCA cert to a RootCertChain. * @brief Adds a default RootCA cert to a RootCertChain.
@ -95,7 +95,7 @@ Result sslcDestroy8CertChain(u32 CertChain_contexthandle);
* @param cert Pointer to the cert. * @param cert Pointer to the cert.
* @param certsize Size of the cert. * @param certsize Size of the cert.
*/ */
Result sslc8CertChainAddCert(u32 CertChain_contexthandle, u8 *cert, u32 certsize, u32 *cert_contexthandle); Result sslc8CertChainAddCert(u32 CertChain_contexthandle, const u8 *cert, u32 certsize, u32 *cert_contexthandle);
/** /**
* @brief Adds a default cert to a CertChain from sslcCreate8CertChain(). Not actually usable since no certIDs are implemented in SSL-module for this. * @brief Adds a default cert to a CertChain from sslcCreate8CertChain(). Not actually usable since no certIDs are implemented in SSL-module for this.
@ -120,7 +120,7 @@ Result sslc8CertChainRemoveCert(u32 CertChain_contexthandle, u32 cert_contexthan
* @param keysize Size of the DER key. * @param keysize Size of the DER key.
* @param ClientCert_contexthandle Output contexthandle. * @param ClientCert_contexthandle Output contexthandle.
*/ */
Result sslcOpenClientCertContext(u8 *cert, u32 certsize, u8 *key, u32 keysize, u32 *ClientCert_contexthandle); Result sslcOpenClientCertContext(const u8 *cert, u32 certsize, const u8 *key, u32 keysize, u32 *ClientCert_contexthandle);
/** /**
* @brief Opens a ClientCert-context with a default certID. * @brief Opens a ClientCert-context with a default certID.
@ -154,7 +154,7 @@ Result sslcGenerateRandomData(u8 *buf, u32 size);
* @param input_opt Input sslc options bitmask. * @param input_opt Input sslc options bitmask.
* @param hostname Server hostname. * @param hostname Server hostname.
*/ */
Result sslcCreateContext(sslcContext *context, int sockfd, u32 input_opt, char *hostname); Result sslcCreateContext(sslcContext *context, int sockfd, u32 input_opt, const char *hostname);
/* /*
* @brief Destroys a sslc context. The associated sockfd must be closed manually. * @brief Destroys a sslc context. The associated sockfd must be closed manually.
@ -187,7 +187,7 @@ Result sslcRead(sslcContext *context, void *buf, size_t len, bool peek);
* @param len Size to send. * @param len Size to send.
* @return When this isn't an error-code, this is the total transferred data size. * @return When this isn't an error-code, this is the total transferred data size.
*/ */
Result sslcWrite(sslcContext *context, void *buf, size_t len); Result sslcWrite(sslcContext *context, const void *buf, size_t len);
/* /*
* @brief Set the RootCertChain for the specified sslc context. * @brief Set the RootCertChain for the specified sslc context.
@ -247,5 +247,5 @@ Result sslcContextInitSharedmem(sslcContext *context, u8 *buf, u32 size);
* @param buf Input cert. * @param buf Input cert.
* @param size Cert size. * @param size Cert size.
*/ */
Result sslcAddCert(sslcContext *context, u8 *buf, u32 size); Result sslcAddCert(sslcContext *context, const u8 *buf, u32 size);

View File

@ -20,7 +20,7 @@ static Handle __httpc_sharedmem_handle;
static Result HTTPC_Initialize(Handle handle, u32 sharedmem_size, Handle sharedmem_handle); static Result HTTPC_Initialize(Handle handle, u32 sharedmem_size, Handle sharedmem_handle);
static Result HTTPC_Finalize(Handle handle); static Result HTTPC_Finalize(Handle handle);
static Result HTTPC_CreateContext(Handle handle, HTTPC_RequestMethod method, char* url, Handle* contextHandle); static Result HTTPC_CreateContext(Handle handle, HTTPC_RequestMethod method, const char* url, Handle* contextHandle);
static Result HTTPC_CloseContext(Handle handle, Handle contextHandle); static Result HTTPC_CloseContext(Handle handle, Handle contextHandle);
static Result HTTPC_InitializeConnectionSession(Handle handle, Handle contextHandle); static Result HTTPC_InitializeConnectionSession(Handle handle, Handle contextHandle);
@ -87,7 +87,7 @@ void httpcExit(void)
} }
} }
Result httpcOpenContext(httpcContext *context, HTTPC_RequestMethod method, char* url, u32 use_defaultproxy) Result httpcOpenContext(httpcContext *context, HTTPC_RequestMethod method, const char* url, u32 use_defaultproxy)
{ {
Result ret=0; Result ret=0;
@ -187,7 +187,7 @@ static Result HTTPC_Finalize(Handle handle)
return cmdbuf[1]; return cmdbuf[1];
} }
static Result HTTPC_CreateContext(Handle handle, HTTPC_RequestMethod method, char* url, Handle* contextHandle) static Result HTTPC_CreateContext(Handle handle, HTTPC_RequestMethod method, const char* url, Handle* contextHandle)
{ {
u32* cmdbuf=getThreadCommandBuffer(); u32* cmdbuf=getThreadCommandBuffer();
u32 l=strlen(url)+1; u32 l=strlen(url)+1;
@ -246,7 +246,7 @@ static Result HTTPC_CloseContext(Handle handle, Handle contextHandle)
return cmdbuf[1]; return cmdbuf[1];
} }
Result httpcAddRequestHeaderField(httpcContext *context, char* name, char* value) Result httpcAddRequestHeaderField(httpcContext *context, const char* name, const char* value)
{ {
u32* cmdbuf=getThreadCommandBuffer(); u32* cmdbuf=getThreadCommandBuffer();
@ -268,7 +268,7 @@ Result httpcAddRequestHeaderField(httpcContext *context, char* name, char* value
return cmdbuf[1]; return cmdbuf[1];
} }
Result httpcAddPostDataAscii(httpcContext *context, char* name, char* value) Result httpcAddPostDataAscii(httpcContext *context, const char* name, const char* value)
{ {
u32* cmdbuf=getThreadCommandBuffer(); u32* cmdbuf=getThreadCommandBuffer();
@ -290,7 +290,7 @@ Result httpcAddPostDataAscii(httpcContext *context, char* name, char* value)
return cmdbuf[1]; return cmdbuf[1];
} }
Result httpcAddPostDataRaw(httpcContext *context, u32* data, u32 len) Result httpcAddPostDataRaw(httpcContext *context, const u32* data, u32 len)
{ {
u32* cmdbuf=getThreadCommandBuffer(); u32* cmdbuf=getThreadCommandBuffer();
@ -367,7 +367,7 @@ Result httpcGetDownloadSizeState(httpcContext *context, u32* downloadedsize, u32
return cmdbuf[1]; return cmdbuf[1];
} }
Result httpcGetResponseHeader(httpcContext *context, char* name, char* value, u32 valuebuf_maxsize) Result httpcGetResponseHeader(httpcContext *context, const char* name, char* value, u32 valuebuf_maxsize)
{ {
u32* cmdbuf=getThreadCommandBuffer(); u32* cmdbuf=getThreadCommandBuffer();
@ -403,7 +403,7 @@ Result httpcGetResponseStatusCode(httpcContext *context, u32* out, u64 delay)
return cmdbuf[1]; return cmdbuf[1];
} }
Result httpcAddTrustedRootCA(httpcContext *context, u8 *cert, u32 certsize) Result httpcAddTrustedRootCA(httpcContext *context, const u8 *cert, u32 certsize)
{ {
u32* cmdbuf=getThreadCommandBuffer(); u32* cmdbuf=getThreadCommandBuffer();
@ -447,7 +447,7 @@ Result httpcSelectRootCertChain(httpcContext *context, u32 RootCertChain_context
return cmdbuf[1]; return cmdbuf[1];
} }
Result httpcSetClientCert(httpcContext *context, u8 *cert, u32 certsize, u8 *privk, u32 privk_size) Result httpcSetClientCert(httpcContext *context, const u8 *cert, u32 certsize, const u8 *privk, u32 privk_size)
{ {
u32* cmdbuf=getThreadCommandBuffer(); u32* cmdbuf=getThreadCommandBuffer();
@ -550,7 +550,7 @@ Result httpcDestroyRootCertChain(u32 RootCertChain_contexthandle)
return cmdbuf[1]; return cmdbuf[1];
} }
Result httpcRootCertChainAddCert(u32 RootCertChain_contexthandle, u8 *cert, u32 certsize, u32 *cert_contexthandle) Result httpcRootCertChainAddCert(u32 RootCertChain_contexthandle, const u8 *cert, u32 certsize, u32 *cert_contexthandle)
{ {
u32* cmdbuf=getThreadCommandBuffer(); u32* cmdbuf=getThreadCommandBuffer();
@ -600,7 +600,7 @@ Result httpcRootCertChainRemoveCert(u32 RootCertChain_contexthandle, u32 cert_co
return cmdbuf[1]; return cmdbuf[1];
} }
Result httpcOpenClientCertContext(u8 *cert, u32 certsize, u8 *privk, u32 privk_size, u32 *ClientCert_contexthandle) Result httpcOpenClientCertContext(const u8 *cert, u32 certsize, const u8 *privk, u32 privk_size, u32 *ClientCert_contexthandle)
{ {
u32* cmdbuf=getThreadCommandBuffer(); u32* cmdbuf=getThreadCommandBuffer();

View File

@ -52,7 +52,7 @@ static Result sslcipc_Initialize(void)
return cmdbuf[1]; return cmdbuf[1];
} }
static Result sslcipc_CreateContext(sslcContext *context, int sockfd, u32 input_opt, char *hostname) static Result sslcipc_CreateContext(sslcContext *context, int sockfd, u32 input_opt, const char *hostname)
{ {
u32* cmdbuf=getThreadCommandBuffer(); u32* cmdbuf=getThreadCommandBuffer();
u32 size = strlen(hostname)+1; u32 size = strlen(hostname)+1;
@ -101,7 +101,7 @@ static Result sslcipc_DestroyCertChain(u32 type, u32 contexthandle)
return cmdbuf[1]; return cmdbuf[1];
} }
static Result sslcipc_CertChainAddCert(u32 type, u32 contexthandle, u8 *cert, u32 certsize, u32 *cert_contexthandle) static Result sslcipc_CertChainAddCert(u32 type, u32 contexthandle, const u8 *cert, u32 certsize, u32 *cert_contexthandle)
{ {
u32* cmdbuf=getThreadCommandBuffer(); u32* cmdbuf=getThreadCommandBuffer();
@ -151,7 +151,7 @@ static Result sslcipc_CertChainRemoveCert(u32 type, u32 contexthandle, u32 cert_
return cmdbuf[1]; return cmdbuf[1];
} }
Result sslcOpenClientCertContext(u8 *cert, u32 certsize, u8 *key, u32 keysize, u32 *ClientCert_contexthandle) Result sslcOpenClientCertContext(const u8 *cert, u32 certsize, const u8 *key, u32 keysize, u32 *ClientCert_contexthandle)
{ {
u32* cmdbuf=getThreadCommandBuffer(); u32* cmdbuf=getThreadCommandBuffer();
@ -275,7 +275,7 @@ static Result sslcipc_StartConnectionGetOut(sslcContext *context, int *internal_
return ret; return ret;
} }
static Result sslcipc_DataTransfer(sslcContext *context, void *buf, size_t len, u32 type) static Result sslcipc_DataTransfer(sslcContext *context, const void *buf, size_t len, u32 type)
{ {
u32* cmdbuf=getThreadCommandBuffer(); u32* cmdbuf=getThreadCommandBuffer();
@ -378,7 +378,7 @@ static Result sslcipc_ContextInitSharedmem(sslcContext *context, u32 size)
return cmdbuf[1]; return cmdbuf[1];
} }
Result sslcAddCert(sslcContext *context, u8 *buf, u32 size) Result sslcAddCert(sslcContext *context, const u8 *buf, u32 size)
{ {
u32* cmdbuf=getThreadCommandBuffer(); u32* cmdbuf=getThreadCommandBuffer();
@ -405,7 +405,7 @@ Result sslcDestroyRootCertChain(u32 RootCertChain_contexthandle)
return sslcipc_DestroyCertChain(0, RootCertChain_contexthandle); return sslcipc_DestroyCertChain(0, RootCertChain_contexthandle);
} }
Result sslcAddTrustedRootCA(u32 RootCertChain_contexthandle, u8 *cert, u32 certsize, u32 *cert_contexthandle) Result sslcAddTrustedRootCA(u32 RootCertChain_contexthandle, const u8 *cert, u32 certsize, u32 *cert_contexthandle)
{ {
return sslcipc_CertChainAddCert(0, RootCertChain_contexthandle, cert, certsize, cert_contexthandle); return sslcipc_CertChainAddCert(0, RootCertChain_contexthandle, cert, certsize, cert_contexthandle);
} }
@ -430,7 +430,7 @@ Result sslcDestroy8CertChain(u32 PinnedCertChain_contexthandle)
return sslcipc_DestroyCertChain(1, PinnedCertChain_contexthandle); return sslcipc_DestroyCertChain(1, PinnedCertChain_contexthandle);
} }
Result sslc8CertChainAddCert(u32 PinnedCertChain_contexthandle, u8 *cert, u32 certsize, u32 *cert_contexthandle) Result sslc8CertChainAddCert(u32 PinnedCertChain_contexthandle, const u8 *cert, u32 certsize, u32 *cert_contexthandle)
{ {
return sslcipc_CertChainAddCert(1, PinnedCertChain_contexthandle, cert, certsize, cert_contexthandle); return sslcipc_CertChainAddCert(1, PinnedCertChain_contexthandle, cert, certsize, cert_contexthandle);
} }
@ -445,7 +445,7 @@ Result sslc8CertChainRemoveCert(u32 PinnedCertChain_contexthandle, u32 cert_cont
return sslcipc_CertChainRemoveCert(1, PinnedCertChain_contexthandle, cert_contexthandle); return sslcipc_CertChainRemoveCert(1, PinnedCertChain_contexthandle, cert_contexthandle);
} }
Result sslcCreateContext(sslcContext *context, int sockfd, u32 input_opt, char *hostname) Result sslcCreateContext(sslcContext *context, int sockfd, u32 input_opt, const char *hostname)
{ {
Result ret=0; Result ret=0;
@ -507,7 +507,7 @@ Result sslcRead(sslcContext *context, void *buf, size_t len, bool peek)
return sslcipc_DataTransfer(context, buf, len, type); return sslcipc_DataTransfer(context, buf, len, type);
} }
Result sslcWrite(sslcContext *context, void *buf, size_t len) Result sslcWrite(sslcContext *context, const void *buf, size_t len)
{ {
return sslcipc_DataTransfer(context, buf, len, 2); return sslcipc_DataTransfer(context, buf, len, 2);
} }