geany  1.38
About: Geany is a text editor (using GTK2) with basic features of an integrated development environment (syntax highlighting, code folding, symbol name auto-completion, ...). F: office T: editor programming GTK+ IDE
  Fossies Dox: geany-1.38.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

routines.c File Reference
#include "general.h"
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <limits.h>
#include "debug.h"
#include "routines.h"
#include "routines_p.h"
#include <errno.h>
#include "vstring.h"
Include dependency graph for routines.c:

Go to the source code of this file.

Macros

#define MB_LEN_MAX   6
 
#define TMPDIR   "/tmp"
 
#define S_ISLNK(mode)   false /* assume no soft links */
 
#define S_ISDIR(mode)   false /* assume no soft links */
 
#define S_IFMT   0
 
#define S_IXUSR   0
 
#define S_IXGRP   0
 
#define S_IXOTH   0
 
#define S_IRUSR   0400
 
#define S_IWUSR   0200
 
#define S_ISUID   0
 
#define S_ISGID   0
 
#define PATH_MAX   256
 

Functions

static bool isPathSeparator (const int c)
 
static char * strSeparator (const char *s)
 
static char * strRSeparator (const char *s)
 
static void canonicalizePath (char *const path)
 
void freeRoutineResources (void)
 
void setExecutableName (const char *const path)
 
const char * getExecutableName (void)
 
const char * getExecutablePath (void)
 
static bool fnmChEq (int c1, int c2)
 
void * eMalloc (const size_t size)
 
void * eCalloc (const size_t count, const size_t size)
 
void * eRealloc (void *const ptr, const size_t size)
 
void eFree (void *const ptr)
 
void eFreeNoNullCheck (void *const ptr)
 
void eFreeIndirect (void **ptr)
 
int struppercmp (const char *s1, const char *s2)
 
int strnuppercmp (const char *s1, const char *s2, size_t n)
 
char * strstr (const char *str, const char *substr)
 
char * strrstr (const char *str, const char *substr)
 
char * eStrdup (const char *str)
 
char * eStrndup (const char *str, size_t len)
 
void toLowerString (char *str)
 
void toUpperString (char *str)
 
char * newLowerString (const char *str)
 
char * newUpperString (const char *str)
 
bool strToULong (const char *const str, int base, unsigned long *value)
 
bool strToLong (const char *const str, int base, long *value)
 
bool strToUInt (const char *const str, int base, unsigned int *value)
 
bool strToInt (const char *const str, int base, int *value)
 
void setCurrentDirectory (void)
 
fileStatuseStat (const char *const fileName)
 
void eStatFree (fileStatus *status)
 
bool doesFileExist (const char *const fileName)
 
bool doesExecutableExist (const char *const fileName)
 
bool isRecursiveLink (const char *const dirName)
 
bool isSameFile (const char *const name1, const char *const name2)
 
const char * baseFilename (const char *const filePath)
 
const char * fileExtension (const char *const fileName)
 
char * baseFilenameSansExtensionNew (const char *const fileName, const char *const templateExt)
 
bool isAbsolutePath (const char *const path)
 
char * combinePathAndFile (const char *const path, const char *const file)
 
static char * concat (const char *s1, const char *s2, const char *s3)
 
char * absoluteFilename (const char *file)
 
char * absoluteDirname (char *file)
 
char * relativeFilename (const char *file, const char *dir)
 
MIOtempFile (const char *const mode, char **const pName)
 

Variables

char * CurrentDirectory
 
static const char * ExecutableProgram
 
static const char * ExecutableName
 

Macro Definition Documentation

◆ MB_LEN_MAX

#define MB_LEN_MAX   6

Definition at line 29 of file routines.c.

◆ PATH_MAX

#define PATH_MAX   256

Definition at line 137 of file routines.c.

◆ S_IFMT

#define S_IFMT   0

Definition at line 94 of file routines.c.

◆ S_IRUSR

#define S_IRUSR   0400

Definition at line 108 of file routines.c.

◆ S_ISDIR

#define S_ISDIR (   mode)    false /* assume no soft links */

Definition at line 89 of file routines.c.

◆ S_ISGID

#define S_ISGID   0

Definition at line 119 of file routines.c.

◆ S_ISLNK

#define S_ISLNK (   mode)    false /* assume no soft links */

Definition at line 81 of file routines.c.

◆ S_ISUID

#define S_ISUID   0

Definition at line 115 of file routines.c.

◆ S_IWUSR

#define S_IWUSR   0200

Definition at line 111 of file routines.c.

◆ S_IXGRP

#define S_IXGRP   0

Definition at line 101 of file routines.c.

◆ S_IXOTH

#define S_IXOTH   0

Definition at line 104 of file routines.c.

◆ S_IXUSR

#define S_IXUSR   0

Definition at line 98 of file routines.c.

◆ TMPDIR

#define TMPDIR   "/tmp"

Definition at line 66 of file routines.c.

Function Documentation

◆ absoluteDirname()

char * absoluteDirname ( char *  file)

Definition at line 833 of file routines.c.

References absoluteFilename(), CurrentDirectory, eStrdup(), NULL, save, and strRSeparator().

Referenced by openTagFile().

◆ absoluteFilename()

◆ baseFilename()

◆ baseFilenameSansExtensionNew()

char * baseFilenameSansExtensionNew ( const char *const  fileName,
const char *const  templateExt 
)

Definition at line 666 of file routines.c.

References baseFilename(), eStrndup(), and NULL.

Referenced by getFileLanguageForRequestInternal().

◆ canonicalizePath()

static void canonicalizePath ( char *const  path)
static

Definition at line 572 of file routines.c.

References isPathSeparator(), and OUTPUT_PATH_SEPARATOR.

Referenced by absoluteFilename(), isSameFile(), and setCurrentDirectory().

◆ combinePathAndFile()

char * combinePathAndFile ( const char *const  path,
const char *const  file 
)

◆ concat()

static char * concat ( const char *  s1,
const char *  s2,
const char *  s3 
)
static

Definition at line 736 of file routines.c.

References xMalloc.

Referenced by absoluteFilename().

◆ doesExecutableExist()

bool doesExecutableExist ( const char *const  fileName)

Definition at line 501 of file routines.c.

References eStat(), fileStatus::exists, and fileStatus::isExecutable.

◆ doesFileExist()

bool doesFileExist ( const char *const  fileName)

◆ eCalloc()

void * eCalloc ( const size_t  count,
const size_t  size 
)

Definition at line 228 of file routines.c.

References count, error(), FATAL, and NULL.

Referenced by createToken().

◆ eFree()

void eFree ( void *const  ptr)

Definition at line 252 of file routines.c.

References Assert, NULL, and ptr.

Referenced by absoluteFilename(), addLanguageMap(), addTagRegexInternal(), addTagRegexOption(), ancestorClear(), argDelete(), argForth(), cArgDelete(), cArgForth(), clearParserFields(), closeTagFile(), colprintHeaderColumnDelete(), colprintTableDelete(), common_flag_field_long(), compileRegex(), copyBytes(), defineField(), defineScopeSeparator(), deleteChar(), deletePattern(), deletePoolToken(), deleteStatement(), deleteTable(), deleteTableEntry(), deleteTagEnry(), deleteToken(), eFreeIndirect(), endEtagsFile(), entry_destroy(), eStatFree(), expandOnSearchPathList(), fieldDefinitionDestroy(), fieldPatternDelete(), fileNameMatched(), fillGuestRequest(), finalizeDependencies(), findPascalTags(), findPythonTags(), flagsEval(), fmtDelete(), freeKdef(), freeKeywordTable(), freeKindControlBlock(), freeLineFposMap(), freeLregexControlBlock(), freeModifier(), freeParserResources(), freeRdef(), freeRoleControlBlock(), freeRoutineResources(), freeSlaveControlBlock(), freeString(), freeTagFileResources(), getFileLanguageForRequestInternal(), getMio(), getSpecLanguageCommon(), guestRequestDelete(), hashTableDelete(), initFieldObjects(), isCtagsLine(), isPodWord(), isRecursiveLink(), isSameFile(), isValidTagAddress(), kindFree(), makeDefineTag(), makePromise(), markTagExtraBitFull(), mio_new_file_full(), mio_new_mio(), mio_unref(), nestingLevelsFree(), nextFileLineSkippingComments(), objPoolDelete(), optlibFreeDep(), parseArglist(), parseFunction(), pickLanguageBySelection(), pre_ptrn_flag_advanceTo_long(), pre_ptrn_flag_mtable_long(), preload(), printLanguageList(), processKindsOption(), processLangDefineKind(), processLangDefineRole(), processLangKindRoleDefinition(), processLanguageDefineOption(), processLanguageMapOption(), processLanguageMultitableExtendingOption(), processLanguagesOption(), processMapOption(), processRolesOption(), ptrArrayDelete(), readIgnoreList(), relativeFilename(), removeLanguageMap(), renderFieldPattern(), replacementTruncate(), scopeSeparatorDelete(), tagFieldDelete(), testEtagsInvocation(), trashBoxDelete(), trashMakeEmpty(), trashPut(), trashTakeBack0(), uwiDeactivate(), vStringDelete(), vStringDeleteUnwrap(), vStringNewOwn(), and xtagDefinitionDestroy().

◆ eFreeIndirect()

void eFreeIndirect ( void **  ptr)

Definition at line 263 of file routines.c.

References eFree(), NULL, and ptr.

Referenced by initFieldObjects(), initXtagObjects(), and langStackInit().

◆ eFreeNoNullCheck()

void eFreeNoNullCheck ( void *const  ptr)

Definition at line 258 of file routines.c.

References ptr.

Referenced by freeRoleControlBlock(), getMio(), mio_new_mio(), and openTagFile().

◆ eMalloc()

void * eMalloc ( const size_t  size)

Definition at line 218 of file routines.c.

References error(), FATAL, and NULL.

Referenced by defineField(), eRealloc(), getMio(), initFieldObjects(), and isPodWord().

◆ eRealloc()

void * eRealloc ( void *const  ptr,
const size_t  size 
)

Definition at line 238 of file routines.c.

References eMalloc(), error(), FATAL, NULL, and ptr.

Referenced by getMio(), mio_new_mio(), nestingLevelsPush(), and openTagFile().

◆ eStat()

◆ eStatFree()

void eStatFree ( fileStatus status)

◆ eStrdup()

◆ eStrndup()

◆ fileExtension()

const char * fileExtension ( const char *const  fileName)

Definition at line 650 of file routines.c.

References baseFilename(), and NULL.

Referenced by getPatternLanguageAndSpec(), and isIncludeFile().

◆ fnmChEq()

static bool fnmChEq ( int  c1,
int  c2 
)
static

Definition at line 205 of file routines.c.

Referenced by relativeFilename().

◆ freeRoutineResources()

void freeRoutineResources ( void  )

Definition at line 180 of file routines.c.

References CurrentDirectory, eFree(), and NULL.

Referenced by ctags_cli_main().

◆ getExecutableName()

const char * getExecutableName ( void  )

◆ getExecutablePath()

const char * getExecutablePath ( void  )

Definition at line 197 of file routines.c.

References ExecutableProgram.

◆ isAbsolutePath()

bool isAbsolutePath ( const char *const  path)

Definition at line 684 of file routines.c.

References error(), FATAL, and isPathSeparator().

Referenced by absoluteFilename(), setInputFileParametersCommon(), and setSourceFileName().

◆ isPathSeparator()

static bool isPathSeparator ( const int  c)
static

◆ isRecursiveLink()

bool isRecursiveLink ( const char *const  dirName)

◆ isSameFile()

bool isSameFile ( const char *const  name1,
const char *const  name2 
)

Definition at line 582 of file routines.c.

References absoluteFilename(), canonicalizePath(), eFree(), and strcasecmp.

Referenced by checkSameFile(), and isRecursiveLink().

◆ newLowerString()

char * newLowerString ( const char *  str)

Definition at line 362 of file routines.c.

References xMalloc.

◆ newUpperString()

char * newUpperString ( const char *  str)

Definition at line 374 of file routines.c.

References xMalloc.

Referenced by fileNameMatched().

◆ relativeFilename()

char * relativeFilename ( const char *  file,
const char *  dir 
)

◆ setCurrentDirectory()

void setCurrentDirectory ( void  )

◆ setExecutableName()

void setExecutableName ( const char *const  path)

Definition at line 186 of file routines.c.

References baseFilename(), ExecutableName, and ExecutableProgram.

Referenced by ctags_cli_main().

◆ strnuppercmp()

int strnuppercmp ( const char *  s1,
const char *  s2,
size_t  n 
)

Definition at line 293 of file routines.c.

◆ strRSeparator()

static char * strRSeparator ( const char *  s)
static

Definition at line 556 of file routines.c.

References NULL, PATH_SEPARATOR, and strSeparator().

Referenced by absoluteDirname(), baseFilename(), and isRecursiveLink().

◆ strrstr()

char * strrstr ( const char *  str,
const char *  substr 
)

Definition at line 316 of file routines.c.

References NULL.

Referenced by determineVimFileType().

◆ strSeparator()

static char * strSeparator ( const char *  s)
static

Definition at line 547 of file routines.c.

References PATH_SEPARATOR.

Referenced by absoluteFilename(), relativeFilename(), and strRSeparator().

◆ strstr()

◆ strToInt()

bool strToInt ( const char *const  str,
int  base,
int *  value 
)

◆ strToLong()

bool strToLong ( const char *const  str,
int  base,
long *  value 
)

Definition at line 403 of file routines.c.

References errno.

Referenced by fmtNew(), processShortOption(), and strToInt().

◆ strToUInt()

bool strToUInt ( const char *const  str,
int  base,
unsigned int *  value 
)

Definition at line 412 of file routines.c.

References strToULong().

Referenced by processPatternLengthLimit().

◆ strToULong()

bool strToULong ( const char *const  str,
int  base,
unsigned long *  value 
)

Definition at line 389 of file routines.c.

References errno.

Referenced by strToUInt().

◆ struppercmp()

int struppercmp ( const char *  s1,
const char *  s2 
)

Definition at line 283 of file routines.c.

Referenced by compareTagsFolded().

◆ tempFile()

MIO * tempFile ( const char *const  mode,
char **const  pName 
)

◆ toLowerString()

void toLowerString ( char *  str)

Definition at line 342 of file routines.c.

Referenced by testEtagsInvocation().

◆ toUpperString()

void toUpperString ( char *  str)

Definition at line 351 of file routines.c.

Variable Documentation

◆ CurrentDirectory

char* CurrentDirectory

◆ ExecutableName

const char* ExecutableName
static

Definition at line 155 of file routines.c.

Referenced by getExecutableName(), and setExecutableName().

◆ ExecutableProgram

const char* ExecutableProgram
static

Definition at line 154 of file routines.c.

Referenced by getExecutablePath(), setExecutableName(), and tempFile().