refactoredCPPNeuronMesher
tinyfiledialogs.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/stat.h>
#include <limits.h>
#include <unistd.h>
#include <dirent.h>
#include <termios.h>
#include <sys/utsname.h>
#include <signal.h>
#include "tinyfiledialogs.h"
Include dependency graph for tinyfiledialogs.c:

Macros

#define TINYFD_SLASH   "/"
 
#define MAX_PATH_OR_CMD   1024 /* _MAX_PATH or MAX_PATH */
 
#define MAX_MULTIPLE_FILES   1024
 
#define LOW_MULTIPLE_FILES   32
 

Functions

static int getenvDISPLAY (void)
 
static char * getCurDir (void)
 
static char * getPathWithoutFinalSlash (char *aoDestination, char const *aSource)
 
static char * getLastName (char *aoDestination, char const *aSource)
 
static void ensureFinalSlash (char *aioString)
 
static void Hex2RGB (char const aHexRGB[8], unsigned char aoResultRGB[3])
 
static void RGB2Hex (unsigned char const aRGB[3], char aoResultHexRGB[8])
 
void tfd_replaceSubStr (char const *aSource, char const *aOldSubStr, char const *aNewSubStr, char *aoDestination)
 
static int filenameValid (char const *aFileNameWithoutPath)
 
static int fileExists (char const *aFilePathAndName)
 
static void wipefile (char const *aFilename)
 
int tfd_quoteDetected (char const *aString)
 
char const * tinyfd_getGlobalChar (char const *aCharVariableName)
 
int tinyfd_getGlobalInt (char const *aIntVariableName)
 
int tinyfd_setGlobalInt (char const *aIntVariableName, int aValue)
 
static char * ensureFilesExist (char *aDestination, char const *aSourcePathsAndNames)
 
int tfd_isDarwin (void)
 
static int dirExists (char const *aDirPath)
 
static int detectPresence (char const *aExecutable)
 
static char * getVersion (char const *aExecutable)
 
static int * getMajorMinorPatch (char const *aExecutable)
 
static int tryCommand (char const *aCommand)
 
static int isTerminalRunning (void)
 
static char * dialogNameOnly (void)
 
int isDialogVersionBetter09b (void)
 
static int whiptailPresentOnly (void)
 
static char * terminalName (void)
 
static char * dialogName (void)
 
static int whiptailPresent (void)
 
static int graphicMode (void)
 
static int ffplayPresent (void)
 
static int pactlPresent (void)
 
static int speakertestPresent (void)
 
static int playPresent (void)
 
static int beepexePresent (void)
 
static int playsoundPresent (void)
 
static int paplayPresent (void)
 
static int xmessagePresent (void)
 
static int gxmessagePresent (void)
 
static int gmessagePresent (void)
 
static int notifysendPresent (void)
 
static int perlPresent (void)
 
static int afplayPresent (void)
 
static int xdialogPresent (void)
 
static int gdialogPresent (void)
 
static int osascriptPresent (void)
 
static int dunstifyPresent (void)
 
static int dunstPresent (void)
 
int tfd_qarmaPresent (void)
 
int tfd_matedialogPresent (void)
 
int tfd_shellementaryPresent (void)
 
int tfd_xpropPresent (void)
 
int tfd_zenityPresent (void)
 
int tfd_yadPresent (void)
 
int tfd_zenity3Present (void)
 
int tfd_kdialogPresent (void)
 
static int osx9orBetter (void)
 
static int python3Present (void)
 
static int python2Present (void)
 
static int tkinter3Present (void)
 
static int tkinter2Present (void)
 
static int pythonDbusPresent (void)
 
static void sigHandler (int signum)
 
void tinyfd_beep (void)
 
int tinyfd_messageBox (char const *aTitle, char const *aMessage, char const *aDialogType, char const *aIconType, int aDefaultButton)
 
int tinyfd_notifyPopup (char const *aTitle, char const *aMessage, char const *aIconType)
 
char * tinyfd_inputBox (char const *aTitle, char const *aMessage, char const *aDefaultInput)
 
char * tinyfd_saveFileDialog (char const *aTitle, char const *aDefaultPathAndOrFile, int aNumOfFilterPatterns, char const *const *aFilterPatterns, char const *aSingleFilterDescription)
 
char * tinyfd_openFileDialog (char const *aTitle, char const *aDefaultPathAndOrFile, int aNumOfFilterPatterns, char const *const *aFilterPatterns, char const *aSingleFilterDescription, int aAllowMultipleSelects)
 
char * tinyfd_selectFolderDialog (char const *aTitle, char const *aDefaultPath)
 
char * tinyfd_colorChooser (char const *aTitle, char const *aDefaultHexRGB, unsigned char const aDefaultRGB[3], unsigned char aoResultRGB[3])
 
void tfd_messageBox (char const *aTitle, char const *aMessage, char const *aDialogType, char const *aIconType, int *aiDefaultButton)
 
void tfd_inputBox (char const *aTitle, char const *aMessage, char **aiDefaultInput)
 
void tfd_saveFileDialog (char const *aTitle, char **aiDefaultPathAndFile, int const *aNumOfFilterPatterns, char const *const *aFilterPatterns, char const *aSingleFilterDescription)
 
void tfd_openFileDialog (char const *aTitle, char **aiDefaultPathAndFile, int const *aNumOfFilterPatterns, char const *const *aFilterPatterns, char const *aSingleFilterDescription, int const *aAllowMultipleSelects)
 
void tfd_selectFolderDialog (char const *aTitle, char **aiDefaultPath)
 
void tfd_colorChooser (char const *aTitle, char **aiDefaultHexRGB)
 

Variables

char tinyfd_version [8] = "3.19.1"
 
int tinyfd_verbose = 0
 
int tinyfd_silent = 1
 
int tinyfd_allowCursesDialogs = 0
 
int tinyfd_forceConsole = 0
 
char tinyfd_response [1024]
 
static int gWarningDisplayed = 0
 
static char gTitle [] ="missing software! (we will try basic console input)"
 
char tinyfd_needs []
 
static char gPython2Name [16]
 
static char gPython3Name [16]
 
static char gPythonName [16]
 

Macro Definition Documentation

◆ LOW_MULTIPLE_FILES

#define LOW_MULTIPLE_FILES   32

◆ MAX_MULTIPLE_FILES

#define MAX_MULTIPLE_FILES   1024

◆ MAX_PATH_OR_CMD

#define MAX_PATH_OR_CMD   1024 /* _MAX_PATH or MAX_PATH */

◆ TINYFD_SLASH

#define TINYFD_SLASH   "/"

Function Documentation

◆ afplayPresent()

static int afplayPresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ beepexePresent()

static int beepexePresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ detectPresence()

static int detectPresence ( char const *  aExecutable)
static
Here is the caller graph for this function:

◆ dialogName()

static char* dialogName ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dialogNameOnly()

static char* dialogNameOnly ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dirExists()

static int dirExists ( char const *  aDirPath)
static
Here is the caller graph for this function:

◆ dunstifyPresent()

static int dunstifyPresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dunstPresent()

static int dunstPresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ensureFilesExist()

static char* ensureFilesExist ( char *  aDestination,
char const *  aSourcePathsAndNames 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ensureFinalSlash()

static void ensureFinalSlash ( char *  aioString)
static
Here is the caller graph for this function:

◆ ffplayPresent()

static int ffplayPresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileExists()

static int fileExists ( char const *  aFilePathAndName)
static
Here is the caller graph for this function:

◆ filenameValid()

static int filenameValid ( char const *  aFileNameWithoutPath)
static
Here is the caller graph for this function:

◆ gdialogPresent()

static int gdialogPresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCurDir()

static char* getCurDir ( void  )
static
Here is the caller graph for this function:

◆ getenvDISPLAY()

static int getenvDISPLAY ( void  )
static
Here is the caller graph for this function:

◆ getLastName()

static char* getLastName ( char *  aoDestination,
char const *  aSource 
)
static
Here is the caller graph for this function:

◆ getMajorMinorPatch()

static int* getMajorMinorPatch ( char const *  aExecutable)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPathWithoutFinalSlash()

static char* getPathWithoutFinalSlash ( char *  aoDestination,
char const *  aSource 
)
static
Here is the caller graph for this function:

◆ getVersion()

static char* getVersion ( char const *  aExecutable)
static
Here is the caller graph for this function:

◆ gmessagePresent()

static int gmessagePresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ graphicMode()

static int graphicMode ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gxmessagePresent()

static int gxmessagePresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Hex2RGB()

static void Hex2RGB ( char const  aHexRGB[8],
unsigned char  aoResultRGB[3] 
)
static
Here is the caller graph for this function:

◆ isDialogVersionBetter09b()

int isDialogVersionBetter09b ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isTerminalRunning()

static int isTerminalRunning ( void  )
static
Here is the caller graph for this function:

◆ notifysendPresent()

static int notifysendPresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ osascriptPresent()

static int osascriptPresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ osx9orBetter()

static int osx9orBetter ( void  )
static
Here is the caller graph for this function:

◆ pactlPresent()

static int pactlPresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ paplayPresent()

static int paplayPresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ perlPresent()

static int perlPresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ playPresent()

static int playPresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ playsoundPresent()

static int playsoundPresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ python2Present()

static int python2Present ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ python3Present()

static int python3Present ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pythonDbusPresent()

static int pythonDbusPresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RGB2Hex()

static void RGB2Hex ( unsigned char const  aRGB[3],
char  aoResultHexRGB[8] 
)
static
Here is the caller graph for this function:

◆ sigHandler()

static void sigHandler ( int  signum)
static
Here is the caller graph for this function:

◆ speakertestPresent()

static int speakertestPresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ terminalName()

static char* terminalName ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tfd_colorChooser()

void tfd_colorChooser ( char const *  aTitle,
char **  aiDefaultHexRGB 
)
Here is the call graph for this function:

◆ tfd_inputBox()

void tfd_inputBox ( char const *  aTitle,
char const *  aMessage,
char **  aiDefaultInput 
)
Here is the call graph for this function:

◆ tfd_isDarwin()

int tfd_isDarwin ( void  )
Here is the caller graph for this function:

◆ tfd_kdialogPresent()

int tfd_kdialogPresent ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tfd_matedialogPresent()

int tfd_matedialogPresent ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tfd_messageBox()

void tfd_messageBox ( char const *  aTitle,
char const *  aMessage,
char const *  aDialogType,
char const *  aIconType,
int *  aiDefaultButton 
)
Here is the call graph for this function:

◆ tfd_openFileDialog()

void tfd_openFileDialog ( char const *  aTitle,
char **  aiDefaultPathAndFile,
int const *  aNumOfFilterPatterns,
char const *const *  aFilterPatterns,
char const *  aSingleFilterDescription,
int const *  aAllowMultipleSelects 
)
Here is the call graph for this function:

◆ tfd_qarmaPresent()

int tfd_qarmaPresent ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tfd_quoteDetected()

int tfd_quoteDetected ( char const *  aString)
Here is the caller graph for this function:

◆ tfd_replaceSubStr()

void tfd_replaceSubStr ( char const *  aSource,
char const *  aOldSubStr,
char const *  aNewSubStr,
char *  aoDestination 
)
Here is the caller graph for this function:

◆ tfd_saveFileDialog()

void tfd_saveFileDialog ( char const *  aTitle,
char **  aiDefaultPathAndFile,
int const *  aNumOfFilterPatterns,
char const *const *  aFilterPatterns,
char const *  aSingleFilterDescription 
)
Here is the call graph for this function:

◆ tfd_selectFolderDialog()

void tfd_selectFolderDialog ( char const *  aTitle,
char **  aiDefaultPath 
)
Here is the call graph for this function:

◆ tfd_shellementaryPresent()

int tfd_shellementaryPresent ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tfd_xpropPresent()

int tfd_xpropPresent ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tfd_yadPresent()

int tfd_yadPresent ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tfd_zenity3Present()

int tfd_zenity3Present ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tfd_zenityPresent()

int tfd_zenityPresent ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tinyfd_beep()

void tinyfd_beep ( void  )
Here is the call graph for this function:

◆ tinyfd_colorChooser()

char* tinyfd_colorChooser ( char const *  aTitle,
char const *  aDefaultHexRGB,
unsigned char const  aDefaultRGB[3],
unsigned char  aoResultRGB[3] 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tinyfd_getGlobalChar()

char const* tinyfd_getGlobalChar ( char const *  aCharVariableName)

◆ tinyfd_getGlobalInt()

int tinyfd_getGlobalInt ( char const *  aIntVariableName)

◆ tinyfd_inputBox()

char* tinyfd_inputBox ( char const *  aTitle,
char const *  aMessage,
char const *  aDefaultInput 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tinyfd_messageBox()

int tinyfd_messageBox ( char const *  aTitle,
char const *  aMessage,
char const *  aDialogType,
char const *  aIconType,
int  aDefaultButton 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tinyfd_notifyPopup()

int tinyfd_notifyPopup ( char const *  aTitle,
char const *  aMessage,
char const *  aIconType 
)
Here is the call graph for this function:

◆ tinyfd_openFileDialog()

char* tinyfd_openFileDialog ( char const *  aTitle,
char const *  aDefaultPathAndOrFile,
int  aNumOfFilterPatterns,
char const *const *  aFilterPatterns,
char const *  aSingleFilterDescription,
int  aAllowMultipleSelects 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tinyfd_saveFileDialog()

char* tinyfd_saveFileDialog ( char const *  aTitle,
char const *  aDefaultPathAndOrFile,
int  aNumOfFilterPatterns,
char const *const *  aFilterPatterns,
char const *  aSingleFilterDescription 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tinyfd_selectFolderDialog()

char* tinyfd_selectFolderDialog ( char const *  aTitle,
char const *  aDefaultPath 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tinyfd_setGlobalInt()

int tinyfd_setGlobalInt ( char const *  aIntVariableName,
int  aValue 
)

◆ tkinter2Present()

static int tkinter2Present ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tkinter3Present()

static int tkinter3Present ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryCommand()

static int tryCommand ( char const *  aCommand)
static
Here is the caller graph for this function:

◆ whiptailPresent()

static int whiptailPresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ whiptailPresentOnly()

static int whiptailPresentOnly ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wipefile()

static void wipefile ( char const *  aFilename)
static
Here is the caller graph for this function:

◆ xdialogPresent()

static int xdialogPresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xmessagePresent()

static int xmessagePresent ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ gPython2Name

char gPython2Name[16]
static

◆ gPython3Name

char gPython3Name[16]
static

◆ gPythonName

char gPythonName[16]
static

◆ gTitle

char gTitle[] ="missing software! (we will try basic console input)"
static

◆ gWarningDisplayed

int gWarningDisplayed = 0
static

◆ tinyfd_allowCursesDialogs

int tinyfd_allowCursesDialogs = 0

Curses dialogs are difficult to use and counter-intuitive. On windows they are only ascii and still uses the unix backslash !

◆ tinyfd_forceConsole

int tinyfd_forceConsole = 0

◆ tinyfd_needs

char tinyfd_needs[]
Initial value:
= "\
___________\n\
/ \\ \n\
| tiny file |\n\
| dialogs |\n\
\\_____ ____/\n\
\\|\
\ntiny file dialogs on UNIX needs:\
\n applescript or kdialog or yad or Xdialog\
\nor zenity (or matedialog or shellementary or qarma)\
\nor python (2 or 3) + tkinter + python-dbus (optional)\
\nor dialog (opens console if needed) ** Disabled by default **\
\nor xterm + bash (opens console for basic input)\
\nor existing console for basic input."

◆ tinyfd_response

char tinyfd_response[1024]

◆ tinyfd_silent

int tinyfd_silent = 1

◆ tinyfd_verbose

int tinyfd_verbose = 0

◆ tinyfd_version

char tinyfd_version[8] = "3.19.1"