mirror of
http://mpg123.de/trunk/.git
synced 2025-10-25 04:37:34 +03:00
These got some new-style debugging through the terminal control bug hunt.
Also, I want to take the chance to hint at scripts/debugdef.pl that I added previously:
It is a Perl script generating the debug.h header in a way to avoid variadic macros for fprintf.
Result are debugN macros that mean "debug line with N arguments". Examples:
debug1("Ok, there's one value: %i", var)
debug3("now three of them: %i %f %i", var1, var2, var3)
simplest case:
debug("just a message");
git-svn-id: svn://scm.orgis.org/mpg123/trunk@176 35dc7657-300d-0410-a2e5-dc2837fedb53
This commit is contained in:
@@ -9,14 +9,10 @@
|
|||||||
* Fri Dec 23, 2005
|
* Fri Dec 23, 2005
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "debug.h"
|
||||||
#include "getlopt.h"
|
#include "getlopt.h"
|
||||||
|
|
||||||
/* #define GLO_DEBUG */
|
|
||||||
|
|
||||||
#ifdef GLO_DEBUG
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int loptind = 1; /* index in argv[] */
|
int loptind = 1; /* index in argv[] */
|
||||||
int loptchr = 0; /* index in argv[loptind] */
|
int loptchr = 0; /* index in argv[loptind] */
|
||||||
char *loptarg; /* points to argument if present, else to option */
|
char *loptarg; /* points to argument if present, else to option */
|
||||||
@@ -57,30 +53,22 @@ int performoption (int argc, char *argv[], topt *opt)
|
|||||||
if (opt->var) {
|
if (opt->var) {
|
||||||
if (opt->flags & GLO_CHAR) /* var is *char */
|
if (opt->flags & GLO_CHAR) /* var is *char */
|
||||||
{
|
{
|
||||||
#ifdef GLO_DEBUG
|
debug1("char at %p", opt->var);
|
||||||
fprintf(stderr, "[char at %ld]\n", opt->var);
|
|
||||||
#endif
|
|
||||||
*((char *) opt->var) = (char) opt->value;\
|
*((char *) opt->var) = (char) opt->value;\
|
||||||
}
|
}
|
||||||
else if(opt->flags & GLO_LONG)
|
else if(opt->flags & GLO_LONG)
|
||||||
{
|
{
|
||||||
#ifdef GLO_DEBUG
|
debug1("long at %p", opt->var);
|
||||||
fprintf(stderr, "[long at %ld]\n", opt->var);
|
|
||||||
#endif
|
|
||||||
*( (long *) opt->var ) = opt->value;
|
*( (long *) opt->var ) = opt->value;
|
||||||
}
|
}
|
||||||
else if(opt->flags & GLO_INT)
|
else if(opt->flags & GLO_INT)
|
||||||
{
|
{
|
||||||
#ifdef GLO_DEBUG
|
debug1("int at %p", opt->var);
|
||||||
fprintf(stderr, "[int at %ld]\n", opt->var);
|
|
||||||
#endif
|
|
||||||
*( (int *) opt->var ) = (int) opt->value;
|
*( (int *) opt->var ) = (int) opt->value;
|
||||||
}
|
}
|
||||||
#ifdef GLO_DEBUG
|
else debug("Option without type flag! This is a programming error!");
|
||||||
else fprintf(stderr, "[Option without type flag! This is a programming error!]\n");
|
|
||||||
|
|
||||||
fprintf(stderr,"[dubious assignment done]\n");
|
debug("casting assignment done");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
result = opt->value ? opt->value : opt->sname;
|
result = opt->value ? opt->value : opt->sname;
|
||||||
@@ -97,9 +85,7 @@ int performoption (int argc, char *argv[], topt *opt)
|
|||||||
*((long *) opt->var) = atol(loptarg);
|
*((long *) opt->var) = atol(loptarg);
|
||||||
else if(opt->flags & GLO_INT)
|
else if(opt->flags & GLO_INT)
|
||||||
*((int *) opt->var) = atoi(loptarg);
|
*((int *) opt->var) = atoi(loptarg);
|
||||||
#ifdef GLO_DEBUG
|
else debug("Option without type flag! This is a programming error!");
|
||||||
else fprintf(stderr, "[Option without type flag! This is a programming error!]\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
result = opt->value ? opt->value : opt->sname;
|
result = opt->value ? opt->value : opt->sname;
|
||||||
@@ -118,9 +104,7 @@ int getsingleopt (int argc, char *argv[], topt *opts)
|
|||||||
if (loptind >= argc)
|
if (loptind >= argc)
|
||||||
return (GLO_END);
|
return (GLO_END);
|
||||||
thisopt = argv[loptind];
|
thisopt = argv[loptind];
|
||||||
#ifdef GLO_DEBUG
|
debug1("getsingleopt: %s", thisopt);
|
||||||
fprintf(stderr,"[getsingleopt: %s]\n", thisopt);
|
|
||||||
#endif
|
|
||||||
if (!loptchr) { /* start new option string */
|
if (!loptchr) { /* start new option string */
|
||||||
if (thisopt[0] != '-' || !thisopt[1]) /* no more options */
|
if (thisopt[0] != '-' || !thisopt[1]) /* no more options */
|
||||||
return (GLO_END);
|
return (GLO_END);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef HAVE_TERMIOS
|
#ifdef HAVE_TERMIOS
|
||||||
|
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
@@ -9,6 +8,7 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
#include "mpg123.h"
|
#include "mpg123.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "term.h"
|
#include "term.h"
|
||||||
@@ -23,6 +23,7 @@ static struct termios old_tio;
|
|||||||
void term_init(void)
|
void term_init(void)
|
||||||
{
|
{
|
||||||
struct termios tio;
|
struct termios tio;
|
||||||
|
debug("term_init");
|
||||||
|
|
||||||
term_enable = 0;
|
term_enable = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user