night mission
This commit is contained in:
10
files/Makefile
Normal file
10
files/Makefile
Normal 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
2
files/samples.list
Normal file
@@ -0,0 +1,2 @@
|
||||
a | bla bla | ../AK14V-ORDRES.wav
|
||||
B | plop ! | ../AK14V-ORDRES.wav
|
||||
115
files/t.c
Normal file
115
files/t.c
Normal 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;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
Reference in New Issue
Block a user