night mission

This commit is contained in:
Tonton Th 2019-10-30 05:31:38 +01:00
parent 7ac2bc53e9
commit d721ea674c
8 changed files with 182 additions and 0 deletions

3
.gitignore vendored
View File

@ -5,6 +5,9 @@ audio/*.wav
ui/t
files/t
# ---> C
# Prerequisites
*.d

10
files/Makefile Normal file
View File

@ -0,0 +1,10 @@
CC = gcc
CCOPT = -Wall -g -DDEBUG_LEVEL=1
LIBS =
t: t.c ${OBJS} Makefile
$(CC) ${CCOPT} $< ${OBJS} ${LIBS} -o $@

2
files/samples.list Normal file
View File

@ -0,0 +1,2 @@
a | bla bla | ../AK14V-ORDRES.wav
B | plop ! | ../AK14V-ORDRES.wav

115
files/t.c Normal file
View File

@ -0,0 +1,115 @@
/*
* NcLooper test des fonctions fichier (???)
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
/* --------------------------------------------------------------------- */
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;
}
/* --------------------------------------------------------------------- */

View File

@ -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 $@

29
ui/ncfuncs.c Normal file
View File

@ -0,0 +1,29 @@
/*
* NcLooper--- interface curses, fonctions de base
*/
#include <curses.h>
/* --------------------------------------------------------------------- */
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;
}
/* --------------------------------------------------------------------- */

8
ui/ncfuncs.h Normal file
View File

@ -0,0 +1,8 @@
/*
* NcLooper--- interface curses, fonctions de base
*/
int init_ecran(char *txt);
int fin_ecran(void);

8
ui/t.c
View File

@ -6,6 +6,8 @@
#include <stdlib.h>
#include <unistd.h>
#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;
}