ref: 4a47abb5a2a4560924523383bb05e88c52797a7a
parent: 2c40db71bb9507b0b549e3208f01f978d6ce9b6a
author: robs <robs>
date: Sun May 13 02:30:08 EDT 2007
Clean-ups.
--- a/src/misc.c
+++ b/src/misc.c
@@ -533,6 +533,14 @@
return result;
}
+enum_item const * find_enum_value(int value, enum_item const * enum_items)
+{
+ for (;enum_items->text; ++enum_items)
+ if (value == enum_items->value)
+ return enum_items;
+ return NULL;
+}
+
enum_item const sox_wave_enum[] = {
ENUM_ITEM(SOX_WAVE_,SINE)
ENUM_ITEM(SOX_WAVE_,TRIANGLE)
--- a/src/sox_i.h
+++ b/src/sox_i.h
@@ -50,6 +50,8 @@
#define range_limit(x, lower, upper) (min(max(x, lower), upper))
+#define sqr(a) ((a) * (a))
+
/* Array-length operator */
#define array_length(a) (sizeof(a)/sizeof(a[0]))
@@ -58,6 +60,7 @@
#define ENUM_ITEM(prefix, item) {#item, prefix##item},
enum_item const * find_enum_text(
char const * text, enum_item const * enum_items);
+enum_item const * find_enum_value(int value, enum_item const * enum_items);
typedef enum {SOX_SHORT, SOX_INT, SOX_FLOAT, SOX_DOUBLE} sox_data_t;
typedef enum {SOX_WAVE_SINE, SOX_WAVE_TRIANGLE} sox_wave_t;
extern enum_item const sox_wave_enum[];