Main Page | Class List | File List | Class Members | File Members | Related Pages

platform.h File Reference

Platform specific routines. More...

#include <sys/stat.h>

Go to the source code of this file.

Classes

struct  _sproc_data

Defines

#define PARENT_FUNC(func)   int func (SubprocessData *subproc, void *udata)
#define CHILD_FUNC(func)   int func (SubprocessData *subproc, void *udata)
#define SUBPROCESS(func)   int func (void *param)
#define __PRETTY_FUNCTION__   ""
#define S_ISDIR(m)   (((m) & S_IFMT) == S_IFDIR)
#define S_ISFIFO(m)   (((m) & S_IFMT) == S_IFIFO)
#define S_ISCHR(m)   (((m) & S_IFMT) == S_IFCHR)
#define S_ISBLK(m)   (((m) & S_IFMT) == S_IFBLK)
#define S_ISREG(m)   (((m) & S_IFMT) == S_IFREG)

Typedefs

typedef int(* ParentFunc )(struct _sproc_data *sdata, void *udata)
typedef int(* ChildFunc )(struct _sproc_data *sdata, void *udata)
typedef _sproc_data SubprocessData

Functions

EXTERN_C_BEGIN LIBGIFT_EXPORT
char * 
platform_data_dir (void)
LIBGIFT_EXPORT char * platform_plugin_dir (void)
LIBGIFT_EXPORT char * platform_home_dir (void)
LIBGIFT_EXPORT char * platform_local_dir (void)
LIBGIFT_EXPORT BOOL platform_init (const char *home_dir, const char *local_dir, const char *data_dir, const char *plugin_dir)
LIBGIFT_EXPORT void platform_cleanup (void)
LIBGIFT_EXPORT int platform_gettimeofday (struct timeval *tv, void *unused)
LIBGIFT_EXPORT int platform_child (ChildFunc cfunc, ParentFunc pfunc, void *udata)
LIBGIFT_EXPORT int platform_child_sendmsg (SubprocessData *sdata, char *msg, size_t len)
LIBGIFT_EXPORT int platform_child_recvmsg (SubprocessData *sdata)
LIBGIFT_EXPORT char * platform_version (void)
LIBGIFT_EXPORT unsigned long platform_errno (void)
LIBGIFT_EXPORT char * platform_error (void)
LIBGIFT_EXPORT unsigned long platform_net_errno (void)
LIBGIFT_EXPORT char * platform_net_error (void)


Detailed Description

Platform specific routines.

Contains routines that are specific to a platform (*nix, Windows, etc). You should be aware that you are expected to call platform_init before using any routines held within libgiFT.


Typedef Documentation

typedef struct _sproc_data SubprocessData
 

Structure containing data passed between parent and child processes.


Function Documentation

LIBGIFT_EXPORT int platform_child ChildFunc  cfunc,
ParentFunc  pfunc,
void *  udata
 

Spawn's a child process. In *nix, fork is used, in Windows, a thread is used.

Parameters:
cfunc Pointer to child function.
pfunc Pointer to parent function.
udata 
Returns:
Boolean success or failure.

LIBGIFT_EXPORT int platform_child_recvmsg SubprocessData sdata  ) 
 

Receive a message from a child process in a parent process. The data is returned in sdata->data, and the length in sdata->len.

Parameters:
sdata SubprocessData of the child process.
Returns:
See recv(2)

LIBGIFT_EXPORT int platform_child_sendmsg SubprocessData sdata,
char *  msg,
size_t  len
 

Send a message to a parent process from a child process.

Parameters:
sdata SubprocessData of the child context.
msg Message to send.
len Size of the message to send.
Returns:
See send(2).

LIBGIFT_EXPORT void platform_cleanup void   ) 
 

Platform specific cleanup. Frees any memory that was allocated by platform_init.

Please note that platform_cleanup should be called on program termination.

EXTERN_C_BEGIN LIBGIFT_EXPORT char* platform_data_dir void   ) 
 

Contains installed data, such as mime.types.

UNIX: this is defined by configure as DATA_DIR Windows: The plugin_dir + /data

LIBGIFT_EXPORT unsigned long platform_errno void   ) 
 

Access the error code of the last system error. This uses GetLastError() on Windows and errno for everything else.

Note:
We should not be using an unsigned long return value here and I cannot think why we are (but there must be a reason, right?). rasa, please check this and get back to me.

LIBGIFT_EXPORT char* platform_error void   ) 
 

Access the error message of the last system error. On Windows , FormatMessage() and GetLastError() will be used. Otherwise the standard strerror call will be used.

Note:
You may want to consider platform_net_error.

LIBGIFT_EXPORT int platform_gettimeofday struct timeval *  tv,
void *  unused
 

Emulates *nix's gettimeofday function.

Parameters:
tv Time structure.
unused Not used, doesn't matter what you pass.

LIBGIFT_EXPORT char* platform_home_dir void   ) 
 

Contains the user's 'home' directory.

UNIX: assigned to $HOME or /home/$USER Windows: Searches for the first valid directory in: 1. HKEY_CURRENT_USER registry key 2. HOME% directory, if HOME% is defined in the environment. 3. Directory where giFT started from. 4. Current directory.

LIBGIFT_EXPORT BOOL platform_init const char *  home_dir,
const char *  local_dir,
const char *  data_dir,
const char *  plugin_dir
 

Platform specific initialization.

Must be called before calling any other functions in this library. See libgift_init for a more appropriate and complete wrapper.

Parameters:
home_dir Optional home_dir hint.
local_dir Optional local_dir hint.
data_dir Optional data_dir hint.
plugin_dir Optional plugin_dir hint.
Returns:
Boolean success or failure. Failure to initialize the platform will result in several systems being unusable. You should not proceed with execution.

LIBGIFT_EXPORT char* platform_local_dir void   ) 
 

Contains all user preferences (.conf files).

UNIX: assigned to $HOME/.giFT Windows: Searches for the first valid directory in: 1. home_dir 2. home_dir + /.giFT

LIBGIFT_EXPORT unsigned long platform_net_errno void   ) 
 

Access the error code of the last socket error. This function is implemented only to work around Windows non-conformity.

LIBGIFT_EXPORT char* platform_net_error void   ) 
 

Similar to platform_error, but will use platform_net_errno to retrieve the error number.

LIBGIFT_EXPORT char* platform_plugin_dir void   ) 
 

Contains all dynamically loaded plugins that this giFT installation has available.

UNIX: this is defined by configure as PLUGIN_DIR Windows: Searches for the first valid directory in: 1. HKEY_LOCAL_MACHINE registry key 2. Directory where giFT started from 3. Current directory

LIBGIFT_EXPORT char* platform_version void   ) 
 

Access an HTTP_USER_AGENT string describing the giFT version and OS version. Uhm, this really wasn't very well throught out and you should definitely avoid using this function.

Returns:
Pointer to local memory, I believe. Check for yourself if you really think you should be using this.


Generated on Sun Aug 22 08:07:11 2004 by doxygen 1.3.7