diff --git a/.gitignore b/.gitignore index 494b51c..36722de 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,9 @@ audio/*.wav ui/t +files/t + + # ---> C # Prerequisites *.d diff --git a/files/Makefile b/files/Makefile new file mode 100644 index 0000000..16e5f55 --- /dev/null +++ b/files/Makefile @@ -0,0 +1,10 @@ +CC = gcc +CCOPT = -Wall -g -DDEBUG_LEVEL=1 + + + +LIBS = + +t: t.c ${OBJS} Makefile + $(CC) ${CCOPT} $< ${OBJS} ${LIBS} -o $@ + diff --git a/files/samples.list b/files/samples.list new file mode 100644 index 0000000..a995406 --- /dev/null +++ b/files/samples.list @@ -0,0 +1,2 @@ +a | bla bla | ../AK14V-ORDRES.wav + B | plop ! | ../AK14V-ORDRES.wav diff --git a/files/t.c b/files/t.c new file mode 100644 index 0000000..737ee0b --- /dev/null +++ b/files/t.c @@ -0,0 +1,115 @@ +/* + * NcLooper test des fonctions fichier (???) + */ + +#include +#include +#include +#include + +/* --------------------------------------------------------------------- */ +int verbosity; + +typedef struct { + char key; + char text[100]; + char path[200]; + } SampleRef; + +/* --------------------------------------------------------------------- */ +static int decode_la_ligne(char *line, SampleRef *sref) +{ +char *ptr; + +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( '%s' %p )\n", __func__, line, sref); +#endif + +/* + * ON THE WAY TO PARSING HELL + */ +ptr = strtok(line, "|"); +fprintf(stderr, "[%s]\n", ptr); +ptr = strtok(NULL, "|"); +fprintf(stderr, "[%s]\n", ptr); +ptr = strtok(NULL, "|"); +fprintf(stderr, "[%s]\n", ptr); + +return -1; +} +/* --------------------------------------------------------------------- */ +#define T_LINE 200 + +int essai_lecture_liste(char *fname) +{ +FILE *fp; +char line[T_LINE+1]; +int ln; /* line number */ +int foo, bar; +SampleRef sample; + +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( '%s' )\n", __func__, fname); +#endif + +if (NULL==(fp=fopen(fname, "r"))) { + perror(fname); + exit(1); + } + +ln = 1; +while (NULL != fgets(line, T_LINE, fp)) { + + fprintf(stderr, "%3d = %s", ln, line); + + /* degommer l'eventuel \n */ + bar = strlen(line); + if (0==bar) { + fprintf(stderr,"line %d very short\n", ln); + continue; + } + bar--; /* backspace one char */ + if ('\n' == line[bar]) line[bar]='\0'; + + foo = decode_la_ligne(line, &sample); + fprintf(stderr, "decode la ligne -> %d\n", foo); + + + ln++; + } + +fclose(fp); + +return -1; +} +/* --------------------------------------------------------------------- */ +void help(int k) +{ +puts("Test des fonctions de gestion des fichiers"); +exit(0); +} +/* --------------------------------------------------------------------- */ + +int main(int argc, char *argv[]) +{ +int foo; +int opt; +char *listname = "samples.list"; + +while ((opt = getopt(argc, argv, "hv")) != -1) { + switch(opt) { + case 'h': help(0); break; + case 'v': verbosity++; break; + } + } + +#if DEBUG_LEVEL +fprintf(stderr, "argc = %d, optind = %d\n", argc, optind); +#endif + +foo = essai_lecture_liste(listname); +fprintf(stderr,"essai lecture '%s' -> %d\n", listname, foo); + +return 0; +} +/* --------------------------------------------------------------------- */ diff --git a/ui/Makefile b/ui/Makefile index 773adfd..f290c9a 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -4,7 +4,14 @@ CC = gcc CCOPT = -Wall -g -DDEBUG_LEVEL=1 +ncfuncs.o: ncfuncs.c ncfuncs.h Makefile + $(CC) ${CCOPT} -c $< + +OBJS = ncfuncs.o +LIBS = -lcurses t: t.c ${OBJS} Makefile $(CC) ${CCOPT} $< ${OBJS} ${LIBS} -o $@ + + diff --git a/ui/ncfuncs.c b/ui/ncfuncs.c new file mode 100644 index 0000000..ad75b1a --- /dev/null +++ b/ui/ncfuncs.c @@ -0,0 +1,29 @@ +/* + * NcLooper--- interface curses, fonctions de base + */ + + +#include + +/* --------------------------------------------------------------------- */ +int init_ecran(char *txt) +{ +initscr(); + +standout(); +border('o', 'o', 'o', 'o', 'X', 'X', 'X', 'X'); +standend(); +mvaddstr(1, 5, txt); +refresh(); + +return -1; +} +/* --------------------------------------------------------------------- */ +int fin_ecran(void) +{ + +endwin(); + +return 0; +} +/* --------------------------------------------------------------------- */ diff --git a/ui/ncfuncs.h b/ui/ncfuncs.h new file mode 100644 index 0000000..aec054b --- /dev/null +++ b/ui/ncfuncs.h @@ -0,0 +1,8 @@ +/* + * NcLooper--- interface curses, fonctions de base + */ + + +int init_ecran(char *txt); +int fin_ecran(void); + diff --git a/ui/t.c b/ui/t.c index 1f5d97f..9f2fe3a 100644 --- a/ui/t.c +++ b/ui/t.c @@ -6,6 +6,8 @@ #include #include +#include "ncfuncs.h" + /* --------------------------------------------------------------------- */ int verbosity; @@ -34,6 +36,12 @@ while ((opt = getopt(argc, argv, "hv")) != -1) { fprintf(stderr, "argc = %d, optind = %d\n", argc, optind); #endif +foo = init_ecran("* NcLooper *"); +sleep(2); + + + +fin_ecran(); return 0; }