mirror of
https://github.com/tomasriveral/NoteWrapper.git
synced 2026-08-12 10:20:46 +02:00
format: fix whole project
This commit is contained in:
+35
-32
@@ -1,60 +1,60 @@
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#include <cjson/cJSON.h>
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <ftw.h>
|
||||
#include <limits.h>
|
||||
#include <ncurses.h>
|
||||
#include <pwd.h>
|
||||
#include <regex.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <ftw.h>
|
||||
#include <pwd.h>
|
||||
#include <ncurses.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/wait.h>
|
||||
#include <limits.h>
|
||||
#include <cjson/cJSON.h>
|
||||
#include <regex.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <ftw.h>
|
||||
#include <unistd.h>
|
||||
#ifndef VERSION
|
||||
#define VERSION "dev"
|
||||
#endif
|
||||
#define BUFFER_SIZE 256 //standard buffer size.
|
||||
// the three supported values are "daily" "weekly" and "monthly" (for months we use the avarage lenght of a month in a non leap year). All values were calculated on my loyal TI-30 ECO RS
|
||||
#define BUFFER_SIZE 256 // standard buffer size.
|
||||
// the three supported values are "daily" "weekly" and "monthly" (for months we use the avarage
|
||||
// lenght of a month in a non leap year). All values were calculated on my loyal TI-30 ECO RS
|
||||
#define DAILY 86400
|
||||
#define WEEKLY 604800
|
||||
#define MONTHLY 2628000 // calculated from the average lenght of a non leap year
|
||||
#define debug(message, ...) \
|
||||
#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 altDebug(message, ...) _altDebug(shouldDebug, message, ##__VA_ARGS__)
|
||||
#define error(condition, type, message, ...) \
|
||||
_error(shouldDebug, condition, type, __FILE__, __LINE__, __func__, message, ##__VA_ARGS__)
|
||||
// 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
|
||||
extern const int numEditors; // number of supported editors
|
||||
|
||||
|
||||
//compares two strings alphabetically.
|
||||
//this function is used for qsort
|
||||
// compares two strings alphabetically.
|
||||
// this function is used for qsort
|
||||
int compareString(const void *a, const void *b);
|
||||
// compares two strings in reversed alphabetical order
|
||||
// this function is used for qsort
|
||||
int reverseCompareString(const void *a, const void *b);
|
||||
// checks if editor is supported and if it installed.
|
||||
// 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.
|
||||
// This can return an error and stop the program.
|
||||
// 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. This can return an error and stop the program.
|
||||
int isEditorValid(char *editorToCheck, int useDefaultEditor, int debug);
|
||||
// please use the macro debug instead of _debug.
|
||||
//formated debugging.
|
||||
void _debug(const int d, const char *file, const int line, const char *function, const char *message, ...);
|
||||
//use for less formal debuggin. (usefull if enumerating or making a list).
|
||||
// formated debugging.
|
||||
void _debug(const int d, const char *file, const int line, const char *function,
|
||||
const char *message, ...);
|
||||
// use for less formal debuggin. (usefull if enumerating or making a list).
|
||||
void _altDebug(const int d, const char *message, ...);
|
||||
// formated error.
|
||||
void _error(const int shouldDebug, const int condition, const char *type, const char *file, const int line, const char *function, const char *message, ...);
|
||||
void _error(const int shouldDebug, const int condition, const char *type, const char *file,
|
||||
const int line, const char *function, const char *message, ...);
|
||||
// Returns 1 if the string is in the array.
|
||||
// Returns 0 if the string is not in the array.
|
||||
// If you want to only check the first n elements of the array, pass n as len.
|
||||
@@ -68,8 +68,8 @@ void appendToFile(const char *path, const char *string, const int shouldDebug);
|
||||
// replace unwanted chars by '_'.
|
||||
// '.' is replaced if it is only the first two chars
|
||||
void sanitize(char *string);
|
||||
//from https://stackoverflow.com/a/5467788.
|
||||
//deletes an entire directory. Use with parsimony and carefullness.
|
||||
// from https://stackoverflow.com/a/5467788.
|
||||
// deletes an entire directory. Use with parsimony and carefullness.
|
||||
int rmrf(char *path, int shouldDebug);
|
||||
// Inputs are the path to the file, the editor to open and some rendering option.
|
||||
// render: if we render the .md file with Vivify.
|
||||
@@ -84,6 +84,9 @@ char *getFormatedTime(char *format, int shouldDebug);
|
||||
If need launches in the background rsync to do the backuping.
|
||||
Each pair of source/destination will launch one rsync process.
|
||||
If a pair don't need to be backed up, the destination should be set to NULL.
|
||||
rsyncArgs is the array of arguments to be passed to rsync. Do not inclue destination or source. It will be added in the function.*/
|
||||
void handleBackups(char **sourceDirectoryArray, const int sourceDirectoryNumber, char **destinationDirectoryArray, const char *homeDir, const int interval, const char **rsyncArgs, const int rsyncArgsNumber, const int shouldDebug);
|
||||
rsyncArgs is the array of arguments to be passed to rsync. Do not inclue destination or source. It
|
||||
will be added in the function.*/
|
||||
void handleBackups(char **sourceDirectoryArray, const int sourceDirectoryNumber,
|
||||
char **destinationDirectoryArray, const char *homeDir, const int interval,
|
||||
const char **rsyncArgs, const int rsyncArgsNumber, const int shouldDebug);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user