NetSurf
Functions | Variables
misc.c File Reference
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/utility.h>
#include <proto/intuition.h>
#include "utils/utils.h"
#include "utils/corestrings.h"
#include "utils/log.h"
#include "utils/file.h"
#include "utils/messages.h"
#include "utils/nsurl.h"
#include "utils/url.h"
#include "netsurf/window.h"
#include "amiga/gui.h"
#include "amiga/misc.h"
#include "amiga/utf8.h"
Include dependency graph for misc.c:

Go to the source code of this file.

Functions

static LONG ami_misc_req (const char *message, uint32 type)
 
void ami_misc_fatal_error (const char *message)
 
nserror amiga_warn_user (const char *warning, const char *detail)
 Warn the user of an event. More...
 
int32 amiga_warn_user_multi (const char *body, const char *opt1, const char *opt2, struct Window *win)
 
static nserror amiga_nsurl_to_path (struct nsurl *url, char **path_out)
 Create a path from a nsurl using amiga file handling. More...
 
static nserror amiga_path_to_nsurl (const char *path, struct nsurl **url_out)
 Create a nsurl from a path using amiga file handling. More...
 
char * translate_escape_chars (const char *s)
 returns a string with escape chars translated and string converted to local charset (based on remove_underscores from utils.c) More...
 
static nserror amiga_vmkpath (char **str, size_t *size, size_t nelm, va_list ap)
 Generate a posix path from one or more component elemnts. More...
 
static nserror amiga_basename (const char *path, char **str, size_t *size)
 Get the basename of a file using posix path handling. More...
 
static nserror amiga_mkdir_all (const char *fname)
 Ensure that all directory elements needed to store a filename exist. More...
 

Variables

static struct gui_file_table file_table
 
struct gui_file_tableamiga_file_table = &file_table
 

Function Documentation

◆ ami_misc_fatal_error()

void ami_misc_fatal_error ( const char *  message)

Definition at line 73 of file misc.c.

References ami_misc_req(), and TDRIMAGE_ERROR.

Referenced by ami_gui_get_user_dir(), ami_gui_resources_open(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_misc_req()

static LONG ami_misc_req ( const char *  message,
uint32  type 
)
static

Definition at line 45 of file misc.c.

References ami_gui_get_active_gw(), ami_gui_get_window(), cur_gw, messages_get(), NSLOG, and type.

Referenced by ami_misc_fatal_error(), and amiga_warn_user().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ amiga_basename()

static nserror amiga_basename ( const char *  path,
char **  str,
size_t *  size 
)
static

Get the basename of a file using posix path handling.

This gets the last element of a path and returns it.

Parameters
[in]pathThe path to extract the name from.
[in,out]strPointer to string pointer if this is NULL enough storage will be allocated for the path element.
[in,out]sizeThe size of the space available if str not NULL on input and set to the total output length on output.
Returns
NSERROR_OK and the complete path is written to str or error code on faliure.

Definition at line 365 of file misc.c.

References NSERROR_BAD_PARAMETER, NSERROR_NOMEM, NSERROR_OK, and path().

Here is the call graph for this function:

◆ amiga_mkdir_all()

static nserror amiga_mkdir_all ( const char *  fname)
static

Ensure that all directory elements needed to store a filename exist.

Parameters
fnameThe filename to ensure the path to exists.
Returns
NSERROR_OK on success or error code on failure.

Definition at line 397 of file misc.c.

References NSERROR_NOT_DIRECTORY, NSERROR_NOT_FOUND, NSERROR_OK, and nsmkdir.

◆ amiga_nsurl_to_path()

static nserror amiga_nsurl_to_path ( struct nsurl url,
char **  path_out 
)
static

Create a path from a nsurl using amiga file handling.

Parameters
[in]urlThe url to encode.
[out]path_outA string containing the result path which should be freed by the caller.
Returns
NSERROR_OK and the path is written to path or error code on faliure.

Definition at line 138 of file misc.c.

References NSERROR_BAD_PARAMETER, NSERROR_NOMEM, NSERROR_OK, nsurl_get_component(), NSURL_PATH, NSURL_SCHEME, path(), and url_unescape().

Here is the call graph for this function:

◆ amiga_path_to_nsurl()

static nserror amiga_path_to_nsurl ( const char *  path,
struct nsurl **  url_out 
)
static

Create a nsurl from a path using amiga file handling.

Perform the necessary operations on a path to generate a nsurl.

Parameters
[in]pathThe path to convert.
[out]url_outpointer to recive the nsurl, The returned url must be unreferenced by the caller.
Returns
NSERROR_OK and the url is placed in url or error code on faliure.

Definition at line 210 of file misc.c.

References DevNameFromLock, DN_FULLPATH, NSERROR_NOMEM, nsurl_create(), path(), and SLEN.

Here is the call graph for this function:

◆ amiga_vmkpath()

static nserror amiga_vmkpath ( char **  str,
size_t *  size,
size_t  nelm,
va_list  ap 
)
static

Generate a posix path from one or more component elemnts.

If a string is allocated it must be freed by the caller.

Parameters
[in,out]strpointer to string pointer if this is NULL enough storage will be allocated for the complete path.
[in,out]sizeThe size of the space available if str not NULL on input and if not NULL set to the total output length on output.
[in]nelmThe number of elements.
[in]apThe elements of the path as string pointers.
Returns
NSERROR_OK and the complete path is written to str or error code on faliure.

Definition at line 286 of file misc.c.

References NSERROR_BAD_PARAMETER, NSERROR_NOMEM, NSERROR_NOSPACE, and NSERROR_OK.

◆ amiga_warn_user()

nserror amiga_warn_user ( const char *  warning,
const char *  detail 
)

Warn the user of an event.

Parameters
[in]warningA warning looked up in the message translation table
[in]detailAdditional text to be displayed or NULL.
Returns
NSERROR_OK on success or error code if there was a faliure displaying the message to the user.

Definition at line 79 of file misc.c.

References ami_misc_req(), ami_utf8_easy(), ASPrintf(), messages_get(), NSERROR_OK, and TDRIMAGE_WARNING.

Referenced by ami_bitmap_get_generic(), ami_cw_mouse_pos(), ami_cw_redraw(), ami_cw_redraw_rect(), ami_cw_window_size(), ami_do_redraw(), ami_do_redraw_limits(), ami_file_open(), ami_font_open(), ami_gui_event(), ami_gui_new_blank_tab(), ami_gui_scroll_internal(), ami_handle_applib(), ami_handle_appmsg(), ami_mouse_to_ns_coords(), ami_ns_rect_to_ibox(), ami_plot_ra_alloc(), ami_print(), ami_refresh_window(), ami_switch_tab(), ami_text_box_at_point(), ami_theme_init(), ami_throbber_update(), gui_download_window_done(), gui_download_window_error(), gui_init2(), gui_window_create(), gui_window_get_dimensions(), gui_window_place_caret(), gui_window_set_icon(), gui_window_set_scroll(), gui_window_stop_throbber(), gui_window_update_extent(), HOOKF(), and RXHOOKF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ amiga_warn_user_multi()

int32 amiga_warn_user_multi ( const char *  body,
const char *  opt1,
const char *  opt2,
struct Window *  win 
)

Definition at line 93 of file misc.c.

References ami_utf8_easy(), ASPrintf(), messages_get(), and TDRIMAGE_WARNING.

Referenced by ami_download_check_overwrite(), and ami_gui_close_tabs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ translate_escape_chars()

char * translate_escape_chars ( const char *  s)

returns a string with escape chars translated and string converted to local charset (based on remove_underscores from utils.c)

Definition at line 246 of file misc.c.

References ami_utf8_easy().

Referenced by gui_window_create().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ amiga_file_table

struct gui_file_table* amiga_file_table = &file_table

Definition at line 463 of file misc.c.

Referenced by main().

◆ file_table

struct gui_file_table file_table
static
Initial value:
= {
.mkpath = amiga_vmkpath,
.basename = amiga_basename,
.nsurl_to_path = amiga_nsurl_to_path,
.path_to_nsurl = amiga_path_to_nsurl,
.mkdir_all = amiga_mkdir_all,
}
static nserror amiga_mkdir_all(const char *fname)
Ensure that all directory elements needed to store a filename exist.
Definition: misc.c:397
static nserror amiga_vmkpath(char **str, size_t *size, size_t nelm, va_list ap)
Generate a posix path from one or more component elemnts.
Definition: misc.c:286
static nserror amiga_path_to_nsurl(const char *path, struct nsurl **url_out)
Create a nsurl from a path using amiga file handling.
Definition: misc.c:210
static nserror amiga_nsurl_to_path(struct nsurl *url, char **path_out)
Create a path from a nsurl using amiga file handling.
Definition: misc.c:138
static nserror amiga_basename(const char *path, char **str, size_t *size)
Get the basename of a file using posix path handling.
Definition: misc.c:365

Definition at line 455 of file misc.c.