mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-25 15:59:36 +03:00
[project @ 2005-01-02 03:58:20 by jmb]
xcalloc/xrealloc/xstrdup-purge - Lose remaining calls (and purge the relevant functions from utils.c) svn path=/import/netsurf/; revision=1419
This commit is contained in:
parent
143d756fcf
commit
8334683068
@ -392,7 +392,16 @@ bool content_set_type(struct content *c, content_type type,
|
|||||||
callback = c->user_list->next->next->callback;
|
callback = c->user_list->next->next->callback;
|
||||||
p1 = c->user_list->next->next->p1;
|
p1 = c->user_list->next->next->p1;
|
||||||
p2 = c->user_list->next->next->p2;
|
p2 = c->user_list->next->next->p2;
|
||||||
content_add_user(clone, callback, p1, p2);
|
if (!content_add_user(clone, callback, p1, p2)) {
|
||||||
|
c->type = CONTENT_UNKNOWN;
|
||||||
|
c->status = CONTENT_STATUS_ERROR;
|
||||||
|
content_destroy(clone);
|
||||||
|
msg_data.error = messages_get("NoMemory");
|
||||||
|
content_broadcast(c, CONTENT_MSG_ERROR,
|
||||||
|
msg_data);
|
||||||
|
warn_user("NoMemory", 0);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
content_remove_user(c, callback, p1, p2);
|
content_remove_user(c, callback, p1, p2);
|
||||||
content_broadcast(clone, CONTENT_MSG_NEWPTR, msg_data);
|
content_broadcast(clone, CONTENT_MSG_NEWPTR, msg_data);
|
||||||
fetchcache_go(clone, 0, callback, p1, p2, 0, 0, false);
|
fetchcache_go(clone, 0, callback, p1, p2, 0, 0, false);
|
||||||
@ -706,24 +715,39 @@ bool content_redraw(struct content *c, int x, int y,
|
|||||||
/**
|
/**
|
||||||
* Register a user for callbacks.
|
* Register a user for callbacks.
|
||||||
*
|
*
|
||||||
|
* \param c The content to register
|
||||||
|
* \param callback The callback function
|
||||||
|
* \param p1, p2 Callback private data
|
||||||
|
* \return true on success, false otherwise and error broadcast to users
|
||||||
|
*
|
||||||
* The callback will be called with p1 and p2 when content_broadcast() is
|
* The callback will be called with p1 and p2 when content_broadcast() is
|
||||||
* called with the content.
|
* called with the content.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void content_add_user(struct content *c,
|
bool content_add_user(struct content *c,
|
||||||
void (*callback)(content_msg msg, struct content *c, void *p1,
|
void (*callback)(content_msg msg, struct content *c, void *p1,
|
||||||
void *p2, union content_msg_data data),
|
void *p2, union content_msg_data data),
|
||||||
void *p1, void *p2)
|
void *p1, void *p2)
|
||||||
{
|
{
|
||||||
struct content_user *user;
|
struct content_user *user;
|
||||||
|
union content_msg_data msg_data;
|
||||||
|
|
||||||
LOG(("content %s, user %p %p %p", c->url, callback, p1, p2));
|
LOG(("content %s, user %p %p %p", c->url, callback, p1, p2));
|
||||||
user = xcalloc(1, sizeof(*user));
|
user = calloc(1, sizeof(*user));
|
||||||
|
if (!user) {
|
||||||
|
c->status = CONTENT_STATUS_ERROR;
|
||||||
|
msg_data.error = messages_get("NoMemory");
|
||||||
|
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
user->callback = callback;
|
user->callback = callback;
|
||||||
user->p1 = p1;
|
user->p1 = p1;
|
||||||
user->p2 = p2;
|
user->p2 = p2;
|
||||||
user->stop = false;
|
user->stop = false;
|
||||||
user->next = c->user_list->next;
|
user->next = c->user_list->next;
|
||||||
c->user_list->next = user;
|
c->user_list->next = user;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ bool content_redraw(struct content *c, int x, int y,
|
|||||||
int width, int height,
|
int width, int height,
|
||||||
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
||||||
float scale, unsigned long background_colour);
|
float scale, unsigned long background_colour);
|
||||||
void content_add_user(struct content *c,
|
bool content_add_user(struct content *c,
|
||||||
void (*callback)(content_msg msg, struct content *c, void *p1,
|
void (*callback)(content_msg msg, struct content *c, void *p1,
|
||||||
void *p2, union content_msg_data data),
|
void *p2, union content_msg_data data),
|
||||||
void *p1, void *p2);
|
void *p1, void *p2);
|
||||||
|
@ -84,8 +84,10 @@ struct content * fetchcache(const char *url,
|
|||||||
if (!post_urlenc && !post_multipart) {
|
if (!post_urlenc && !post_multipart) {
|
||||||
if ((c = content_get(url1)) != NULL) {
|
if ((c = content_get(url1)) != NULL) {
|
||||||
free(url1);
|
free(url1);
|
||||||
content_add_user(c, callback, p1, p2);
|
if (!content_add_user(c, callback, p1, p2))
|
||||||
return c;
|
return NULL;
|
||||||
|
else
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +95,9 @@ struct content * fetchcache(const char *url,
|
|||||||
free(url1);
|
free(url1);
|
||||||
if (!c)
|
if (!c)
|
||||||
return NULL;
|
return NULL;
|
||||||
content_add_user(c, callback, p1, p2);
|
if (!content_add_user(c, callback, p1, p2)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!post_urlenc && !post_multipart)
|
if (!post_urlenc && !post_multipart)
|
||||||
c->fresh = true;
|
c->fresh = true;
|
||||||
|
@ -41,23 +41,27 @@ unsigned long nsfont_width(struct font_data *font, const char * text,
|
|||||||
return length * 10;
|
return length * 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsfont_position_in_string(struct font_data* font, const char* text,
|
bool nsfont_position_in_string(struct font_data* font, const char* text,
|
||||||
size_t length, unsigned long x, int* char_offset, int* pixel_offset)
|
size_t length, unsigned long x, int* char_offset, int* pixel_offset)
|
||||||
{
|
{
|
||||||
assert(font != 0 && text != 0);
|
assert(font != 0 && text != 0);
|
||||||
|
|
||||||
*char_offset = x / 10;
|
*char_offset = x / 10;
|
||||||
*pixel_offset = x;
|
*pixel_offset = x;
|
||||||
|
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct font_set *nsfont_new_set()
|
struct font_set *nsfont_new_set()
|
||||||
{
|
{
|
||||||
struct font_set *set = xcalloc(1, sizeof(*set));
|
struct font_set *set;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
set = calloc(1, sizeof(*set));
|
||||||
|
if (!set)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; i < FONT_FAMILIES * 4; i++)
|
for (i = 0; i < FONT_FAMILIES * 4; i++)
|
||||||
set->font[i] = 0;
|
set->font[i] = 0;
|
||||||
|
|
||||||
@ -101,7 +105,9 @@ struct font_data *nsfont_open(struct font_set *set, struct css_style *style)
|
|||||||
if (data->size == size)
|
if (data->size == size)
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
data = xcalloc(1, sizeof(*data));
|
data = calloc(1, sizeof(*data));
|
||||||
|
if (!data)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
data->size = size;
|
data->size = size;
|
||||||
data->space_width = nsfont_width(data, " ", sizeof(" ")-1);
|
data->space_width = nsfont_width(data, " ", sizeof(" ")-1);
|
||||||
@ -155,9 +161,11 @@ char *nsfont_split(struct font_data *data, const char * text,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void nsfont_paint(struct font_data *data, const char *text,
|
bool nsfont_paint(struct font_data *data, const char *text,
|
||||||
size_t length, int xpos, int ypos, void *trfm)
|
size_t length, int xpos, int ypos, void *trfm)
|
||||||
{
|
{
|
||||||
assert(data != NULL);
|
assert(data != NULL);
|
||||||
assert(text != NULL);
|
assert(text != NULL);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1095,7 +1095,7 @@ void browser_window_textarea_click(struct browser_window *bw,
|
|||||||
* Consecutive BR may not be present. These constraints are satisfied
|
* Consecutive BR may not be present. These constraints are satisfied
|
||||||
* by using a 0-length INLINE for blank lines. */
|
* by using a 0-length INLINE for blank lines. */
|
||||||
|
|
||||||
int char_offset, pixel_offset, new_scroll_y;
|
int char_offset = 0, pixel_offset = 0, new_scroll_y;
|
||||||
struct box *inline_container, *text_box;
|
struct box *inline_container, *text_box;
|
||||||
|
|
||||||
inline_container = textarea->children;
|
inline_container = textarea->children;
|
||||||
@ -1464,8 +1464,8 @@ void browser_window_input_click(struct browser_window* bw,
|
|||||||
int box_x, int box_y,
|
int box_x, int box_y,
|
||||||
int x, int y)
|
int x, int y)
|
||||||
{
|
{
|
||||||
size_t char_offset;
|
size_t char_offset = 0;
|
||||||
int pixel_offset, dx = 0;
|
int pixel_offset = 0, dx = 0;
|
||||||
struct box *text_box = input->children->children;
|
struct box *text_box = input->children->children;
|
||||||
int uchars;
|
int uchars;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
|
@ -107,7 +107,7 @@ unsigned long nsfont_width(struct font_data *font, const char *text,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void nsfont_position_in_string(struct font_data *font, const char *text,
|
bool nsfont_position_in_string(struct font_data *font, const char *text,
|
||||||
size_t length, unsigned long x, int *char_offset,
|
size_t length, unsigned long x, int *char_offset,
|
||||||
int *pixel_offset)
|
int *pixel_offset)
|
||||||
{
|
{
|
||||||
@ -131,6 +131,8 @@ void nsfont_position_in_string(struct font_data *font, const char *text,
|
|||||||
|
|
||||||
*char_offset = index;
|
*char_offset = index;
|
||||||
*pixel_offset = PANGO_PIXELS(pos.x);
|
*pixel_offset = PANGO_PIXELS(pos.x);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,13 +33,13 @@ struct font_data *nsfont_open(struct font_set *set, struct css_style *style);
|
|||||||
void nsfont_free_set(struct font_set *set);
|
void nsfont_free_set(struct font_set *set);
|
||||||
unsigned long nsfont_width(struct font_data *font, const char *text,
|
unsigned long nsfont_width(struct font_data *font, const char *text,
|
||||||
size_t length);
|
size_t length);
|
||||||
void nsfont_position_in_string(struct font_data *font, const char *text,
|
bool nsfont_position_in_string(struct font_data *font, const char *text,
|
||||||
size_t length, unsigned long x, int *char_offset,
|
size_t length, unsigned long x, int *char_offset,
|
||||||
int *pixel_offset);
|
int *pixel_offset);
|
||||||
char *nsfont_split(struct font_data *font, const char *text,
|
char *nsfont_split(struct font_data *font, const char *text,
|
||||||
size_t length,
|
size_t length,
|
||||||
unsigned int width, unsigned int *used_width);
|
unsigned int width, unsigned int *used_width);
|
||||||
void nsfont_paint(struct font_data *font, const char *str,
|
bool nsfont_paint(struct font_data *font, const char *str,
|
||||||
size_t length, int xpos, int ypos, void *trfm);
|
size_t length, int xpos, int ypos, void *trfm);
|
||||||
void nsfont_txtenum(struct font_data *font, const char *text,
|
void nsfont_txtenum(struct font_data *font, const char *text,
|
||||||
size_t length,
|
size_t length,
|
||||||
|
@ -592,9 +592,13 @@ bool html_find_stylesheets(struct content *c, xmlNode *head)
|
|||||||
if (c->data.html.stylesheet_content[STYLESHEET_STYLE] != 0) {
|
if (c->data.html.stylesheet_content[STYLESHEET_STYLE] != 0) {
|
||||||
if (css_convert(c->data.html.stylesheet_content[STYLESHEET_STYLE], c->width,
|
if (css_convert(c->data.html.stylesheet_content[STYLESHEET_STYLE], c->width,
|
||||||
c->height)) {
|
c->height)) {
|
||||||
content_add_user(c->data.html.stylesheet_content[STYLESHEET_STYLE],
|
if (!content_add_user(c->data.html.stylesheet_content[STYLESHEET_STYLE],
|
||||||
html_convert_css_callback,
|
html_convert_css_callback,
|
||||||
c, (void *) STYLESHEET_STYLE);
|
c, (void *) STYLESHEET_STYLE)) {
|
||||||
|
/* no memory */
|
||||||
|
c->data.html.stylesheet_content[STYLESHEET_STYLE] = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* conversion failed */
|
/* conversion failed */
|
||||||
c->data.html.stylesheet_content[STYLESHEET_STYLE] = 0;
|
c->data.html.stylesheet_content[STYLESHEET_STYLE] = 0;
|
||||||
|
@ -57,7 +57,7 @@ void gui_401login_open(struct browser_window *bw, struct content *c, char *realm
|
|||||||
|
|
||||||
ro_gui_401login_open(bw->window->window, host, realm, murl);
|
ro_gui_401login_open(bw->window->window, host, realm, murl);
|
||||||
|
|
||||||
xfree(host);
|
free(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -134,8 +134,8 @@ void get_unamepwd(void)
|
|||||||
{
|
{
|
||||||
char *lidets = calloc(strlen(uname)+strlen(pwd)+2, sizeof(char));
|
char *lidets = calloc(strlen(uname)+strlen(pwd)+2, sizeof(char));
|
||||||
if (!lidets) {
|
if (!lidets) {
|
||||||
LOG(("Insufficient memory for calloc"));
|
LOG(("Insufficient memory for calloc"));
|
||||||
warn_user("NoMemory", 0);
|
warn_user("NoMemory", 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,6 +394,9 @@ unsigned long nsfont_width(struct font_data *font, const char *text,
|
|||||||
break;
|
break;
|
||||||
case FONTTYPE_STANDARD_LATIN1: {
|
case FONTTYPE_STANDARD_LATIN1: {
|
||||||
const char *loc_text = cnv_strn_local_enc(text, length, NULL);
|
const char *loc_text = cnv_strn_local_enc(text, length, NULL);
|
||||||
|
if (!loc_text)
|
||||||
|
return 0;
|
||||||
|
|
||||||
error = xfont_scan_string((font_f)font->handle,
|
error = xfont_scan_string((font_f)font->handle,
|
||||||
loc_text,
|
loc_text,
|
||||||
font_GIVEN_FONT
|
font_GIVEN_FONT
|
||||||
@ -430,8 +433,9 @@ unsigned long nsfont_width(struct font_data *font, const char *text,
|
|||||||
* \param x horizontal position in pixels
|
* \param x horizontal position in pixels
|
||||||
* \param char_offset updated to give the offset in the string
|
* \param char_offset updated to give the offset in the string
|
||||||
* \param pixel_offset updated to give the coordinate of the character in pixels
|
* \param pixel_offset updated to give the coordinate of the character in pixels
|
||||||
|
* \return true on success, false on failure.
|
||||||
*/
|
*/
|
||||||
void nsfont_position_in_string(struct font_data *font, const char *text,
|
bool nsfont_position_in_string(struct font_data *font, const char *text,
|
||||||
size_t length, unsigned long x,
|
size_t length, unsigned long x,
|
||||||
int *char_offset, int *pixel_offset)
|
int *char_offset, int *pixel_offset)
|
||||||
{
|
{
|
||||||
@ -475,6 +479,9 @@ void nsfont_position_in_string(struct font_data *font, const char *text,
|
|||||||
case FONTTYPE_STANDARD_LATIN1: {
|
case FONTTYPE_STANDARD_LATIN1: {
|
||||||
const ptrdiff_t *back_mapP;
|
const ptrdiff_t *back_mapP;
|
||||||
const char *loc_text = cnv_strn_local_enc(text, length, &back_mapP);
|
const char *loc_text = cnv_strn_local_enc(text, length, &back_mapP);
|
||||||
|
if (!loc_text)
|
||||||
|
return false;
|
||||||
|
|
||||||
error = xfont_scan_string((font_f)font->handle,
|
error = xfont_scan_string((font_f)font->handle,
|
||||||
loc_text,
|
loc_text,
|
||||||
font_GIVEN_BLOCK
|
font_GIVEN_BLOCK
|
||||||
@ -495,11 +502,14 @@ void nsfont_position_in_string(struct font_data *font, const char *text,
|
|||||||
}
|
}
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
LOG(("(u)font_scan_string failed : %s\n", error->errmess));
|
LOG(("(u)font_scan_string failed : %s\n", error->errmess));
|
||||||
die("nsfont_position_in_string: (u)font_scan_string failed");
|
/* die("nsfont_position_in_string: (u)font_scan_string failed");*/
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*char_offset = (int)(split - text);
|
*char_offset = (int)(split - text);
|
||||||
*pixel_offset = x_out / 800;
|
*pixel_offset = x_out / 800;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -559,6 +569,9 @@ char *nsfont_split(struct font_data *font, const char *text,
|
|||||||
case FONTTYPE_STANDARD_LATIN1: {
|
case FONTTYPE_STANDARD_LATIN1: {
|
||||||
const ptrdiff_t *back_mapP;
|
const ptrdiff_t *back_mapP;
|
||||||
const char *loc_text = cnv_strn_local_enc(text, length, &back_mapP);
|
const char *loc_text = cnv_strn_local_enc(text, length, &back_mapP);
|
||||||
|
if (!loc_text)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
error = xfont_scan_string((font_f)font->handle,
|
error = xfont_scan_string((font_f)font->handle,
|
||||||
loc_text,
|
loc_text,
|
||||||
font_GIVEN_BLOCK
|
font_GIVEN_BLOCK
|
||||||
@ -591,7 +604,7 @@ char *nsfont_split(struct font_data *font, const char *text,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void nsfont_paint(struct font_data *data, const char *text,
|
bool nsfont_paint(struct font_data *data, const char *text,
|
||||||
size_t length, int xpos, int ypos, void *trfm)
|
size_t length, int xpos, int ypos, void *trfm)
|
||||||
{
|
{
|
||||||
os_error *error;
|
os_error *error;
|
||||||
@ -648,6 +661,9 @@ void nsfont_paint(struct font_data *data, const char *text,
|
|||||||
break;
|
break;
|
||||||
case FONTTYPE_STANDARD_LATIN1: {
|
case FONTTYPE_STANDARD_LATIN1: {
|
||||||
const char *loc_text = cnv_strn_local_enc(text, length, NULL);
|
const char *loc_text = cnv_strn_local_enc(text, length, NULL);
|
||||||
|
if (!loc_text)
|
||||||
|
return false;
|
||||||
|
|
||||||
error = xfont_paint((font_f)data->handle, loc_text,
|
error = xfont_paint((font_f)data->handle, loc_text,
|
||||||
flags, xpos, ypos, NULL,
|
flags, xpos, ypos, NULL,
|
||||||
trfm, 0);
|
trfm, 0);
|
||||||
@ -660,8 +676,11 @@ void nsfont_paint(struct font_data *data, const char *text,
|
|||||||
}
|
}
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
LOG(("(u)font_paint failed : %s\n", error->errmess));
|
LOG(("(u)font_paint failed : %s\n", error->errmess));
|
||||||
die("nsfont_paint: (u)font_paint failed");
|
/*die("nsfont_paint: (u)font_paint failed");*/
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -312,11 +312,10 @@ bool ro_plot_text(int x, int y, struct font_data *font,
|
|||||||
error->errnum, error->errmess));
|
error->errnum, error->errmess));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
nsfont_paint(font, text, length,
|
return nsfont_paint(font, text, length,
|
||||||
ro_plot_origin_x + x * 2,
|
ro_plot_origin_x + x * 2,
|
||||||
ro_plot_origin_y - y * 2,
|
ro_plot_origin_y - y * 2,
|
||||||
&ro_plot_trfm);
|
&ro_plot_trfm);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
47
riscos/uri.c
47
riscos/uri.c
@ -32,43 +32,42 @@ extern wimp_t task_handle;
|
|||||||
|
|
||||||
void ro_uri_message_received(uri_full_message_process* uri_message)
|
void ro_uri_message_received(uri_full_message_process* uri_message)
|
||||||
{
|
{
|
||||||
uri_h uri_handle;
|
uri_h uri_handle;
|
||||||
char* uri_requested;
|
char* uri_requested;
|
||||||
int uri_length;
|
int uri_length;
|
||||||
|
|
||||||
uri_handle = uri_message->handle;
|
uri_handle = uri_message->handle;
|
||||||
|
|
||||||
if (!fetch_can_fetch(uri_message->uri)) return;
|
if (!fetch_can_fetch(uri_message->uri)) return;
|
||||||
|
|
||||||
uri_message->your_ref = uri_message->my_ref;
|
uri_message->your_ref = uri_message->my_ref;
|
||||||
uri_message->action = message_URI_PROCESS_ACK;
|
uri_message->action = message_URI_PROCESS_ACK;
|
||||||
|
|
||||||
xwimp_send_message(wimp_USER_MESSAGE,
|
xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)uri_message,
|
||||||
(wimp_message*)uri_message,
|
uri_message->sender);
|
||||||
uri_message->sender);
|
|
||||||
|
|
||||||
xuri_request_uri(0, 0, 0, uri_handle, &uri_length);
|
xuri_request_uri(0, 0, 0, uri_handle, &uri_length);
|
||||||
uri_requested = calloc((unsigned int)uri_length, sizeof(char));
|
uri_requested = calloc((unsigned int)uri_length, sizeof(char));
|
||||||
|
|
||||||
if (uri_requested == NULL)
|
if (uri_requested == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xuri_request_uri(0, uri_requested, uri_length, uri_handle, NULL);
|
xuri_request_uri(0, uri_requested, uri_length, uri_handle, NULL);
|
||||||
|
|
||||||
browser_window_create(uri_requested, NULL, 0);
|
browser_window_create(uri_requested, NULL, 0);
|
||||||
|
|
||||||
xfree(uri_requested);
|
free(uri_requested);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ro_uri_launch(char *uri) {
|
bool ro_uri_launch(char *uri)
|
||||||
|
{
|
||||||
uri_h uri_handle;
|
uri_h uri_handle;
|
||||||
wimp_t handle_task;
|
wimp_t handle_task;
|
||||||
uri_dispatch_flags returned;
|
uri_dispatch_flags returned;
|
||||||
os_error *e;
|
os_error *e;
|
||||||
|
|
||||||
e = xuri_dispatch(uri_DISPATCH_INFORM_CALLER, uri, task_handle,
|
e = xuri_dispatch(uri_DISPATCH_INFORM_CALLER, uri, task_handle,
|
||||||
&returned, &handle_task, &uri_handle);
|
&returned, &handle_task, &uri_handle);
|
||||||
|
|
||||||
if (e || returned & 1) {
|
if (e || returned & 1) {
|
||||||
return false;
|
return false;
|
||||||
@ -77,8 +76,8 @@ bool ro_uri_launch(char *uri) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ro_uri_bounce(uri_full_message_return_result *message) {
|
void ro_uri_bounce(uri_full_message_return_result *message)
|
||||||
|
{
|
||||||
char uri_buf[512];
|
char uri_buf[512];
|
||||||
os_error *e;
|
os_error *e;
|
||||||
|
|
||||||
@ -87,8 +86,8 @@ void ro_uri_bounce(uri_full_message_return_result *message) {
|
|||||||
e = xuri_request_uri(0, uri_buf, sizeof uri_buf, message->handle, 0);
|
e = xuri_request_uri(0, uri_buf, sizeof uri_buf, message->handle, 0);
|
||||||
|
|
||||||
if (e) {
|
if (e) {
|
||||||
LOG(("xuri_request_uri: %d: %s", e->errnum, e->errmess));
|
LOG(("xuri_request_uri: %d: %s", e->errnum, e->errmess));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ro_url_load(uri_buf);
|
ro_url_load(uri_buf);
|
||||||
|
@ -46,40 +46,6 @@ int whitespace(const char * str)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void * xcalloc(const size_t n, const size_t size)
|
|
||||||
{
|
|
||||||
void * p = calloc(n, size);
|
|
||||||
if (p == 0) die("Out of memory in xcalloc()");
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void * xrealloc(void * p, const size_t size)
|
|
||||||
{
|
|
||||||
p = realloc(p, size);
|
|
||||||
if (p == 0) die("Out of memory in xrealloc()");
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void xfree(void* p)
|
|
||||||
{
|
|
||||||
if (p == 0)
|
|
||||||
fprintf(stderr, "Attempt to free NULL pointer\n");
|
|
||||||
else
|
|
||||||
free(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
char * xstrdup(const char * const s)
|
|
||||||
{
|
|
||||||
char *c;
|
|
||||||
if (s == NULL)
|
|
||||||
fprintf(stderr, "Attempt to strdup() NULL pointer\n");
|
|
||||||
c = malloc(((s == NULL) ? 0 : strlen(s)) + 1);
|
|
||||||
if (c == NULL) die("Out of memory in xstrdup()");
|
|
||||||
strcpy(c, (s == NULL) ? "" : s);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace consecutive whitespace with a single space.
|
* Replace consecutive whitespace with a single space.
|
||||||
*
|
*
|
||||||
@ -223,13 +189,22 @@ char *cnv_strn_local_enc(const char *s, int length, const ptrdiff_t **back_mapPP
|
|||||||
/* Buffer at d & back_mapP can be overdimentioned but is certainly
|
/* Buffer at d & back_mapP can be overdimentioned but is certainly
|
||||||
* big enough to carry the end result.
|
* big enough to carry the end result.
|
||||||
*/
|
*/
|
||||||
char *d = xcalloc(length + 1, sizeof(char));
|
char *d, *d0;
|
||||||
ptrdiff_t *back_mapP = (back_mapPP != NULL) ? xcalloc(length + 1, sizeof(ptrdiff_t)) : NULL;
|
|
||||||
char *d0 = d;
|
|
||||||
const char * const s0 = s;
|
const char * const s0 = s;
|
||||||
|
ptrdiff_t *back_mapP = NULL;
|
||||||
|
|
||||||
if (back_mapPP != NULL)
|
if (back_mapPP != NULL) {
|
||||||
|
back_mapP = calloc(length + 1, sizeof(ptrdiff_t));
|
||||||
|
if (!back_mapP)
|
||||||
|
return NULL;
|
||||||
*back_mapPP = back_mapP;
|
*back_mapPP = back_mapP;
|
||||||
|
}
|
||||||
|
|
||||||
|
d = calloc(length + 1, sizeof(char));
|
||||||
|
if (!d)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
d0 = d;
|
||||||
|
|
||||||
while (length != 0) {
|
while (length != 0) {
|
||||||
int u, chars;
|
int u, chars;
|
||||||
|
@ -19,15 +19,12 @@
|
|||||||
void die(const char * const error);
|
void die(const char * const error);
|
||||||
char * strip(char * const s);
|
char * strip(char * const s);
|
||||||
int whitespace(const char * str);
|
int whitespace(const char * str);
|
||||||
void * xcalloc(const size_t n, const size_t size);
|
|
||||||
void * xrealloc(void * p, const size_t size);
|
|
||||||
void xfree(void* p);
|
|
||||||
char * xstrdup(const char * const s);
|
|
||||||
char * squash_whitespace(const char * s);
|
char * squash_whitespace(const char * s);
|
||||||
char *cnv_space2nbsp(const char *s);
|
char *cnv_space2nbsp(const char *s);
|
||||||
char *cnv_local_enc_str(const char *s, size_t length);
|
char *cnv_local_enc_str(const char *s, size_t length);
|
||||||
char *cnv_str_local_enc(const char *s);
|
char *cnv_str_local_enc(const char *s);
|
||||||
char *cnv_strn_local_enc(const char *s, int length, const ptrdiff_t **back_mapPP);
|
char *cnv_strn_local_enc(const char *s, int length,
|
||||||
|
const ptrdiff_t **back_mapPP);
|
||||||
bool is_dir(const char *path);
|
bool is_dir(const char *path);
|
||||||
void regcomp_wrapper(regex_t *preg, const char *regex, int cflags);
|
void regcomp_wrapper(regex_t *preg, const char *regex, int cflags);
|
||||||
void clean_cookiejar(void);
|
void clean_cookiejar(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user