LgiCommon.h File Reference

Common LGI include Copyright (C) 2000-2004, Matthew Allen. More...

#include "GArray.h"
#include "LgiClass.h"

Go to the source code of this file.

Typedefs

typedef bool(* RecursiveFileSearch_Callback )(void *UserData, char *Path, class GDirectory *Dir)
 Returns 0 to end search.

Functions

LgiFunc int LgiBufConvertCp (void *Out, char *OutCp, int OutLen, void *&In, char *InCp, int &InLen)
 Converts a buffer of text to a different charset.
LgiFunc void * LgiNewConvertCp (char *OutCp, void *In, char *InCp, int InLen=-1)
 Converts a string to a new charset.
LgiFunc char16LgiNewUtf8To16 (char *In, int InLen=-1)
 Converts a utf-8 string into a wide character string.
LgiFunc char * LgiNewUtf16To8 (char16 *In, int InLen=-1)
 Converts a wide character string into a utf-8 string.
LgiFunc bool LgiIsCpImplemented (char *Cp)
 Return true if Lgi support the charset.
LgiFunc char * LgiAnsiToLgiCp (int AnsiCodePage=-1)
 Converts the ANSI code page to a charset name.
LgiFunc int LgiByteLen (void *Str, char *Cp)
 Calculate the byte length of a string.
LgiFunc int LgiCharLen (void *Str, char *Cp, int Bytes=-1)
 Calculate the number of characters in a string.
LgiFunc char * LgiSeekUtf8 (char *Ptr, int D, char *Start=0)
 Move a pointer along a utf-8 string by characters.
LgiFunc bool LgiIsUtf8 (char *s, int len=-1)
 Return true if the string is valid utf-8.
LgiFunc char * LgiToNativeCp (char *In, int InLen=-1)
 Converts a string to the native 8bit charset of the OS from utf-8.
LgiFunc char * LgiFromNativeCp (char *In, int InLen=-1)
 Converts a string from the native 8bit charset of the OS to utf-8.
LgiFunc char * LgiTokStr (char *&s)
 Returns the next token in a string, leaving the argument pointing to the end of the token.
LgiFunc void LgiFormatSize (char *Str, uint64 Size)
 Formats a data size into appropriate units.
LgiFunc char * LgiDecodeUri (char *uri, int len=-1)
LgiFunc char * LgiEncodeUri (char *uri, int len=-1)
LgiFunc bool LgiGetExeFile (char *Dst, int DstSize)
 Gets the path and file name of the currently running executable.
LgiFunc bool LgiGetExePath (char *Dst, int DstSize)
 Gets the path of the currently running executable.
LgiFunc bool LgiGetTempPath (char *Dst, int DstSize)
 Gets the path of the temporary file directory.
LgiFunc bool LgiGetSystemPath (LgiSystemPath Which, char *Dst, int DstSize)
 Returns the system path specified.
LgiFunc char * LgiFindFile (char *Name)
 Finds a file in the applications directory or nearby.
LgiFunc bool LgiRecursiveFileSearch (char *Root, GArray< char * > *Ext=0, GArray< char * > *Files=0, uint64 *Size=0, uint64 *Count=0, RecursiveFileSearch_Callback Callback=0, void *UserData=0)
 Recursively search for files.
LgiFunc struct GLanguage * LgiGetLanguageId ()
 Gets the currently selected language.
LgiFunc char * LgiLoadString (int Res, char *Default=0)
 Loads a string from the resource file.
LgiFunc int LgiGetOs (GArray< int > *Ver=0)
 Returns the operating system that Lgi is running on.
LgiFunc char * LgiGetOsName ()
 Gets the current operation systems name.
LgiFunc bool LgiExecute (char *File, char *Arguments="", char *Dir=0)
 Opens a file or directory.
LgiFunc void LgiRandomize (uint Seed)
 Initializes the random number generator.
LgiFunc uint LgiRand (uint Max=0)
 Returns a random number between 0 and Max-1.
LgiFunc bool LgiPlaySound (char *FileName, int Flags)
 Plays a sound.
LgiFunc bool LgiGetMimeTypeExtensions (char *Mime, GArray< char * > &Ext)
 Returns the mime type of the file.
LgiFunc bool LgiGetFileMimeType (char *File, char *MimeType, int BufLen)
 Returns the mime type of the file.
LgiFunc bool LgiGetAppForMimeType (char *Mime, char *AppPath, int BufSize)
 Returns the application associated with the mime type.
LgiFunc bool LgiGetAppsForMimeType (char *Mime, GArray< GAppInfo * > &Apps, int Limit=-1)
 Returns the all applications that can open a given mime type.
LgiFunc uint64 LgiCurrentTime ()
 Gets the current clock in milli-seconds.
LgiFunc int LgiIsReleaseBuild ()
 Returns true if the build is for release.


Detailed Description

Common LGI include Copyright (C) 2000-2004, Matthew Allen.

Author:
Matthew Allen
Date:
27/3/2000

Function Documentation

LgiFunc char* LgiDecodeUri ( char *  uri,
int  len = -1 
)

Converts a string from URI encoding (ala 20 -> ' ')

Returns:
a dynamically allocated string or NULL on error
Parameters:
uri  The URI
len  The length or -1 if NULL terminated

References GStringPipe::NewStr(), and GStringPipe::Push().

LgiFunc char* LgiEncodeUri ( char *  uri,
int  len = -1 
)

Converts a string to URI encoding (ala 20 -> ' ')

Returns:
a dynamically allocated string or NULL on error
Parameters:
uri  The URI
len  The length or -1 if NULL terminated

References GStringPipe::NewStr(), and GStringPipe::Push().

LgiFunc bool LgiExecute ( char *  File,
char *  Arguments = "",
char *  Dir = 0 
)

Opens a file or directory.

If the input is an executable then it is run. If the input file is a document then an appropriate application is found to open the file and the file is passed to that application. If the input is a directory then the OS's file manager is openned to browse the directory.

Parameters:
File  The file to open
Arguments  The arguments to pass to the program
Dir  The directory to run in

References GArray< Type >::Length(), and LGI_PATH_SEPARATOR.

LgiFunc void LgiFormatSize ( char *  Str,
uint64  Size 
)

Formats a data size into appropriate units.

Parameters:
Str  Output string
Size  Input size in bytes

LgiFunc bool LgiGetAppForMimeType ( char *  Mime,
char *  AppPath,
int  BufSize 
)

Returns the application associated with the mime type.

Parameters:
Mime  Type of the file to find and app for
AppPath  Path to the executable of the app that can handle the file type.
BufSize  Size of the 'AppPath' buffer

LgiFunc bool LgiGetAppsForMimeType ( char *  Mime,
GArray< GAppInfo * > &  Apps,
int  Limit = -1 
)

Returns the all applications that can open a given mime type.

Parameters:
Mime  The type of files to match apps to.

Two special cases exist:

  • application/email gets the default email client
  • application/browser get the default web browser
Apps  The applications that can handle the
Limit  Limit the length of the results, i.e. stop looking after 'Limit' matches. -1 means return all matches.

References LgiApp.

LgiFunc bool LgiGetFileMimeType ( char *  File,
char *  MimeType,
int  BufLen 
)

Returns the mime type of the file.

Parameters:
File  File to file type of
MimeType  Pointer to buffer to receive mime-type
BufLen  Buffer length

References LgiApp.

LgiFunc bool LgiGetMimeTypeExtensions ( char *  Mime,
GArray< char * > &  Ext 
)

Returns the mime type of the file.

Parameters:
Mime  The returned mime type
Ext  The extensions

References GArray< Type >::Length().

LgiFunc int LgiGetOs ( GArray< int > *  Ver  ) 

Returns the operating system that Lgi is running on.

Gets the current operating system and optionally it's version.

Returns:
One of the defines starting with LGI_OS_UNKNOWN in LgiDefs.h
See also:
Returns one of the defines starting with LGI_OS_UNKNOWN in LgiDefs.h
Parameters:
Ver  Returns the version of the OS or NULL if you don't care

References GArray< Type >::Add(), GArray< Type >::Length(), LGI_OS_BEOS, LGI_OS_LINUX, LGI_OS_MAC_OS_X, LGI_OS_UNKNOWN, LGI_OS_WIN9X, and LGI_OS_WINNT.

LgiFunc bool LgiGetSystemPath ( LgiSystemPath  Which,
char *  Dst,
int  DstSize 
)

Returns the system path specified.

Parameters:
Which  Which path to retreive
Dst  The buffer to receive the path into
DstSize  The size of the receive buffer in bytes

References DIR_CHAR, LGI_OS_WIN9X, LgiApp, LSP_APP_INSTALL, LSP_APP_ROOT, LSP_COMMON_APP_DATA, LSP_DESKTOP, LSP_EXE, LSP_HOME, LSP_LOCAL_APP_DATA, LSP_OS, LSP_OS_LIB, LSP_TEMP, LSP_TRASH, LSP_USER_APP_DATA, LSP_USER_DOCUMENTS, LSP_USER_MUSIC, LSP_USER_VIDEO, GStringPipe::NewStr(), and GProcess::Run().

LgiFunc void* LgiNewConvertCp ( char *  OutCp,
void *  In,
char *  InCp,
int  InLen = -1 
)

Converts a string to a new charset.

Returns:
A dynamically allocate, null terminated string in the new charset
Parameters:
OutCp  Output charset
In  Input buffer
InCp  The input data's charset
InLen  Bytes of valid data in the input

References GCharset::GetIconvName(), GBytePipe::GetSize(), GBytePipe::New(), GCharset::Type, and GBytePipe::Write().

LgiFunc char* LgiNewUtf16To8 ( char16 In,
int  InLen = -1 
)

Converts a wide character string into a utf-8 string.

Parameters:
In  Input string
InLen  Number of bytes in the input or -1 for NULL terminated

LgiFunc bool LgiPlaySound ( char *  FileName,
int  Flags 
)

Plays a sound.

Parameters:
FileName  File name of the sound to play
Flags  0 or SND_ASYNC. If 0 the function blocks till the sound finishes.

LgiFunc bool LgiRecursiveFileSearch ( char *  Root,
GArray< char * > *  Ext = 0,
GArray< char * > *  Files = 0,
uint64 Size = 0,
uint64 Count = 0,
RecursiveFileSearch_Callback  Callback = 0,
void *  UserData = 0 
)

Recursively search for files.

Returns:
Non zero if something was found
Parameters:
Root  Start search in this dir
Ext  Extensions to match
Files  [optional] Output filenames
Size  [optional] Output total size
Count  [optional] File count
Callback  [optional] Callback for match
UserData  [options] Callback user data

References GArray< Type >::Add(), DIR_CHAR, GDirectory::First(), GDirectory::GetSize(), GDirectory::IsDir(), GArray< Type >::Length(), GDirectory::Next(), and GDirectory::Path().

LgiFunc char* LgiSeekUtf8 ( char *  Ptr,
int  D,
char *  Start = 0 
)

Move a pointer along a utf-8 string by characters.

Parameters:
Ptr  Pointer to the current character
D  The number of characters to move forward or back
Start  The start of the memory buffer if you known

References LgiNextUtf8().


Generated on Wed Dec 1 15:41:01 2010 for Lgi by  doxygen 1.5.7.1