Wii network module.
More...
#include <stdio.h>
#include <ctype.h>
#include <gccore.h>
#include <ogcsys.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <malloc.h>
#include <network.h>
#include <ogc/lwp_watchdog.h>
#include <sys/types.h>
#include <sys/errno.h>
#include <fcntl.h>
#include "http.h"
#include "trace.h"
Defines |
#define | TCP_CONNECT_TIMEOUT 5000 |
#define | TCP_BLOCK_SIZE (16 * 1024) |
#define | TCP_BLOCK_RECV_TIMEOUT 4000 |
#define | TCP_BLOCK_SEND_TIMEOUT 4000 |
#define | HTTP_TIMEOUT 300000 |
#define | MAX_LEN 256 |
#define | NUM_THREADS 1 |
#define | MAX_BUFFER_SIZE 10240 |
Enumerations |
enum | http_res {
HTTPR_OK,
HTTPR_ERR_CONNECT,
HTTPR_ERR_REQUEST,
HTTPR_ERR_STATUS,
HTTPR_ERR_TOOBIG,
HTTPR_ERR_RECEIVE
} |
Functions |
s32 | tcp_socket (void) |
s32 | tcp_connect (char *host, const u16 port) |
char * | tcp_readln (const s32 s, const u16 max_length, const u64 start_time, const u16 timeout) |
bool | tcp_read (const s32 s, u8 **buffer, const u32 length) |
bool | tcp_write (const s32 s, const u8 *buffer, const u32 length) |
int | tcp_init (void) |
void | tcp_sleep (unsigned int seconds) |
bool | http_split_url (char **host, char **path, const char *url) |
char * | http_replaceString (char *orgstr, char *oldstr, char *newstr) |
bool | http_convertHTMlToAscii (char *in, int inSize) |
char | http_bin2hex (int val) |
char * | http_encode_url (char *buf, const char *str) |
void | http_googleAnalysicUrl (char *buffer, char *domain, char *url, char *id) |
bool | http_request (char *url, const u32 max_size) |
bool | http_get_result (u32 *_http_status, u8 **content, u32 *length) |
char * | http_findToken (u8 *buffer, int bufsize, char *token) |
void * | tcp_thread (void *threadid) |
void | tcp_clear_memory (void) |
int | tcp_get_state_nr (void) |
char * | tcp_get_state (void) |
int | tcp_set_state (int state, char *userData3) |
char * | tcp_get_version (void) |
char * | tcp_get_releasenote (void) |
char * | tcp_get_global_highscore (void) |
char * | tcp_get_today_highscore (void) |
int | tcp_start_thread (char *name, char *version, char *id1, char *url1, char *id2, char *url2, char *id3, char *url3, char *id4, char *url4, char *token, char *userData2, char *userData3) |
int | tcp_stop_thread (void) |
Variables |
lwp_t | threads [NUM_THREADS] |
mutex_t | mutexcheck |
mutex_t | mutexversion |
bool | do_tcp_treat |
char * | appl_host |
char * | appl_path |
char | appl_new_version [MAX_LEN] |
char | appl_release_notes [MAX_BUFFER_SIZE] |
char | appl_token [MAX_LEN] |
char | appl_global_highscore [MAX_BUFFER_SIZE] |
char | appl_today_highscore [MAX_BUFFER_SIZE] |
char | appl_name [MAX_LEN] |
char | appl_version [MAX_LEN] |
char | appl_id1 [MAX_LEN] |
char | appl_url1 [MAX_LEN] |
char | appl_id2 [MAX_LEN] |
char | appl_url2 [MAX_LEN] |
char | appl_id3 [MAX_LEN] |
char | appl_url3 [MAX_LEN] |
char | appl_id4 [MAX_LEN] |
char | appl_url4 [MAX_LEN] |
char | appl_userData2 [MAX_LEN] |
char | appl_userData3 [MAX_LEN] |
char | var_cookie [MAX_LEN] |
GXRModeObj * | rmode |
int | tcp_state |
int | tcp_state_prev |
char * | http_host |
u16 | http_port |
char * | http_path |
u32 | http_max_size |
http_res | result |
u32 | http_status |
u32 | content_length |
u8 * | http_data |
int | retval |
u32 | outlen |
u8 * | outbuf |
Detailed Description
Wii network module.
- Author:
- wplaat
Copyright (C) 2008-2010 PlaatSoft
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Define Documentation
#define HTTP_TIMEOUT 300000 |
#define MAX_BUFFER_SIZE 10240 |
#define TCP_BLOCK_RECV_TIMEOUT 4000 |
#define TCP_BLOCK_SEND_TIMEOUT 4000 |
#define TCP_BLOCK_SIZE (16 * 1024) |
#define TCP_CONNECT_TIMEOUT 5000 |
Enumeration Type Documentation
- Enumerator:
HTTPR_OK |
|
HTTPR_ERR_CONNECT |
|
HTTPR_ERR_REQUEST |
|
HTTPR_ERR_STATUS |
|
HTTPR_ERR_TOOBIG |
|
HTTPR_ERR_RECEIVE |
|
Function Documentation
char http_bin2hex |
( |
int |
val |
) |
|
bool http_convertHTMlToAscii |
( |
char * |
in, |
|
|
int |
inSize | |
|
) |
| | |
char* http_encode_url |
( |
char * |
buf, |
|
|
const char * |
str | |
|
) |
| | |
char* http_findToken |
( |
u8 * |
buffer, |
|
|
int |
bufsize, |
|
|
char * |
token | |
|
) |
| | |
bool http_get_result |
( |
u32 * |
_http_status, |
|
|
u8 ** |
content, |
|
|
u32 * |
length | |
|
) |
| | |
void http_googleAnalysicUrl |
( |
char * |
buffer, |
|
|
char * |
domain, |
|
|
char * |
url, |
|
|
char * |
id | |
|
) |
| | |
char* http_replaceString |
( |
char * |
orgstr, |
|
|
char * |
oldstr, |
|
|
char * |
newstr | |
|
) |
| | |
bool http_request |
( |
char * |
url, |
|
|
const u32 |
max_size | |
|
) |
| | |
bool http_split_url |
( |
char ** |
host, |
|
|
char ** |
path, |
|
|
const char * |
url | |
|
) |
| | |
Splits url in parts.
- Author:
- wplaat
- Parameters:
-
| host | The host part. |
| path | The path part. |
| url | The input URL. |
- Returns:
- succesfull
void tcp_clear_memory |
( |
void |
|
) |
|
s32 tcp_connect |
( |
char * |
host, |
|
|
const u16 |
port | |
|
) |
| | |
Make tcp connect.
- Author:
- wplaat
- Parameters:
-
| host | The host name |
| port | Port number |
- Returns:
- Network handler
char* tcp_get_global_highscore |
( |
void |
|
) |
|
char* tcp_get_releasenote |
( |
void |
|
) |
|
char* tcp_get_state |
( |
void |
|
) |
|
int tcp_get_state_nr |
( |
void |
|
) |
|
char* tcp_get_today_highscore |
( |
void |
|
) |
|
char* tcp_get_version |
( |
void |
|
) |
|
Init tcp layer.
- Author:
- wplaat
- Returns:
- succesful (<0 failure)
bool tcp_read |
( |
const s32 |
s, |
|
|
u8 ** |
buffer, |
|
|
const u32 |
length | |
|
) |
| | |
Receive data out tcp layer.
- Author:
- wplaat
- Parameters:
-
| s | Network handler. |
| buffer | Receive buffer. |
| length | Amount of bytes received. |
- Returns:
- succesful
char* tcp_readln |
( |
const s32 |
s, |
|
|
const u16 |
max_length, |
|
|
const u64 |
start_time, |
|
|
const u16 |
timeout | |
|
) |
| | |
Read line out received tcp information.
- Author:
- wplaat
- Parameters:
-
| s | Network handler. |
| max_length | Max length of return string. |
| start_time | Start time. |
| timeout | Max waiting before timeout. |
- Returns:
- received line
int tcp_set_state |
( |
int |
state, |
|
|
char * |
userData3 | |
|
) |
| | |
void tcp_sleep |
( |
unsigned int |
seconds |
) |
|
Sleep some time.
- Author:
- wplaat
- Parameters:
-
| seconds | The wait time in seconds. |
Open tcp socket.
- Author:
- wplaat
- Returns:
- status (<0 failure, >=0 succesful)
int tcp_start_thread |
( |
char * |
name, |
|
|
char * |
version, |
|
|
char * |
id1, |
|
|
char * |
url1, |
|
|
char * |
id2, |
|
|
char * |
url2, |
|
|
char * |
id3, |
|
|
char * |
url3, |
|
|
char * |
id4, |
|
|
char * |
url4, |
|
|
char * |
token, |
|
|
char * |
userData2, |
|
|
char * |
userData3 | |
|
) |
| | |
int tcp_stop_thread |
( |
void |
|
) |
|
void* tcp_thread |
( |
void * |
threadid |
) |
|
bool tcp_write |
( |
const s32 |
s, |
|
|
const u8 * |
buffer, |
|
|
const u32 |
length | |
|
) |
| | |
Write data to tcp layer.
- Author:
- wplaat
- Parameters:
-
| s | The network handler. |
| buffer | THe data buffer. |
| length | The data lenght. |
- Returns:
- succusfull
Variable Documentation