mirror of
https://github.com/tomasriveral/NoteWrapper.git
synced 2026-08-12 02:18:38 +02:00
Added first part of journal code and debug(), altDebug() and error()
This commit is contained in:
+21
-3
@@ -14,9 +14,15 @@
|
||||
#include <sys/wait.h>
|
||||
#include <limits.h>
|
||||
#include <cjson/cJSON.h>
|
||||
|
||||
#include <regex.h>
|
||||
#include <errno.h>
|
||||
#define debug(message, ...) \
|
||||
_debug(shouldDebug, __FILE__, __LINE__, __func__, message, ##__VA_ARGS__)
|
||||
#define altDebug(message, ...) \
|
||||
_altDebug(shouldDebug, message, ##__VA_ARGS__)
|
||||
#define error(condition, type, message, ...) \
|
||||
_error(shouldDebug, condition, type, __FILE__, __LINE__, __func__, message, ##__VA_ARGS__)
|
||||
#define HASH_MACRO "0ea1d20bcdd52c46c086d3dba125b9b83ad8cbea2e026d5646775f48bae8f867" // if the user inputs this hash. The program brokes. It was the best way i found to see if some values were unchanged
|
||||
|
||||
// you must edit this two values if you want to add suport for an editor
|
||||
extern const char *supportedEditor[]; // array of supported editors
|
||||
extern const int numEditors; // number of supported editors
|
||||
@@ -27,6 +33,13 @@ int compareString(const void *a, const void *b);
|
||||
int doesEditorExist(char *editorToCheck, int debug);
|
||||
// this basically checks all the dirs from your path for the editor. This is a safety check
|
||||
// If the executable from an editor is not the editor name (for example neovim and nvim), you must handle at the start of the function.
|
||||
void _debug(const int d, const char *file, const int line, const char *function, const char *message, ...);
|
||||
//formated debugging
|
||||
void _altDebug(const int d, const char *message, ...);
|
||||
//use for less formal debuggin. (usefull if enumerating or making a list)
|
||||
void _error(const int shouldDebug, const int condition, const char *type, const char *file, const int line, const char *function, const char *message, ...);
|
||||
// formated error
|
||||
// if the error is not a critical one (for ex: file not found) System error message will be Succesfull
|
||||
int isStringInArray(const char *string, const char **array, const int len);
|
||||
// Returns 1 if the string is in the array
|
||||
// Returns 0 if the string is not in the array
|
||||
@@ -38,8 +51,13 @@ int rmrf(char *path);
|
||||
//deletes an entire directory. Use with parsimony and carefullness
|
||||
char **getVaultsFromDirectory(char *dirString, size_t *count, int debug);
|
||||
// this function is inputed a path to a directory (which comes usually from the config file) and outpus all the suitable directories (so not the hidden ones) which will serve as separate vaults for notes
|
||||
char **getNotesFromVault(char *pathToVault, char *vault, int *count, int debug);
|
||||
char **getNotesFromVault(char *pathToVault, char *vault, char *journalRegex, int *count, int debug);
|
||||
// this function is inputed a path to a vault (which was selected before) and outpus all the suitable notes (so not the hidden ones)
|
||||
// journalRegex is the regex code for the journals. If a note matches this code, it is treated as a journal and it is not outputed from this function.
|
||||
char **getJournalsFromVault(char *pathToVault, char *vault, char *journalRegex, int *count, int debug);
|
||||
// gets the journals from the vault
|
||||
// to distinguish journals from note we use regex.
|
||||
// Note: we must handle them separatly as journals can either be a single file (which will treat specially) or a directory
|
||||
int openEditor(char *path, char *editor, int render, int endOfFile, int debug);
|
||||
// Inputs are the path to the file, the editor to open and some rendering option
|
||||
// render: if we render the .md file with Vivify
|
||||
|
||||
Reference in New Issue
Block a user