+ for (i=0; styles[i].id != NULL; i++)
+ {
+ if (strcmp (name, gettext (backends[i].name)) == 0)
+ {
+ return i;
+ }
+ }
+
+ g_message( "Unknown barcode name \"%s\"", name );
+ return 0;
+}
+
+
+/*---------------------------------------------------------------------------*/
+/* Convert style id to index into styles table. */
+/*---------------------------------------------------------------------------*/
+static gint
+style_id_to_index (const gchar *backend_id,
+ const gchar *id)
+{
+ gint i;
+
+ if (backend_id == NULL)
+ {
+ return 0; /* NULL request default. I.e., the first element. */
+ }
+
+ if (id == NULL)
+ {
+ /* Search for first element with given backend_id. */
+ for (i=0; styles[i].id != NULL; i++)
+ {
+ if (g_ascii_strcasecmp (backend_id, styles[i].backend_id) == 0)
+ {
+ return i;
+ }
+ }
+ g_message( "Unknown barcode backend id \"%s\"", backend_id );
+ return 0;
+ }
+
+ for (i=0; styles[i].id != NULL; i++)
+ {
+ if ((g_ascii_strcasecmp (backend_id, styles[i].backend_id) == 0) &&
+ (g_ascii_strcasecmp (id, styles[i].id) == 0))
+ {
+ return i;
+ }
+ }
+
+ g_message( "Unknown barcode id \"%s\"", id );
+ return 0;
+}
+
+
+/*---------------------------------------------------------------------------*/
+/* Convert style name to index into styles table. */
+/*---------------------------------------------------------------------------*/
+static gint
+style_name_to_index (const gchar *backend_id,
+ const gchar *name)
+{
+ gint i;
+
+ if (backend_id == NULL)
+ {
+ return 0; /* NULL request default. I.e., the first element. */
+ }
+
+ if (name == NULL)
+ {
+ /* Search for first element with given backend_id. */
+ for (i=0; styles[i].id != NULL; i++)
+ {
+ if (g_ascii_strcasecmp (backend_id, styles[i].backend_id) == 0)
+ {
+ return i;
+ }
+ }
+ g_message( "Unknown barcode backend id \"%s\"", backend_id );
+ return 0;
+ }
+
+ for (i=0; styles[i].id != NULL; i++)
+ {
+ if ((g_ascii_strcasecmp (backend_id, styles[i].backend_id) == 0) &&
+ (strcmp (name, gettext (styles[i].name)) == 0))
+ {