=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/aucat/Attic/file.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- src/usr.bin/aucat/Attic/file.c 2008/08/14 09:48:50 1.2 +++ src/usr.bin/aucat/Attic/file.c 2008/08/14 09:58:55 1.3 @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.2 2008/08/14 09:48:50 ratchov Exp $ */ +/* $OpenBSD: file.c,v 1.3 2008/08/14 09:58:55 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov * @@ -31,17 +31,36 @@ #include #include #include +#include #include #include "conf.h" #include "file.h" #include "aproc.h" #include "abuf.h" +#include "dev.h" #define MAXFDS 100 struct filelist file_list; +void +file_dprint(int n, struct file *f) +{ + if (debug_level >= n) { + fprintf(stderr, "%s <", f->name); + if (f->state & FILE_ROK) + fprintf(stderr, "ROK"); + if (f->state & FILE_WOK) + fprintf(stderr, "WOK"); + if (f->state & FILE_EOF) + fprintf(stderr, "EOF"); + if (f->state & FILE_HUP) + fprintf(stderr, "HUP"); + fprintf(stderr, ">"); + } +} + struct file * file_new(int fd, char *name) { @@ -74,7 +93,14 @@ void file_del(struct file *f) { - DPRINTF("file_del: %s|%x\n", f->name, f->state); + DPRINTF("file_del: "); + file_dprint(1, f); + DPRINTF("\n"); + + if (f->hdr == HDR_WAV) + wav_writehdr(f->fd, &f->hpar); + close(f->fd); + free(f); } int @@ -176,8 +202,8 @@ fnext = LIST_NEXT(f, entry); if (f->rproc == NULL && f->wproc == NULL) { LIST_REMOVE(f, entry); - DPRINTF("file_poll: %s: deleted\n", f->name); - free(f); + DPRINTF("file_poll: %s: removed\n", f->name); + file_del(f); } } if (LIST_EMPTY(&file_list)) {