SmartFolder  1.0
SmartFolder is a way to search files on your system and group the results. The program will interpret search queries and create a folder with symbolic links to all the found matches.
Parser.c File Reference

Source file that contains the implementation of our Parser. More...

#include "Parser.h"
Include dependency graph for Parser.c:

Functions

int isValidPath (const char *path)
 
struct timespec * getTimeSpec (const char *date)
 
searchType getSearchType (const char *param, const char *arg)
 
int isBooleanOp (const char *word)
 
int isValidSearch (searchType st, const char *arg)
 
int evaluateAndSearch (const char **expression, int exprLen, char *folder, List **result)
 
const void * prepareArgument (searchType st, const char *arg)
 
int getSize (const char *sizeAsString)
 
const char * trimArgument (searchType st, const char *arg)
 

Detailed Description

Source file that contains the implementation of our Parser.

Authors
Maxime Lovino, Thomas Ibanez
Date
January 25, 2017
Version
1.0

Function Documentation

int evaluateAndSearch ( const char **  expression,
int  exprLen,
char *  folder,
List **  result 
)

Evaluates an expression and searches for matching files

Parameters
expressionThe expression to search with (as an array of terms)
exprLenThe length of the expression
folderThe folder to search from
resultA List to put the results of the search in
Returns
0 if the search was ok, 1 otherwise
searchType getSearchType ( const char *  param,
const char *  arg 
)

Converts a search word to a searchType

Parameters
paramthe search word
argthe parameter linked to the search word
Returns
the corresponding searchType or -1 if no match exists
int getSize ( const char *  sizeAsString)

Converts a size with its Unit suffix (K, M, G, T) to the correct size

Parameters
sizeAsStringThe size with its suffix
Returns
The size as an integer value
struct timespec* getTimeSpec ( const char *  date)

Function to convert a date in YYYY-MM-DD format to a timespec

Parameters
dateThe date as a String in the format YYYY-MM-DD
Returns
The date as a a pointer of struct timespec
int isBooleanOp ( const char *  word)

Checks if a word is a boolean operator

Parameters
wordthe word to check
Returns
1 if it is a boolean operator, 0 otherwise
int isValidPath ( const char *  path)

Function to check if a path is valid

Parameters
pathThe path we want to check
Returns
1 if the path is valid, 0 otherwise
int isValidSearch ( searchType  st,
const char *  arg 
)

Checks if a searchType has proper argument linked to it

Parameters
stThe search type
argThe argument
Returns
1 if the search is valid, 0 otherwise
const void* prepareArgument ( searchType  st,
const char *  arg 
)

Function that returns a generic pointer to an argument for a search of a certain type It will actually return the pointer for the correct type depending on the search

Parameters
stThe type of search
argThe argument as a string
Returns
A pointer to the argument in the correct type
const char* trimArgument ( searchType  st,
const char *  arg 
)

Removes the + or - before a search argument if necessary

Parameters
stsearchType
argargument to trim
Returns
Trimmed argument