infra: Clean up project setup
[jog] / auerr.c
CommitLineData
e9060e7e 1/* -*-c-*-
2 *
3 * $Id: auerr.c,v 1.1 2002/02/02 19:16:28 mdw Exp $
4 *
5 * Audio error reporting
6 *
7 * (c) 2002 Mark Wooding
8 */
9
10/*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of Jog: Programming for a jogging machine.
13 *
14 * Jog is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * Jog is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with Jog; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 */
28
e9060e7e 29/*----- Header files ------------------------------------------------------*/
30
31#ifdef HAVE_CONFIG_H
32# include "config.h"
33#endif
34
35#include <stdio.h>
36#include <stdlib.h>
37#include <string.h>
38
39#include <mLib/dstr.h>
40
41#include "au.h"
42#include "aunum.h"
43#include "err.h"
44
45/*----- Main code ---------------------------------------------------------*/
46
47/* --- @auerr@ --- *
48 *
49 * Arguments: @int ctx@ = context code
50 * @int reason@ = reason code
51 * @unsigned long err@ = error code
52 *
53 * Returns: ---
54 *
55 * Use: Reports an error to the audio output.
56 */
57
58void auerr(int ctx, int reason, unsigned long err)
59{
60 dstr d = DSTR_INIT;
61
62 dstr_putf(&d, "%d", ctx);
63 if (reason)
64 dstr_putf(&d, "-%d", reason);
65 if (err)
66 dstr_putf(&d, "-%lu", err);
67 if (!au_tryplay(d.buf))
68 goto done;
69
70 au_play("e-error");
71 au_play("e-ctx"); aunum_ulong(ctx);
72 if (reason) { au_play("e-reason"); aunum_ulong(reason); }
73 if (err) { au_play("e-code"); aunum_ulong(err); }
74
75done:
76 dstr_destroy(&d);
77}
78
79/* --- @auerr_abort@ --- *
80 *
81 * Arguments: @int reason@ = abort reason code
82 * @unsigned long err@ = error code
83 *
84 * Returns: ---
85 *
86 * Use: Reports an abort message to te audio output.
87 */
88
89void auerr_abort(int reason, unsigned long err)
90{
91 au_play("e-abort");
92 au_play("e-reason"); aunum_ulong(reason);
93 au_play("e-code"); aunum_ulong(err);
94}
95
96/*----- That's all, folks -------------------------------------------------*/