libsheepy

C lib for handling text files, strings and json like data structure with an object oriented system
git clone https://spartatek.se/git/libsheepy.git
Log | Files | Refs | README | LICENSE

here.c (1032B)


      1 //
      2 
      3 #include "../release/libsheepyObject.h"
      4 
      5 #define internal static
      6 
      7 
      8 #ifndef unitTest
      9 #endif
     10 int MAIN(int ARGC, char** ARGV);
     11 
     12 int argc; char **argv;
     13 
     14 #ifndef unitTest
     15 // Remove main when running the unit tests
     16 #define MAIN   main
     17 #endif
     18 int MAIN(int ARGC, char** ARGV) {
     19   char **list UNUSED = NULL;
     20 
     21   argc = ARGC; argv = ARGV;;// list path having the words given in arguments
     22 
     23   // Steps
     24   // check arguments
     25   // copy arguments to array args
     26   // list files in current folder
     27   // print path having any word given on the command line
     28 
     29   // check arguments
     30   if (argc < 2) {
     31     puts(BLD RED "At least one argument is needed" RST);
     32   }
     33 
     34   // copy arguments to array args
     35   cleanAllocateSmallArray(args);
     36   fromArrayG(args, &argv[1], argc-1);
     37 
     38   // list files in current folder
     39   cleanSmallArrayP(a) = walkDirG(rtSmallArrayt, ".");
     40 
     41   // print path having any word given on the command line
     42   iter(a, l) {
     43     castS(L, l);
     44     iter(args, arg) {
     45       castS(s, arg);
     46       if (hasG(L, s)) {
     47         putsG(L);
     48       }
     49     }
     50   }
     51 }