fish/fish_shell/fish_utils.h

70 lines
1.9 KiB
C
Raw Permalink Normal View History

2017-05-15 12:08:10 +00:00
//
// Created by Antoine Bartuccio on 15/05/2017.
//
#ifndef FISH_FISH_UTILS_H
#define FISH_FISH_UTILS_H
2017-05-15 13:02:58 +00:00
#include "fish_types.h"
2017-06-19 11:45:06 +00:00
/* Crash the application and throw a random error message in english */
2017-05-16 00:58:16 +00:00
void crash(); // Tested
2017-05-15 12:08:10 +00:00
2017-06-19 11:45:06 +00:00
/* Get a random french insult for the user */
2017-05-16 00:58:16 +00:00
char *getInsult(); // Tested
2017-05-15 13:52:48 +00:00
2017-06-19 11:45:06 +00:00
/* Free a WordArray */
2017-05-16 00:58:16 +00:00
void freeWordArray(WordArray *array); // Tested
2017-05-15 13:02:58 +00:00
2017-06-19 11:45:06 +00:00
/* Create a new WordList */
2017-05-16 00:58:16 +00:00
WordList * createWordList(); // Tested
2017-05-15 13:02:58 +00:00
2017-06-19 11:45:06 +00:00
/* Cut a WordList and throw every word contained between the two index */
WordList * sliceWordList(WordList *list, int min_index, int max_index);
2017-06-19 11:45:06 +00:00
/* Add a world at the end of a WordList */
void addEndWordList(WordList *list, char *word); // Tested
2017-06-19 11:45:06 +00:00
/* Add a word at the beginning of a WordList */
void addBeginWordList(WordList *list, char *word);
2017-05-15 13:02:58 +00:00
2017-06-19 11:45:06 +00:00
/* Delete an entire WordList */
2017-05-16 00:58:16 +00:00
void removeWordList(WordList *list); // Tested
2017-05-15 13:02:58 +00:00
2017-06-19 11:45:06 +00:00
/* Remove an element from a WordList */
void removeWordListElem(WordList *list, WordListElement *elem);
2017-06-19 11:45:06 +00:00
/* Free an entire WordList */
2017-05-16 00:58:16 +00:00
void freeWordList(WordList *list); // Tested
2017-05-15 13:02:58 +00:00
2017-06-19 11:45:06 +00:00
/* Convert a WordList into a WordArray */
2017-05-16 00:58:16 +00:00
WordArray * wordListToWordArray(WordList *list); // Tested
2017-05-15 13:02:58 +00:00
2017-06-19 11:45:06 +00:00
/* Convert a WordArray into a WordList */
2017-05-16 00:58:16 +00:00
WordList * wordArrayToWordList(WordArray * array); // Tested
2017-05-15 13:02:58 +00:00
2017-06-19 11:45:06 +00:00
/* Split a WordList according to a given regex */
WordList * splitWordList(WordList *list, char *regex);
2017-06-19 11:45:06 +00:00
/* Split a word from a given index removing parts according to the size to delete */
char * splitWord(char * origin, int beginning_index, int size_to_delete); // Tested
2017-06-19 11:45:06 +00:00
/* Put the second WordList into the first one */
2017-05-27 15:36:55 +00:00
void concatWordList(WordList* list1, WordList* list2);
2017-05-15 17:10:46 +00:00
2017-06-19 11:45:06 +00:00
/* Print a WordList for debug */
2017-05-28 15:25:04 +00:00
void printWordList(WordList* list);
2017-05-16 05:32:19 +00:00
2017-06-19 11:45:06 +00:00
/* Detect if a string contains a given character */
2017-05-16 05:32:19 +00:00
int stringContains(char* string, char charToTest);
2017-06-19 11:45:06 +00:00
/* Better than Strcat */
char* trueStrcat(char* string1, char* string2);
2017-06-19 11:45:06 +00:00
/* Check if the given path is a directory */
2017-06-07 15:58:44 +00:00
int isDirectory(char* path);
2017-05-28 15:25:04 +00:00
2017-05-15 12:08:10 +00:00
#endif //FISH_FISH_UTILS_H