From e660aacdb3fe0f79d1531d9aa0c8ce2f158b7ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjetil=20=C3=98rbekk?= Date: Wed, 21 Nov 2007 20:09:39 +0100 Subject: - Added Makefile - Moved `test programs` out of source tree (So the Makefile actually works) --- Makefile | 19 +++++++++++++++++++ id3test.c | 26 ++++++++++++++++++++++++++ readdir_test.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/id3test.c | 26 -------------------------- src/readdir_test.c | 52 ---------------------------------------------------- 5 files changed, 97 insertions(+), 78 deletions(-) create mode 100644 Makefile create mode 100644 id3test.c create mode 100644 readdir_test.c delete mode 100644 src/id3test.c delete mode 100644 src/readdir_test.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..18fb9c9 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +CFLAGS = -Wall -Iinclude/ \ + `pkg-config fuse --cflags` + +LD_ADD = -lid3 \ + `pkg-config fuse --libs` +CC = gcc + +C_FILES = $(wildcard src/*.c) +OBJS = $(C_FILES:.c=.o) \ + +PROGRAM = mp3fs + +all: $(PROGRAM) + +$(PROGRAM): $(OBJS) + $(CC) -o $@ $+ $(LD_ADD) + +clean: + rm -f $(PROGRAM) $(OBJS) *~ diff --git a/id3test.c b/id3test.c new file mode 100644 index 0000000..6136112 --- /dev/null +++ b/id3test.c @@ -0,0 +1,26 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +#include +#include +#include "mp3node.h" + +/* Compile with gcc -Wall -lid3 -I../include id3test.c */ + +int main (int argc, char **argv) +{ + if (argc != 2) + return -1; + + struct mnode node; + + node.tag = ID3Tag_New (); + ID3Tag_Link (node.tag, argv[1]); + ID3Frame *artist_frame = ID3Tag_FindFrameWithID (node.tag, ID3FID_LEADARTIST); + + ID3Field *field = ID3Frame_GetField (artist_frame, ID3FN_TEXT); + char *artist = malloc (sizeof(char) * (ID3Field_Size (field) + 1)); + ID3Field_GetASCII (field, artist, ID3Field_Size (field)); + + printf("Artist: %s\n", artist); + + return 0; +} diff --git a/readdir_test.c b/readdir_test.c new file mode 100644 index 0000000..0cca325 --- /dev/null +++ b/readdir_test.c @@ -0,0 +1,52 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +#include +#include +#include +#include +#include + +extern int errno; + +void print_directory (char *path, int level) +{ + DIR *dir = opendir (path); + int i; + + if (dir == NULL) { + for (i=0; id_name, "." ) == 0 || + strcmp (de->d_name, "..") == 0) + continue; + + for (i=0; id_name); + + if (de->d_type == 4) { /* ToDo: have to use lstat or something */ + char subdir[strlen(path) + strlen(de->d_name) + 1]; + strcpy (subdir, path); + strcpy (subdir+strlen(path), "/"); + strcpy (subdir+strlen(path)+1, de->d_name); + + print_directory (subdir, level+1); + } + } +} + +int main (int argc, char **argv) +{ + if (argc != 2) + return -1; + + print_directory (argv[1], 0); + return 0; +} + diff --git a/src/id3test.c b/src/id3test.c deleted file mode 100644 index 6136112..0000000 --- a/src/id3test.c +++ /dev/null @@ -1,26 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -#include -#include -#include "mp3node.h" - -/* Compile with gcc -Wall -lid3 -I../include id3test.c */ - -int main (int argc, char **argv) -{ - if (argc != 2) - return -1; - - struct mnode node; - - node.tag = ID3Tag_New (); - ID3Tag_Link (node.tag, argv[1]); - ID3Frame *artist_frame = ID3Tag_FindFrameWithID (node.tag, ID3FID_LEADARTIST); - - ID3Field *field = ID3Frame_GetField (artist_frame, ID3FN_TEXT); - char *artist = malloc (sizeof(char) * (ID3Field_Size (field) + 1)); - ID3Field_GetASCII (field, artist, ID3Field_Size (field)); - - printf("Artist: %s\n", artist); - - return 0; -} diff --git a/src/readdir_test.c b/src/readdir_test.c deleted file mode 100644 index 0cca325..0000000 --- a/src/readdir_test.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -#include -#include -#include -#include -#include - -extern int errno; - -void print_directory (char *path, int level) -{ - DIR *dir = opendir (path); - int i; - - if (dir == NULL) { - for (i=0; id_name, "." ) == 0 || - strcmp (de->d_name, "..") == 0) - continue; - - for (i=0; id_name); - - if (de->d_type == 4) { /* ToDo: have to use lstat or something */ - char subdir[strlen(path) + strlen(de->d_name) + 1]; - strcpy (subdir, path); - strcpy (subdir+strlen(path), "/"); - strcpy (subdir+strlen(path)+1, de->d_name); - - print_directory (subdir, level+1); - } - } -} - -int main (int argc, char **argv) -{ - if (argc != 2) - return -1; - - print_directory (argv[1], 0); - return 0; -} - -- cgit v1.2.3