Far Standard Functions

Far Manager

Far Standard Functions

The FarStandardFunctions structure contains addresses to standard FAR functions. Using these functions allows the plugin to use standard operations and reduce the size of the plugin's DLL.
struct FarStandardFunctions
{
  int StructSize;

  FARSTDATOI                 atoi;
  FARSTDATOI64               atoi64;
  FARSTDITOA                 itoa;
  FARSTDITOA64               itoa64;
  FARSTDSPRINTF              sprintf;
  FARSTDSSCANF               sscanf;
  FARSTDQSORT                qsort;
  FARSTDBSEARCH              bsearch;
  FARSTDQSORT                qsortex;
  FARSTDSNPRINTF             snprintf;

  DWORD_PTR                  Reserved[8];

  FARSTDLOCALISLOWER         LIsLower;
  FARSTDLOCALISUPPER         LIsUpper;
  FARSTDLOCALISALPHA         LIsAlpha;
  FARSTDLOCALISALPHANUM      LIsAlphanum;
  FARSTDLOCALUPPER           LUpper;
  FARSTDLOCALLOWER           LLower;
  FARSTDLOCALUPPERBUF        LUpperBuf;
  FARSTDLOCALLOWERBUF        LLowerBuf;
  FARSTDLOCALSTRUPR          LStrupr;
  FARSTDLOCALSTRLWR          LStrlwr;
  FARSTDLOCALSTRICMP         LStricmp;
  FARSTDLOCALSTRNICMP        LStrnicmp;

  FARSTDUNQUOTE              Unquote;
  FARSTDEXPANDENVIRONMENTSTR ExpandEnvironmentStr;
  FARSTDLTRIM                LTrim;
  FARSTDRTRIM                RTrim;
  FARSTDTRIM                 Trim;
  FARSTDTRUNCSTR             TruncStr;
  FARSTDTRUNCPATHSTR         TruncPathStr;
  FARSTDQUOTESPACEONLY       QuoteSpaceOnly;
  FARSTDPOINTTONAME          PointToName;
  FARSTDGETPATHROOT          GetPathRoot;
  FARSTDADDENDSLASH          AddEndSlash;
  FARSTDCOPYTOCLIPBOARD      CopyToClipboard;
  FARSTDPASTEFROMCLIPBOARD   PasteFromClipboard;
  FARSTDKEYTOKEYNAME         FarKeyToName;
  FARSTDKEYNAMETOKEY         FarNameToKey;
  FARSTDINPUTRECORDTOKEY     FarInputRecordToKey;
  FARSTDXLAT                 XLat;
  FARSTDGETFILEOWNER         GetFileOwner;
  FARSTDGETNUMBEROFLINKS     GetNumberOfLinks;
  FARSTDRECURSIVESEARCH      FarRecurseSearch;
  FARSTDMKTEMP               MkTemp;
  FARSTDDELETEBUFFER         DeleteBuffer;
  FARSTDPROCESSNAME          ProcessName;
  FARSTDMKLINK               MkLink;
  FARCONVERTNAMETOREAL       ConvertNameToReal;
  FARGETREPARSEPOINTINFO     GetReparsePointInfo;
};

Members

FunctionDescription
StructSize Structure size. If the structure will change in the future, this field will allow to determine it.
atoi converts a string to a 32-bit integer.
atoi64 converts a string to a 64-bit integer (__int64).
itoa converts a 32-bit integer value into a string.
itoa64 converts a 64-bit integer (__int64) value into a string.
sprintf allows to write formatted output to a string.
sscanf allows to read formatted data from a string.
qsort allows to sort an array of any type of data using the QuickSort algorithm.
bsearch allows to perform a binary search of a sorted array.
qsortex allows to sort an array of any type of data using the QuickSort algorithm.
snprintf allows to write formatted output to a string.
LIsLower tests whether the given character is in lower case.
LIsUpper tests whether the given character is in upper case.
LIsAlpha tests whether the given character is a letter.
LIsAlphanum tests whether the given character is a number or a letter.
LUpper converts a character to upper case.
LLower converts a character to lower case.
LUpperBuf converts an array of characters, including null ones, to upper case.
LLowerBuf converts an array of characters, including null ones, to lower case.
LStrupr converts a null-terminated string to upper case.
LStrlwr converts a null-terminated string to lower case.
LStricmp compares two strings without case sensitivity.
LStrnicmp compares portions of two strings without case sensitivity.
Unquote removes all quotes from a null-terminated string.
ExpandEnvironmentStr used to expand environment variables in a string to their values.
LTrim removes leading whitespace from a string.
RTrim removes trailing whitespace from a string.
Trim removes all leading and trailing whitespace from a string.
TruncStr truncates a given string to the specified length and, if needed, inserts in its beginning an ellipsis instead of the truncated part.
TruncPathStr truncates a given path to specified length and, if needed, inserts an ellipsis to indicate the place of truncation.
QuoteSpaceOnly quotes the input string if it contains at least one space inside.
PointToName used to get the file name from a given file path.
GetPathRoot used to get the root directory from a given file path.
AddEndSlash used to add a trailing backslash or a slash to a path.
CopyToClipboard copies a text string to the Windows clipboard.
PasteFromClipboard used to get data from the Windows clipboard.
FarKeyToName used to convert an internal FAR key code to a string.
FarNameToKey used to convert a literal key name to an internal FAR key code.
FarInputRecordToKey used to convert a key code from an INPUT_RECORD structure to an internal FAR key code.
XLat used to transliterate a string portion from one character set (for example Russian) to another character set (for example Latin).
GetFileOwner used to determine the owner of the given file.
GetNumberOfLinks returns the number of hard links to the specified file.
FarRecursiveSearch used to find a file in a directory tree with name matching the given mask.
MkTemp used to create a temporary file name with the path based on a specified template.
DeleteBuffer used to free an allocated buffer returned by the PasteFromClipboard function.
ProcessName allows to perform various actions on a file name: compare with a mask, with a list of masks or to generate new file name using a mask.
MkLink supports creating hard and symbolic links and mounting local drives to the file system.
ConvertNameToReal converts a relative name of a file object to its full pathname and expands symbolic links (reparse points).
GetReparsePointInfo allows to determine the target (path to the target drive and directory) of a symbolic link (reparse point).

Remarks

Before you can start using standard functions you have to store structure contents locally:

static struct PluginStartupInfo Info;
static struct FarStandardFunctions FSF;

void  _export SetStartupInfo(struct PluginStartupInfo *psInfo)
{
    Info=*psInfo;
    FSF=*psInfo->FSF;
    Info.FSF=&FSF; // now Info.FSF will point to the correct local address
    ...
} 
See also: