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

LgiCommon.h File Reference

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

#include "GArray.h"

Go to the source code of this file.

Typedefs

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

Enumerations

enum  LgiSystemPath {
  LSP_OS, LSP_OS_LIB, LSP_TEMP, LSP_APP_DATA,
  LSP_LOCAL_APP_DATA, LSP_DESKTOP, LSP_HOME, LSP_EXE,
  LSP_TRASH
}
 Types of system paths available for querying. More...

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 char * LgiDetectCharset (char *Utf8, int Len=-1, List< char > *Prefs=0)
 Returns the charset that best fits the input data.
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, List< char > *Ext=0, List< char > *Files=0, uint64 *Size=0, uint64 *Count=0, RecursiveFileSearch_Callback Callback=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 (int *Ver=0, int *Rev=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=".")
 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 LgiGetFileMimeType (char *File, char *Mime, int MimeBufSize)
 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 void LgiTrace (char *Format,...)
 Writes a debug statement to a file in the executables directory.
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

Enumeration Type Documentation

enum LgiSystemPath
 

Types of system paths available for querying.

See also:
LgiGetSystemPath
Enumeration values:
LSP_OS  "windows" | "/boot"
LSP_OS_LIB  "system[32]" | "/usr/lib"
LSP_TEMP  "windows/temp" | "/tmp"
LSP_APP_DATA  "application data" | "/usr"
LSP_LOCAL_APP_DATA  "application data" | "/usr/local"
LSP_DESKTOP  Desktop dir.
LSP_HOME  Home dir.
LSP_EXE  The running application's path.
LSP_TRASH  The system trash folder.


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

LgiFunc char* LgiDetectCharset char *  Utf8,
int  Len = -1,
List< char > *  Prefs = 0
 

Returns the charset that best fits the input data.

Parameters:
Utf8  The input text
Len  The byte length of the input text
Prefs  An optional list of prefered charsets to look through first

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

LgiFunc bool LgiExecute char *  File,
char *  Arguments = "",
char *  Dir = "."
 

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

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
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.

LgiFunc bool LgiGetFileMimeType char *  File,
char *  Mime,
int  MimeBufSize
 

Returns the mime type of the file.

Parameters:
File  File to file type of
Mime  The returned mime type
MimeBufSize  The size of the buffer pointed to by 'Mime'

LgiFunc int LgiGetOs int *  Ver,
int *  Rev
 

Returns the operating system that Lgi is running on.

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

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

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

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,
List< char > *  Ext = 0,
List< char > *  Files = 0,
uint64 Size = 0,
uint64 Count = 0,
RecursiveFileSearch_Callback  Callback = 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

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


Generated on Wed Oct 26 14:46:54 2005 for Lgi by  doxygen 1.4.1