Ejemplo n.º 1
0
/*
 * this is for Georg's accent levels:
 * unaccented : FALSE
 * accented   : TRUE
 */
static s_bool syl_is_accented(const SItem *syl, s_erc *error)
{
	const char *accent_feat;


	S_CLR_ERR(error);
	accent_feat = SItemGetString(syl, "accent", error);
	if (S_CHK_ERR(error, S_CONTERR,
					"syl_is_accented",
					"Call to \"SItemGetString\" failed"))
		return FALSE;

	if (s_strcmp(accent_feat, "unaccented", error) == 0)
	{
		S_CHK_ERR(error, S_CONTERR,
				  "syl_is_accented",
				  "Call to \"s_strcmp\" failed");
		return FALSE;
	}

	if (s_strcmp(accent_feat, "accented", error) == 0)
	{
		if (S_CHK_ERR(error, S_CONTERR,
					  "syl_is_accented",
					  "Call to \"s_strcmp\" failed"))
			return FALSE;

		return TRUE;
	}

	return FALSE; /* unknown */
}
Ejemplo n.º 2
0
static s_bool CompareVoid(const SObject *Sv1, const SObject *Sv2, s_erc *error)
{
    const SVoid *s1;
    const SVoid *s2;
    int rv;


    S_CLR_ERR(error);

    /* type is checked by SObjectCompare */
    s1 = (SVoid*)Sv1;
    s2 = (SVoid*)Sv2;

    /* check type_name */
    rv = s_strcmp(s1->type_name, s2->type_name, error);
    if (S_CHK_ERR(error, S_CONTERR,
                  "CompareVoid",
                  "Call to \"s_strcmp\" failed"))
        return FALSE;

    if (rv != 0)
        return FALSE;

    if (s1->ptr != s2->ptr)
        return FALSE;

    return TRUE;
}
Ejemplo n.º 3
0
/*
 * Content word's "cat" feature is 'content'
 */
static s_bool word_is_content(const SItem *word, s_erc *error)
{
	const char *cat_feat;
	s_bool comp;


	S_CLR_ERR(error);
	cat_feat = SItemGetString(word, "cat", error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "word_is_content",
				  "Call to \"SItemGetString\" failed"))
		return FALSE;


	comp = s_strcmp(cat_feat, "content", error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "syl_is_stressed",
				  "Call to \"s_strcmp\" failed"))
		return FALSE;

	if (comp == 0)
		return TRUE;

	return FALSE; /* not content word */
}
Ejemplo n.º 4
0
int property_get( char *name, char *val )
{
	char buf[96];
	int line_no = 0;
	int kc;
	char *ki[15];
	int rel = -1;
	while(1){
		if( txt_file_read_line( g_property_file_name, line_no++, buf, sizeof( buf ) ) < 0 )
			break;
		kc = analysis_string_to_strings_by_decollator( buf, "=", ki, 15 );
		if( kc !=2 )
			continue;
		if( s_strcmp( ki[0], name ) == 0 ){
			//int len;
			strncpy( buf, ki[1], sizeof(buf) );
			rel = 0;
			s_chop( buf );
			if( val )
				strcpy( val, buf );
			return 1;
		}
	}
	return 0;
}
Ejemplo n.º 5
0
int property_set( char *name, char *val )
{
	char buf[96];
	int line_no = 0;
	int kc;
	char *ki[15];
	int tf, f;
	char *t_property_file_name = "/tmp_perperty.tr";
	int new_key = 1;

	f = uffs_open( g_property_file_name, UO_RDONLY );
	if( f == -1 ){
		f = uffs_open( g_property_file_name, UO_RDWR|UO_CREATE );
		if( f == -1 )
			return -1;
	}
	tf = uffs_open( t_property_file_name, UO_WRONLY|UO_CREATE );
	if( tf == -1 ){
		uffs_close( f );
		return -1;
	}
	while(1){
		if( uffs_read_line( f, buf, sizeof( buf ) ) < 0 )
			break;
		kc = analysis_string_to_strings_by_decollator( buf, "=", ki, 15 );
		if( kc !=2 )
			continue;
		if( s_strcmp( ki[0], name ) == 0 ){
			//int len;
			//strncpy( buf, &ki[1], sizeof(buf) );
			if( new_key == 0 )
				continue;
			sprintf( buf, "%s=%s\n", name, val );
			new_key = 0;
		}
		else	strcat( buf, "\n" );
		uffs_write( tf, buf, strlen( buf ) );
	}
	if( new_key == 1 ){
		uffs_close( tf );
		uffs_close( f );
		f = uffs_open( g_property_file_name, UO_RDWR|UO_CREATE );
		if( f == -1 )
			return -1;
		uffs_seek( f, 0, _SEEK_END );
		sprintf( buf, "%s=%s\n", name, val );
		uffs_write( f, buf, strlen( buf ) );
		uffs_close( f );
	}
	else{
		uffs_close( tf );
		uffs_close( f );
		uffs_remove( g_property_file_name );
		uffs_rename( t_property_file_name, g_property_file_name );
	}
	return 0;
}
Ejemplo n.º 6
0
static s_bool _item_match(const char *PATT, const char *THING, const SMap *sets,
						  s_erc *error)
{
	int rv;
	s_bool is_present;
	const SObject *tmp;
	const SList *setList;
	SObject *thingObject;

	S_CLR_ERR(error);
	rv = s_strcmp(PATT, THING, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "_item_match",
				  "Call to \"s_strcmp\" failed"))
		return FALSE;

	if (rv == 0)
		return TRUE;

	if (sets == NULL)
		return FALSE;

	tmp = SMapGetObjectDef(sets, PATT, NULL, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "_item_match",
				  "Call to \"SMapGetObjectDef\" failed"))
		return FALSE;

	if (tmp == NULL)
		return FALSE;

	setList = S_CAST(tmp, SList, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "_item_match",
				  "Call to \"S_CAST(SList)\" failed"))
		return FALSE;

	thingObject = SObjectSetString(THING, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "_item_match",
				  "Call to \"SObjectSetString\" failed"))
		return FALSE;

	is_present = SListValPresent(setList, thingObject, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "_item_match",
				  "Call to \"SListValPresent\" failed"))
	{
		S_DELETE(thingObject, "_item_match", error);
		return FALSE;
	}

	S_DELETE(thingObject, "_item_match", error);
	return is_present;
}
Ejemplo n.º 7
0
/*
 * this is for Georg's stress levels:
 * unstressed : FALSE
 * primary    : TRUE
 * secondary  : TRUE
 */
static s_bool syl_is_stressed(const SItem *syl, s_erc *error)
{
	const char *stress_feat;


	S_CLR_ERR(error);
	stress_feat = SItemGetString(syl, "stress", error);
	if (S_CHK_ERR(error, S_CONTERR,
					"syl_is_stressed",
					"Call to \"SItemGetString\" failed"))
		return FALSE;

	if (s_strcmp(stress_feat, "unstressed", error) == 0)
	{
		S_CHK_ERR(error, S_CONTERR,
				  "syl_is_stressed",
				  "Call to \"s_strcmp\" failed");
		return FALSE;
	}

	if (s_strcmp(stress_feat, "primary", error) == 0)
	{
		if (S_CHK_ERR(error, S_CONTERR,
					  "syl_is_stressed",
					  "Call to \"s_strcmp\" failed"))
			return FALSE;

		return TRUE;
	}

	if (s_strcmp(stress_feat, "secondary", error) == 0)
	{
		if (S_CHK_ERR(error, S_CONTERR,
					  "syl_is_stressed",
					  "Call to \"s_strcmp\" failed"))
			return FALSE;

		return TRUE;
	}

	return FALSE; /* unknown */
}
Ejemplo n.º 8
0
S_API const void *SObjectGetVoid(const SObject *self,
                                 const char *type_name,
                                 s_erc *error)
{
    s_bool type_is_good;
    int rv;


    S_CLR_ERR(error);

    if (self == NULL)
    {
        S_CTX_ERR(error, S_ARGERROR,
                  "SObjectGetVoid",
                  "Argument \"self\" is NULL");
        return NULL;
    }

    type_is_good = SObjectIsType(self, "SVoid", error);
    if (S_CHK_ERR(error, S_CONTERR,
                  "SObjectGetVoid",
                  "Call to \"SObjectIsType\" failed"))
        return NULL;

    if (type_is_good == FALSE)
    {
        S_CTX_ERR(error, S_FAILURE,
                  "SObjectGetVoid",
                  "Given object not of type SVoid");
        return NULL;
    }

    rv = s_strcmp(((SVoid*)self)->type_name, type_name, error);
    if (S_CHK_ERR(error, S_CONTERR,
                  "SObjectGetVoid",
                  "Call to \"s_strcmp\" failed"))
        return NULL;

    if (rv != 0)
    {
        S_CTX_ERR(error, S_FAILURE,
                  "SObjectGetVoid",
                  "Type mismatch, object is of type \'%s\' and not \'%s\'",
                  ((SVoid*)self)->type_name, type_name);
        return NULL;
    }

    return ((SVoid*)self)->ptr;
}
Ejemplo n.º 9
0
static float get_end(const SItem *item, const char *relname, s_erc *error)
{
	const s_relation_time *i;
	get_item_time end_func = NULL;
	int cmp;
	float end = 0.0;


	S_CLR_ERR(error);
	i = rt;
	while (i->name != NULL)
	{
		cmp = s_strcmp(relname, i->name, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "get_end",
					  "Call to \"s_strcmp\" failed"))
			return 0.0;

		if (cmp == 0)
		{
			end_func = i->end_func;
			break;
		}

		i++;
	}

	if (end_func == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "get_end",
				  "Failed to find end function of relation \"%s\"", relname);
		return 0.0;
	}

	end = (end_func)(item, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "get_end",
				  "Call to \"end_func\" of relation \"%s\" failed", relname))
		return 0.0;

	return end;
}
Ejemplo n.º 10
0
/* required for s_list to compare two elements */
static s_bool s_str_list_compare_fp(const void *le1, const void *le2, s_erc *error)
{
	const char *str1 = le1;
	const char *str2 = le2;
	int rv;


	S_CLR_ERR(error);
	if ((str1 == NULL) || (str2 == NULL))
		return FALSE;

	rv = s_strcmp(str1, str2, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "s_str_list_compare_fp",
				  "Call to \"s_strcmp\" failed"))
		return FALSE;

	if (rv == 0)
		return TRUE;

	return FALSE;
}
Ejemplo n.º 11
0
/*
 * named "CompareStrings" because win32 makes it "CompareStringA"
 * which clashes with a winnls.h function.
 */
static s_bool CompareStrings(const SObject *Sv1, const SObject *Sv2, s_erc *error)
{
    const char *s1;
    const char *s2;
    int rv;


    S_CLR_ERR(error);

    s1 = ((SString*)Sv1)->s;
    s2 = ((SString*)Sv2)->s;

    rv = s_strcmp(s1, s2, error);
    if (S_CHK_ERR(error, S_FAILURE,
                  "CompareString",
                  "Call to \"s_strcmp\" failed"))
        return FALSE;

    if (rv != 0)
        return FALSE;

    return TRUE;
}
Ejemplo n.º 12
0
int main()
{
	s_erc error;
	SDatasource *ds = NULL;
	SPlugin *plugin = NULL;
	const char *doc_type = "spct_ebml_test";
	SEbmlRead *ebmlReader = NULL;
	int rv;


	S_CLR_ERR(&error);

	/*
	 * initialize speect
	 */
	error = speect_init(NULL);
	if (error != S_SUCCESS)
	{
		printf("Failed to initialize Speect\n");
		return 1;
	}

	/*
	 * load the ebml plug-in
	 */
	plugin = s_pm_load_plugin("ebml.spi", &error);
	if (S_CHK_ERR(&error, S_CONTERR,
				  "main",
				  "Failed to load plug-in at 'ebml.spi'"))
	{
		printf("failed to load plug-in\n");
		goto quit;
	}
	else
	{
		printf("plug-in loaded\n");
	}


	/*
	 * create a data source, "rb" = read, binary
	 */
	ds = SFilesourceOpenFile("ebml_test.bin", "rb", &error);
	if (S_CHK_ERR(&error, S_CONTERR,
				  "main",
				  "Failed to create data source 'ebml_test.bin'"))
	{
		printf("failed to create data source\n");
		goto quit;
	}
	else
	{
		printf("data source created\n");
	}

	/*
	 * create ebml reader object
	 */
	ebmlReader = S_NEW(SEbmlRead, &error);
	if (S_CHK_ERR(&error, S_CONTERR,
				  "main",
				  "Failed to create new SEbmlRead object"))
	{
		printf("failed to create SEbmlRead object\n");
		goto quit;
	}
	else
	{
		printf("created SEbmlRead object\n");
	}

	/*
	 * initialize ebml reader object
	 */
	if (S_EBMLREAD_METH_VALID(ebmlReader, read_init))
	{
		S_EBMLREAD_CALL(ebmlReader, read_init)(&ebmlReader, ds, &error);
		if (S_CHK_ERR(&error, S_CONTERR,
					  "main",
					  "Failed to initialize SEbmlRead object"))
		{
			printf("failed to initialize SEbmlRead object\n");
			goto quit;
		}
		else
		{
			printf("initialized SEbmlRead object\n");

			/*
			 * ebml reader takes hold of the data source, we dont want
			 * a reference to it anymore (for quit to work).
			 */
			ds = NULL;
		}
	}
	else
	{
		S_CTX_ERR(&error, S_METHINVLD,
				  "main",
				  "EbmlRead method \"read_init\" not implemented");
		printf("cannot do read_init\n");
		goto quit;
	}

	/*
	 * verify doc_type
	 */
	rv = s_strcmp(ebmlReader->header->doctype, doc_type, &error);
	if (S_CHK_ERR(&error, S_CONTERR,
				  "main",
				  "Failed to compare doc_type's"))
	{
		printf("failed to compare document types\n");
		goto quit;
	}

	if (rv != 0)
	{
		printf("document types differ\n");
		goto quit;
	}
	else
	{
		printf("document types are good\n");
	}

	/*
	 * Open container
	 */
	if (S_EBMLREAD_METH_VALID(ebmlReader, container))
	{
		uint32 id;

		id = S_EBMLREAD_CALL(ebmlReader, container)(ebmlReader, &error);
		if (S_CHK_ERR(&error, S_CONTERR,
					  "main",
					  "Failed to open ebml container"))
		{
			printf("failed to open container\n");
			goto quit;
		}
		else
		{
			printf("container opened with id %d, should be %d\n", id, 129);
		}
	}


	/*
	 * Read a few unsigned int values
	 */
	if (S_EBMLREAD_METH_VALID(ebmlReader, read_uint))
	{
		uint32 val;
		uint32 id;

		val = S_EBMLREAD_CALL(ebmlReader, read_uint)(ebmlReader, &id, &error);
		if (S_CHK_ERR(&error, S_CONTERR,
					  "main",
					  "Failed to read uint [%d]", 234))
		{
			printf("failed to read uint [%d]\n", 234);
			goto quit;
		}
		else
		{
			printf("read uint [%d] with id %d (should be %d and id %d)\n",
				   val, id, 234, 130);
		}

		val = S_EBMLREAD_CALL(ebmlReader, read_uint)(ebmlReader, &id, &error);
		if (S_CHK_ERR(&error, S_CONTERR,
					  "main",
					  "Failed to read uint [%d]", 31234))
		{
			printf("failed to read uint [%d]\n", 31234);
			goto quit;
		}
		else
		{
			printf("read uint [%d] with id %d (should be %d and id %d)\n",
				   val, id, 31234, 130);
		}
	}

	/*
	 * Read a few signed int values
	 */
	if (S_EBMLREAD_METH_VALID(ebmlReader, read_sint))
	{
		sint32 val;
		uint32 id;

		val = S_EBMLREAD_CALL(ebmlReader, read_sint)(ebmlReader, &id, &error);
		if (S_CHK_ERR(&error, S_CONTERR,
					  "main",
					  "Failed to read sint [%d]", -69))
		{
			printf("failed to read sint [%d]\n", -69);
			goto quit;
		}
		else
		{
			printf("read sint [%d] with id %d (should be %d, and id %d)\n",
				   val, id, -69, 131);
		}

		val = S_EBMLREAD_CALL(ebmlReader, read_sint)(ebmlReader, &id, &error);
		if (S_CHK_ERR(&error, S_CONTERR,
					  "main",
					  "Failed to read sint [%d]", -132769))
		{
			printf("failed to read sint [%d]\n", -132769);
			goto quit;
		}
		else
		{
			printf("read sint [%d] with id %d (should be %d, and id %d)\n",
				   val, id, -132769, 131);
		}
	}

	/*
	 * Open container
	 */
	if (S_EBMLREAD_METH_VALID(ebmlReader, container))
	{
		uint32 id;

		id = S_EBMLREAD_CALL(ebmlReader, container)(ebmlReader, &error);
		if (S_CHK_ERR(&error, S_CONTERR,
					  "main",
					  "Failed to open ebml container"))
		{
			printf("failed to open container\n");
			goto quit;
		}
		else
		{
			printf("container opened with id %d, should be %d\n", id, 132);
		}
	}

	/*
	 * Read some floats
	 */
	if (S_EBMLREAD_METH_VALID(ebmlReader, read_float))
	{
		float val;
		uint32 id;

		val = S_EBMLREAD_CALL(ebmlReader, read_float)(ebmlReader, &id, &error);
		if (S_CHK_ERR(&error, S_CONTERR,
					  "main",
					  "Failed to read float [%f]", 20.343))
		{
			printf("failed to read float [%f]\n", 20.343);
			goto quit;
		}
		else
		{
			printf("read float [%f] with id %d (should be %f and id %d)\n",
				   val, id, 20.343, 133);
		}

		val = S_EBMLREAD_CALL(ebmlReader, read_float)(ebmlReader, &id, &error);
		if (S_CHK_ERR(&error, S_CONTERR,
					  "main",
					  "Failed to read float [%f]", -12320.7603))
		{
			printf("failed to read float [%f]\n", -12320.7603);
			goto quit;
		}
		else
		{
			printf("read float [%f] with id %d (should be %f and id %d)\n",
				   val, id, -12320.7603, 133);
		}
	}

	/*
	 * Read some doubles
	 */
	if (S_EBMLREAD_METH_VALID(ebmlReader, read_double))
	{
		double val;
		uint32 id;

		val = S_EBMLREAD_CALL(ebmlReader, read_double)(ebmlReader, &id, &error);
		if (S_CHK_ERR(&error, S_CONTERR,
					  "main",
					  "Failed to read double [%f]", -3.145343234223321))
		{
			printf("failed to read double [%f]\n", -3.145343234223321);
			goto quit;
		}
		else
		{
			printf("read double [%f] with id %d (should be %f and id %d)\n",
				   val, id, -3.145343234223321, 134);
		}

		val = S_EBMLREAD_CALL(ebmlReader, read_double)(ebmlReader, &id, &error);
		if (S_CHK_ERR(&error, S_CONTERR,
					  "main",
					  "Failed to read double [%f]", 533.145343234223321145343234223321))
		{
			printf("failed to read double [%f]\n", 533.145343234223321145343234223321);
			goto quit;
		}
		else
		{
			printf("read double [%f] with id %d (should be %f and id %d)\n",
				   val, id, 533.145343234223321145343234223321, 134);
		}
	}

	/*
	 * Check that container is at end
	 */
	if (S_EBMLREAD_METH_VALID(ebmlReader, container_at_end))
	{
		s_bool at_end;

		at_end = S_EBMLREAD_CALL(ebmlReader, container_at_end)(ebmlReader, &error);
		if (S_CHK_ERR(&error, S_CONTERR,
					  "main",
					  "Failed to check if container is at end"))
		{
			printf("failed to check if container is at end\n");
			goto quit;
		}

		if (at_end)
		{
			printf("found container at end (correct)\n");
		}
		else
		{
			printf("container not at end, error\n");
			goto quit;
		}
	}


	/*
	 * Read some ascii
	 */
	if (S_EBMLREAD_METH_VALID(ebmlReader, read_ascii))
	{
		char *val;
		uint32 id;

		val = S_EBMLREAD_CALL(ebmlReader, read_ascii)(ebmlReader, &id, &error);
		if (S_CHK_ERR(&error, S_CONTERR,
					  "main",
					  "Failed to read ascii [%s]", "hello world"))
		{
			printf("Failed to read ascii [%s]\n", "hello world");
			goto quit;
		}
		else
		{
			printf("read ascii [%s] with id %d (should be 'hello world' and id %d)\n",
				   val, id, 135);
			S_FREE(val);
		}
	}


	/*
	 * Read some utf8
	 */
	if (S_EBMLREAD_METH_VALID(ebmlReader, read_utf8))
	{
		char *val;
		uint32 id;

		val = S_EBMLREAD_CALL(ebmlReader, read_utf8)(ebmlReader, &id, &error);
		if (S_CHK_ERR(&error, S_CONTERR,
					  "main",
					  "Failed to read utf8 [%s]", "hello world in Japanese"))
		{
			printf("Failed to read utf8 [%s]", "hello world in Japanese");
			goto quit;
		}
		else
		{
			printf("read utf8 [%s] with id %d (should be 'hello world in Japanese: ハロー世界' and id %d)\n",
				   val, id, 136);
			S_FREE(val);
		}
	}

	/*
	 * Check that container is at end
	 */
	if (S_EBMLREAD_METH_VALID(ebmlReader, container_at_end))
	{
		s_bool at_end;

		at_end = S_EBMLREAD_CALL(ebmlReader, container_at_end)(ebmlReader, &error);
		if (S_CHK_ERR(&error, S_CONTERR,
					  "main",
					  "Failed to check if container is at end"))
		{
			printf("failed to check if container is at end\n");
			goto quit;
		}

		if (at_end)
		{
			printf("found container at end (correct)\n");
		}
		else
		{
			printf("container not at end, error\n");
			goto quit;
		}
	}


	/*
	 * quit
	 */
quit:
	if (ds != NULL)
		S_DELETE(ds, "main", &error);

	if (ebmlReader != NULL)
		S_DELETE(ebmlReader, "main", &error);

	/* must be after ebmlReader */
	if (plugin != NULL)
		S_DELETE(plugin, "main", &error);

	/*
	 * quit speect
	 */
	error = speect_quit();
	if (error != S_SUCCESS)
	{
		printf("Call to 'speect_quit' failed\n");
		return 1;
	}


	return 0;
}
Ejemplo n.º 13
0
S_LOCAL SUtterance *s_read_utt_ebml(SDatasource *ds, s_erc *error)
{
	SUtterance *utt = NULL;
	SEbmlRead *ebmlReader = NULL;
	s_hash_table *items_content_table = NULL;
	uint32 id;
	int scomp;
	s_bool container_exhausted;


	S_CLR_ERR(error);

	/* create and initialize ebml reader */
	ebmlReader = S_NEW(SEbmlRead, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "s_read_utt_ebml",
				  "Failed to create new SEbmlRead object"))
		goto quit_error;

	S_EBMLREAD_CALL(ebmlReader, read_init)(&ebmlReader, ds, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "s_read_utt_ebml",
				  "Failed to initialize SEbmlRead object"))
		goto quit_error;

	/* check that we have the correct doc type */
	scomp = s_strcmp(ebmlReader->header->doctype, "spct_utt", error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "s_read_utt_ebml",
				  "Call to \"s_strcmp\" failed"))
		goto quit_error;

	if (scomp != 0)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "s_read_utt_ebml",
				  "Ebml file format not of type 'spct_utt', read format is '%s'",
				  ebmlReader->header->doctype);
		goto quit_error;
	}

	/* create and initialize new utterance */
	utt = S_NEW(SUtterance, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "s_read_utt_ebml",
				  "Failed to create new utterance"))
		goto quit_error;

	SUtteranceInit(&utt, NULL, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "s_read_utt_ebml",
				  "Failed to initialize new utterance"))
		goto quit_error;

	/* read top level container */
	id = S_EBMLREAD_CALL(ebmlReader, container)(ebmlReader, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "s_read_utt_ebml",
				  "ebmlRead method \"container\" failed"))
		goto quit_error;

	/* sanity check id */
	S_EBML_ID_SANITY(id, S_UTT_EBML,
				"s_read_utt_ebml",
				"ID mismatch", error);

	while (1)
	{
		container_exhausted = S_EBMLREAD_CALL(ebmlReader, container_at_end)(ebmlReader, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "s_read_utt_ebml",
					  "ebmlRead method \"container_at_end\" failed"))
			goto quit_error;

		if (container_exhausted)
			break; /* we are finished reading the utterance file */

		/* peek id for utterance elements */
		id = S_EBMLREAD_CALL(ebmlReader, peek_id)(ebmlReader, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "s_read_utt_ebml",
					  "ebmlRead method \"peek_id\" failed"))
			goto quit_error;

		switch(id)
		{
		case S_UTT_EBML_FEATURES:
		{
			read_utt_features(utt, ebmlReader, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "s_read_utt_ebml",
						  "Call to \"read_utt_features\" failed"))
				goto quit_error;
			break;
		}
		case S_UTT_EBML_ITEMS_CONTENTS:
		{
			items_content_table = read_item_contents(ebmlReader, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "s_read_utt_ebml",
						  "Call to \"read_item_contents\" failed"))
				goto quit_error;
			break;
		}
		case S_UTT_EBML_RELATIONS:
		{
			read_utt_relations(ebmlReader, utt, items_content_table, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "s_read_utt_ebml",
						  "Call to \"read_utt_relations\" failed"))
				goto quit_error;

			break;
		}
		default:
			/* unknown elements, skip */
			S_WARNING(S_FAILURE,
					  "s_read_utt_ebml",
					  "Skipping element with unknown id '0x%x'",
					  id);

			S_EBMLREAD_CALL(ebmlReader, element_skip)(ebmlReader, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "s_read_utt_ebml",
						  "ebmlRead method \"element_skip\" failed"))
				goto quit_error;
		}
	}

	/* if we get here then everything was OK */
	goto quit;


	/* errors start clean up code here */
quit_error:
	if (utt != NULL)
		S_DELETE(utt, "s_read_utt_ebml", error); /* sets utt = NULL */

	if (items_content_table != NULL)
	{
		s_erc local_err = S_SUCCESS;

		s_hash_table_delete(items_content_table, &local_err);
		items_content_table = NULL;
	}

	/* normal exit start clean up code here */
quit:
	if (items_content_table != NULL)
		delete_unused_items_content(items_content_table, error);

	if (ebmlReader != NULL)
		S_DELETE(ebmlReader, "s_read_utt_ebml", error);

	return utt;
}
Ejemplo n.º 14
0
/* setSentenceType should be made out of two parts:
 * 	    1) the first section searchs for the last punctuation element of the sentence
 * 				-> if it is a '.' --> set "decl" type (where should I set this feature value?)
 * 				-> if it is a '!' --> set "excl" type (where should I set this feature value?)
 * 				-> if it is a '?' --> set "interrog" type (where should I set this feature value?)
 * 	    2) if the first part decides for "interrog" type, there should be other controls
 * 	       to establish the sentence's complete type
 * */
static char* setSentenceType(const SItem *phrase, SMap *prosSymbols, s_erc *error)
{
	S_CLR_ERR(error);

	char* result = "decl";

	/* types: "decl, "excl", "interrog" */
	/* stop at sentence's last token */
	const SItem *wordFromCurrentPhrase = SItemPathToItem(phrase, "daughter", error);
	if (S_CHK_ERR(error, S_CONTERR,
		      "setSentenceType",
		      "Call to \"SItemPathToItem\" failed"))
		return NULL;

	SItem *wordAsToken = SItemAs(wordFromCurrentPhrase, "Token", error);
	if (S_CHK_ERR(error, S_CONTERR,
		      "setSentenceType",
		      "Call to \"SItemAs\" failed"))
		return NULL;

	SItem *tokenItem = SItemParent(wordAsToken, error);
	SItem *firstTokenItem = tokenItem;

	s_bool isPunct = SItemFeatureIsPresent(tokenItem, "IsPunctuation", error);
	if (S_CHK_ERR(error, S_CONTERR,
		      "setSentenceType",
		      "Call to \"SItemFeatureIsPresent\" failed"))
		return NULL;

	s_bool isFinalPunct = FALSE;

	while (isFinalPunct == FALSE)
	{
		isPunct = SItemFeatureIsPresent(tokenItem, "IsPunctuation", error);
		if (S_CHK_ERR(error, S_CONTERR,
			      "setSentenceType",
			      "Call to \"SItemFeatureIsPresent\" failed"))
			return NULL;

		if (isPunct)
		{
			const char *punctStr = SItemGetName(tokenItem, error);
			if (S_CHK_ERR(error, S_CONTERR,
				      "setSentenceType",
				      "Call to \"SItemGetName\" failed"))
				return NULL;

			if (s_strcmp(punctStr, ".", error) == 0)
			{
				isFinalPunct = TRUE;
				result = "decl";
			}
			else if (s_strcmp(punctStr, "!", error) == 0)
			{
				isFinalPunct = TRUE;
				result = "excl";
			}
			else if (s_strcmp(punctStr, "?", error) == 0)
			{
				isFinalPunct = TRUE;
				const char *posValueStr = NULL;
				char *posValueStr_filtered = NULL;
				s_bool currPosInCurrList;
				s_bool have_symbols = FALSE;
				SMap* valueMap = NULL;

				have_symbols = SMapObjectPresent(prosSymbols, "firstPosInQuestionW", error);
				if (S_CHK_ERR(error, S_CONTERR,
					      "SetSentenceType",
					      "Call to \"SMapObjectPresent\" failed"))
					goto quit_error;

				if (have_symbols)
				{
					valueMap = S_CAST(SMapGetObject(prosSymbols, "firstPosInQuestionW", error), SMap, error);
					if (S_CHK_ERR(error, S_CONTERR,
						      "SetSentenceType",
						      "Call to \"SMapGetObject\" failed"))
						goto quit_error;
				}
				else
					goto quit_error;

				posValueStr = SItemGetString(firstTokenItem, "POS", error);
				if (S_CHK_ERR(error, S_CONTERR,
					      "SetSentenceType",
					      "Call to \"SItemGetString\" failed"))
					goto quit_error;

				/* filter the current POS tag, remember to free the memory
				 *  pointed to by 'posValueStr_filtered' pointer
                                 */
				posValueStr_filtered = filterPosTag(posValueStr, error);
				if (S_CHK_ERR(error, S_CONTERR,
					      "SetSentenceType",
					      "Call to \"filterPosTag\" failed"))
					goto quit_error;

				currPosInCurrList = searchStringMap(valueMap, posValueStr_filtered, error);
				if (currPosInCurrList == TRUE)
				{
					result = "interrogW";
				}
				else
				{
					result = "interrog";
				}
				quit_error:
					if (posValueStr_filtered)
					{
						S_FREE(posValueStr_filtered);
					}
					break;
			}
		}

		tokenItem = SItemNext(tokenItem, error);
		if (S_CHK_ERR(error, S_CONTERR,
			      "setSentenceType",
			      "Call to \"SItemNext\" failed"))
			return NULL;
		if(tokenItem == NULL) {
			isFinalPunct = TRUE;
		}
	}
	return result;
}
Ejemplo n.º 15
0
/*

    Function:   iSrchFilterProcessTerm()

    Purpose:    This function processes the passed term, stripping the field
                name (if present), setting the field ID bit map if needed
                and stemming the term

    Parameters: pssSrchSearch           search structure
                psiSrchIndex            index structure
                pvLngStemmer            stemmer
                pwcTerm                 term
                pucFieldIDBitmap        field ID bitmap (optional)
                uiFieldIDBitmapLength   field ID bitmap length (optional)
                ppwcTerm                return pointer for the processed term
                pbFieldIDBitmapSet      return flag set to true if the field ID bitmap was set

    Globals:    none

    Returns:    SRCH error code

*/
static int iSrchFilterProcessTerm
(
    struct srchSearch *pssSrchSearch,
    struct srchIndex *psiSrchIndex,
    void *pvLngStemmer,
    wchar_t *pwcTerm,
    unsigned char *pucFieldIDBitmap,
    unsigned int uiFieldIDBitmapLength,
    wchar_t **ppwcTerm,
    boolean *pbFieldIDBitmapSet
)
{

    int             iError = SRCH_NoError;
    unsigned char   pucFieldName[SRCH_INFO_SYMBOL_MAXIMUM_LENGTH + 1] = {'\0'};
    unsigned int    uiFieldID = 0;
    unsigned int    uiFieldOptions = SRCH_INFO_FIELD_OPTION_NONE;
    boolean         bFieldIDBitmapSet = false;
    boolean         bContainsUpperCase = false;
    wchar_t         *pwcPtr = NULL;

    
    ASSERT(pssSrchSearch != NULL);
    ASSERT(psiSrchIndex != NULL);
    ASSERT(pvLngStemmer != NULL);
    ASSERT(bUtlStringsIsStringNULL(pwcTerm) == false);
    ASSERT(((pucFieldIDBitmap == NULL) && (uiFieldIDBitmapLength <= 0)) || ((pucFieldIDBitmap != NULL) && (uiFieldIDBitmapLength > 0)));
    ASSERT(ppwcTerm != NULL);
    ASSERT(pbFieldIDBitmapSet != NULL);


    /* Set the field option defaults */
    iSrchInfoGetFieldOptionDefaults(psiSrchIndex, &uiFieldOptions);


    /* Extract field name if present */
    if ( (bUtlStringsIsWideStringUrl(pwcTerm) == false) && ((pwcPtr = s_wcspbrk(pwcTerm, SRCH_FILTER_FIELD_NAME_SEPARATORS)) != NULL) ) {
        
        wchar_t     *pwcFieldNamePtr = NULL;
    
        /* Set the field name */
        pwcFieldNamePtr = pwcTerm;
        
        /* Set the term */
        pwcTerm = pwcPtr + 1;

        /* Null terminate the field name, separating the term from the field name */
        *pwcPtr = L'\0';

        /* Convert the field name from wide characters to utf-8 */
        if ( (iError = iLngConvertWideStringToUtf8_s(pwcFieldNamePtr, 0, pucFieldName, SRCH_INFO_SYMBOL_MAXIMUM_LENGTH + 1)) != LNG_NoError ) {
            iUtlLogError(UTL_LOG_CONTEXT, "Failed to convert a field name from wide characters to utf-8, lng error: %d.", iError);
            return (SRCH_FilterCharacterSetConvertionFailed);
        }

        /* Look up the field ID for this field */
        if ( (iError = iSrchInfoGetFieldID(psiSrchIndex, pucFieldName, &uiFieldID)) == SRCH_NoError ) {
            
            /* Get the field options, reset them to the default if we cant get them */
            if ( (iError = iSrchInfoGetFieldInfo(psiSrchIndex, uiFieldID, NULL, 0, NULL, 0, NULL, &uiFieldOptions)) != SRCH_NoError ) {
                
                /* Set the field option defaults */
                iSrchInfoGetFieldOptionDefaults(psiSrchIndex, &uiFieldOptions);
            }


            /* Set the field ID in the bitmap */
            if ( pucFieldIDBitmap != NULL ) {

                /* Set the field ID in the bitmap - field ID 0 is not a field */
                UTL_BITMAP_SET_BIT_IN_POINTER(pucFieldIDBitmap, uiFieldID - 1);
            
                /* Field ID bit map is set */
                bFieldIDBitmapSet = true;
            }
        }
    }


    /* Check if there is an unfielded search option if the field ID bit map was not set, and if the field name is not the wildcard field name */
    if ( (bFieldIDBitmapSet == false) && ((pucFieldName == NULL) || (s_strcmp(pucFieldName, SRCH_PARSER_WILDCARD_FIELD_NAME_STRING) != 0)) ) {
    
        unsigned char   pucUnfieldedSearchFieldNames[SPI_FIELD_NAME_MAXIMUM_LENGTH + 1] = {"\0"};

        /* Get the unfielded search field names and, if they exist, use them for this search */
        if ( iSrchInfoGetUnfieldedSearchFieldNames(psiSrchIndex, pucUnfieldedSearchFieldNames, SPI_FIELD_NAME_MAXIMUM_LENGTH + 1) == SRCH_NoError ) {
            
            unsigned char   *pucUnfieldedSearchFieldNamePtr = NULL;
            unsigned char   *pucUnfieldedSearchFieldNamesStrtokPtr = NULL;
            

            /* Loop parsing the unfielded search field names */
            for ( pucUnfieldedSearchFieldNamePtr = (unsigned char *)s_strtok_r(pucUnfieldedSearchFieldNames, SRCH_INFO_UNFIELDED_SEARCH_FIELD_NAMES_SEPARATORS, (char **)&pucUnfieldedSearchFieldNamesStrtokPtr); 
                    pucUnfieldedSearchFieldNamePtr != NULL; 
                    pucUnfieldedSearchFieldNamePtr = (unsigned char *)s_strtok_r(NULL, SRCH_INFO_UNFIELDED_SEARCH_FIELD_NAMES_SEPARATORS, (char **)&pucUnfieldedSearchFieldNamesStrtokPtr) ) {

                /* Set the field ID in the bitmap */
                if ( iSrchInfoGetFieldID (psiSrchIndex, pucUnfieldedSearchFieldNamePtr, &uiFieldID) == SRCH_NoError ) {

                    ASSERT(uiFieldID <= uiFieldIDBitmapLength);

                    /* Set the field ID in the bitmap, we know there are fields other than field ID 0 
                    ** since there are unfielded search field names - field ID 0 is not a field 
                    */
                    UTL_BITMAP_SET_BIT_IN_POINTER(pucFieldIDBitmap, uiFieldID - 1);

                    /* Field ID bit map is set */
                    bFieldIDBitmapSet = true;
                }
            }
        }
    }


    /* Set the mixed case flag, which really means 'does this term contain upper case, or non-alphanumerics' */
    bContainsUpperCase = bLngCaseDoesWideStringContainUpperCase(pwcTerm);

    /* Stem the term if we are stemming on this field and if the term does not end in a wildcard  */
    if ( (bSrchInfoFieldOptionStemming(uiFieldOptions) == true) && (bContainsUpperCase == false) && (s_wcschr(SRCH_PARSER_WILDCARDS_WSTRING    , pwcTerm[s_wcslen(pwcTerm) - 1]) == NULL) ) {
        if ( (iError = iLngStemmerStemTerm(pvLngStemmer, pwcTerm, 0)) != LNG_NoError ) {
            iUtlLogError(UTL_LOG_CONTEXT, "Failed to stem a term, lng error: %d.", iError);
            return (SRCH_FeedbackStemmingFailed);
        }
    }


    /* Set the return pointers */
    *ppwcTerm = pwcTerm;
    *pbFieldIDBitmapSet = bFieldIDBitmapSet;


    return (SRCH_NoError);

}
Ejemplo n.º 16
0
static void Run(const SUttProcessor *self, SUtterance *utt,
				s_erc *error)
{
	SG2P *g2p = NULL;
	SLexicon *lexicon = NULL;
	SAddendum *addendum = NULL;
	SSyllabification *syllab = NULL;
	const SRelation *wordRel;
	SRelation *syllableRel = NULL;
	SRelation *sylStructRel = NULL;
	SRelation *segmentRel = NULL;
	SItem *wordItem;
	char *downcase_word;
	SList *phones;
	s_bool syllabified;
	SList *syllablesPhones;
	SItem *sylStructureWordItem;
	SItem *syllableItem;
	SItem *sylStructSylItem;
	SItem *segmentItem;
	SIterator *sylItr = NULL;
	SIterator *phoneItr = NULL;
	const SObject *phone;
	s_bool is_present;


	S_CLR_ERR(error);
	s_get_lexical_objects(self, utt, &g2p, &lexicon, &addendum, &syllab, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Run",
				  "Call to \"s_get_lexical_objects\" failed"))
		goto quit_error;

	/* we require the word relation */
	is_present = SUtteranceRelationIsPresent(utt, "Word", error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Run",
				  "Call to \"SUtteranceRelationIsPresent\" failed"))
		goto quit_error;

	if (!is_present)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "Run",
				  "Failed to find 'Word' relation in utterance");
		goto quit_error;
	}

	wordRel = SUtteranceGetRelation(utt, "Word", error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Run",
				  "Call to \"SUtteranceGetRelation\" failed"))
		goto quit_error;

	/* create relations */
	syllableRel = SUtteranceNewRelation(utt, "Syllable", error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Run",
				  "Call to \"SUtteranceNewRelation\" failed"))
		goto quit_error;

	sylStructRel = SUtteranceNewRelation(utt, "SylStructure", error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Run",
				  "Call to \"SUtteranceNewRelation\" failed"))
		goto quit_error;

	segmentRel = SUtteranceNewRelation(utt, "Segment", error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Run",
				  "Call to \"SUtteranceNewRelation\" failed"))
		goto quit_error;

	/* start at the first item in the word relation, cast away
	 * const, we want to add daughter items.
	 * iterate over the word relation and fill in the
	 * phones and the associated structure.
	 */
	wordItem = (SItem*)SRelationHead(wordRel, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "Run",
				  "Call to \"SRelationHead\" failed"))
		goto quit_error;

	while (wordItem != NULL)
	{
		/* get word and downcase it */
		downcase_word = s_strlwr(s_strdup(SItemGetName(wordItem, error), error), error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "Run",
					  "Failed to down-case word item"))
			goto quit_error;

		if  (downcase_word == NULL || s_strcmp(downcase_word, "", error) == 0)
			goto continue_cycle;

		phones = NULL;
		syllabified = FALSE;

		/* get phone sequence for word */
		if (addendum != NULL)
		{
			phones = S_ADDENDUM_CALL(addendum, get_word)(addendum,
														 downcase_word,
														 NULL,
														 &syllabified,
														 error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "Run",
						  "Call to method \"get_word\" (SAddendum) failed"))
				goto quit_error;
		}

		if ((phones == NULL) && (lexicon != NULL))
		{
			phones = S_LEXICON_CALL(lexicon, get_word)(lexicon,
													   downcase_word,
													   NULL,
													   &syllabified,
													   error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "Run",
						  "Call to method \"get_word\" (SLexicon) failed"))
				goto quit_error;
		}

		if ((phones == NULL) && (g2p != NULL))
		{
			phones = S_G2P_CALL(g2p, apply)(g2p, downcase_word, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "Run",
						  "Call to method \"apply\" (SG2P) failed"))
				goto quit_error;
		}

		if (phones == NULL)
		{
			S_CTX_ERR(error, S_FAILURE,
					  "Run",
					  "Failed to get phone sequence for word '%s'", downcase_word);
			S_FREE(downcase_word);
			continue;
		}

		S_FREE(downcase_word);

		/* syllabify phone sequence */
		if (syllabified == FALSE)
		{
			if (syllab != NULL)
			{
				syllablesPhones = S_SYLLABIFICATION_CALL(syllab, syllabify)(syllab,
																			wordItem,
																			phones,
																			error);
				if (S_CHK_ERR(error, S_CONTERR,
							  "Run",
							  "Call to method \"syllabify\" failed"))
					goto quit_error;

				S_DELETE(phones, "Run", error);
			}
			else
			{
				syllablesPhones = S_LIST(S_NEW(SListList, error));
				if (S_CHK_ERR(error, S_CONTERR,
							  "Run",
							  "Failed to create new 'SList' object"))
					goto quit_error;

				SListAppend(syllablesPhones, S_OBJECT(phones), error);
				if (S_CHK_ERR(error, S_CONTERR,
							  "Run",
							  "Call to \"SListAppend\" failed"))
					goto quit_error;
			}
		}
		else
			syllablesPhones = (SList*)phones;

		/* create new syllable structure word item, shares content
		 * with word item.
		 */
		sylStructureWordItem = SRelationAppend(sylStructRel, wordItem, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "Run",
					  "Call to \"SRelationAppend\" failed"))
			goto quit_error;

		/* iterate over syllables */
		sylItr = S_ITERATOR_GET(syllablesPhones, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "Run",
					  "Call to \"S_ITERATOR_GET\" failed"))
			goto quit_error;

		while (sylItr != NULL)
		{
			/* new item in syllable relation */
			syllableItem = SRelationAppend(syllableRel, NULL, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "Run",
						  "Call to \"SRelationAppend\" failed"))
				goto quit_error;

			SItemSetName(syllableItem, "syl", error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "Run",
						  "Call to \"SItemSetName\" failed"))
				goto quit_error;

			/* daughter of above item, but in SylStructure */
			sylStructSylItem = SItemAddDaughter(sylStructureWordItem, syllableItem, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "Run",
						  "Call to \"SItemAddDaughter\" failed"))
				goto quit_error;

			/* iterate over phones and add segments */
			phoneItr = S_ITERATOR_GET((SList*)SIteratorObject(sylItr, error), error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "Run",
						  "Call to \"S_ITERATOR_GET/SIteratorObject\" failed"))
				goto quit_error;

			while (phoneItr != NULL)
			{
				phone = SIteratorObject(phoneItr, error);
				if (S_CHK_ERR(error, S_CONTERR,
							  "Run",
							  "Call to \"SIteratorObject\" failed"))
					goto quit_error;

				segmentItem = SRelationAppend(segmentRel, NULL, error);
				if (S_CHK_ERR(error, S_CONTERR,
							  "Run",
							  "Call to \"SRelationAppend\" failed"))
					goto quit_error;

				SItemSetName(segmentItem, SObjectGetString(phone, error), error);
				if (S_CHK_ERR(error, S_CONTERR,
							  "Run",
							  "Call to \"SItemSetName/SObjectGetString\" failed"))
					goto quit_error;

				SItemAddDaughter(sylStructSylItem, segmentItem, error);
				if (S_CHK_ERR(error, S_CONTERR,
							  "Run",
							  "Call to \"SItemAddDaughter\" failed"))
					goto quit_error;

				phoneItr = SIteratorNext(phoneItr);
			}


			sylItr = SIteratorNext(sylItr);
		}

		S_DELETE(syllablesPhones, "Run", error);
continue_cycle:
		wordItem = SItemNext(wordItem, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "Run",
					  "Call to \"SItemNext\" failed"))
			goto quit_error;
	}

	/* here all is OK */
	return;


	/* error clean-up code */
quit_error:
	if (syllableRel != NULL)
	{
		SUtteranceDelRelation(utt, "Syllable", error);
		S_CHK_ERR(error, S_CONTERR,
				  "Run",
				  "Call to \"SUtteranceDelRelation\" failed");
	}

	if (sylStructRel != NULL)
	{
		SUtteranceDelRelation(utt, "SylStructure", error);
		S_CHK_ERR(error, S_CONTERR,
				  "Run",
				  "Call to \"SUtteranceDelRelation\" failed");
	}

	if (segmentRel != NULL)
	{
		SUtteranceDelRelation(utt, "Segment", error);
		S_CHK_ERR(error, S_CONTERR,
				  "Run",
				  "Call to \"SUtteranceDelRelation\" failed");
	}

	if (sylItr != NULL)
		S_DELETE(sylItr, "Run", error);

	if (phoneItr != NULL)
		S_DELETE(phoneItr, "Run", error);

	self = NULL;
}
Ejemplo n.º 17
0
static hts_params *get_hts_engine_params(const SMap *features, s_bool *me, s_erc *error)
{
	hts_params *engine_params;
	const char *tmp;


	S_CLR_ERR(error);

	engine_params = S_CALLOC(hts_params, 1);
	if (engine_params == NULL)
	{
		S_FTL_ERR(error, S_MEMERROR,
				  "get_hts_engine_params",
				  "Failed to allocate memory for 'hts_params' object");
		return NULL;
	}

	engine_params->sampling_rate = (int)SMapGetIntDef(features, "sampling_rate",
													  SPCT_DEF_SAMPLING_RATE, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "get_hts_engine_params",
				  "Call to \"SMapGetIntDef\" failed"))
		goto quit_error;

	engine_params->fperiod = (int)SMapGetIntDef(features, "fperiod",
												SPCT_DEF_FPERIOD, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "get_hts_engine_params",
				  "Call to \"SMapGetIntDef\" failed"))
		goto quit_error;

	engine_params->alpha = (double)SMapGetFloatDef(features, "alpha",
												   SPCT_DEF_ALPHA, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "get_hts_engine_params",
				  "Call to \"SMapGetFloatDef\" failed"))
		goto quit_error;

	engine_params->stage = (double)SMapGetFloatDef(features, "stage",
												   SPCT_DEF_STAGE, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "get_hts_engine_params",
				  "Call to \"SMapGetFloatDef\" failed"))
		goto quit_error;

	engine_params->beta = (double)SMapGetFloatDef(features, "beta",
												   SPCT_DEF_BETA, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "get_hts_engine_params",
				  "Call to \"SMapGetFloatDef\" failed"))
		goto quit_error;

	engine_params->audio_buff_size = (int)SMapGetIntDef(features, "audio_buff_size",
														SPCT_DEF_AUDIO_BUFF_SIZE, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "get_hts_engine_params",
				  "Call to \"SMapGetIntDef\" failed"))
		goto quit_error;

	engine_params->uv_threshold = (double)SMapGetFloatDef(features, "uv_threshold",
														  SPCT_DEF_UV_THRESHOLD, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "get_hts_engine_params",
				  "Call to \"SMapGetFloatDef\" failed"))
		goto quit_error;

	engine_params->gv_weight_lf0 = (double)SMapGetFloatDef(features, "gv_weight_lf0",
														   SPCT_DEF_GV_WEIGHT_LF0, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "get_hts_engine_params",
				  "Call to \"SMapGetFloatDef\" failed"))
		goto quit_error;

	engine_params->gv_weight_mcp = (double)SMapGetFloatDef(features, "gv_weight_mcp",
														   SPCT_DEF_GV_WEIGHT_MCP, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "get_hts_engine_params",
				  "Call to \"SMapGetFloatDef\" failed"))
		goto quit_error;


	(*me) = SMapObjectPresent(features, "gv_weight_str", error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "get_hts_engine_params",
				  "Call to \"SMapObjectPresent\" failed"))
		goto quit_error;

	if (*me)
	{
		engine_params->gv_weight_str = (double)SMapGetFloat(features, "gv_weight_str",
															error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "get_hts_engine_params",
					  "Call to \"SMapGetFloat\" failed"))
			goto quit_error;
	}

	/* set "use_log_gain" to FALSE as default */
	engine_params->use_log_gain = FALSE;

	tmp = SMapGetStringDef(features, "use_log_gain", NULL, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "get_hts_engine_params",
				  "Call to \"SMapGetStringDef\" failed"))
		goto quit_error;

	if (tmp != NULL)
	{
		int scomp;


		scomp = s_strcmp("TRUE", tmp, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "get_hts_engine_params",
					  "Call to \"s_strcmp\" failed"))
			goto quit_error;

		if (scomp == 0)
			engine_params->use_log_gain = TRUE;
	}

	/* all OK, no errors */
	return engine_params;

	/* error clean up */
quit_error:
	S_FREE(engine_params);
	return NULL;
}
Ejemplo n.º 18
0
static s_bool _context_match(const s_str_list *pattern, const s_str_list *string,
							 const SMap *sets, s_erc *error)
{
	uint32 plength;
	uint32 slength;
	const char *element;
	int rv;
	int r;
	int s;
	int t;
	int u;
	s_str_list *new_pattern = NULL;
	s_str_list *tmp = NULL;
	s_str_list *new_string = NULL;
	const char *pattern0;
	const char *string0;


	S_CLR_ERR(error);
	plength = s_str_list_size(pattern, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "_context_match",
				  "Call to \"s_str_list_size\" failed"))
		return FALSE;

	if (plength == 0) /* rule context is none, so match */
		return TRUE;

	slength = s_str_list_size(string, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "_context_match",
				  "Call to \"s_str_list_size\" failed"))
		return FALSE;

	if (slength == 0)
	{
		/* rule context is not none and itape context is
		 * none
		 */
		return FALSE;
	}

	if (plength > 1)
	{
		element = s_str_list_nth_string(pattern, 1, error); /* pattern[1] */
		if (S_CHK_ERR(error, S_CONTERR,
					  "_context_match",
					  "Call to \"s_str_list_nth_string\" failed"))
			return FALSE;

		rv = s_strcmp(element, "*", error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "_context_match",
					  "Call to \"s_strcmp\" failed"))
			return FALSE;

		if (rv == 0) /* pattern[1] == "*" */
		{
			new_pattern = s_str_list_slice(pattern, 2, -1, error); /* pattern[2:] */
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"s_str_list_slice\" failed"))
				return FALSE;

			r = _context_match(new_pattern, string, sets, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Recursive call to \"_context_match\" failed"))
				goto error_return;

			tmp = s_str_list_dup(new_pattern, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"s_str_list_dup\" failed"))
				goto error_return;

			s_str_list_delete(new_pattern, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"s_str_list_delete\" failed"))
				goto error_return;

			new_pattern = NULL;

			pattern0 = s_str_list_nth_string(pattern, 0, error); /* pattern[0] */
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"s_str_list_nth_string\" failed"))
				goto error_return;

			s_str_list_prepend(tmp, s_strdup(pattern0, error), error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"s_strdup/s_str_list_prepend\" failed"))
				goto error_return;

			s = _context_match(tmp, string, sets, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Recursive call to \"_context_match\" failed"))
				goto error_return;

			s_str_list_delete(tmp, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"s_str_list_delete\" failed"))
				goto error_return;

			tmp = NULL;

			string0 = s_str_list_nth_string(string, 0, error); /* string[0] */
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"s_str_list_nth_string\" failed"))
				goto error_return;

			t = _item_match(pattern0, string0, sets, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"_item_match\" failed"))
				goto error_return;

			new_string = s_str_list_slice(string, 1, -1, error); /* string[1:] */
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"s_str_list_slice\" failed"))
				return FALSE;

			u = _context_match(pattern, new_string, sets, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Recursive call to \"_context_match\" failed"))
				goto error_return;

			s_str_list_delete(new_string, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"s_str_list_delete\" failed"))
				goto error_return;

			new_string = NULL;

			return (r || s || (t && u));
		}

		rv = s_strcmp(element, "+", error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "_context_match",
					  "Call to \"s_strcmp\" failed"))
			return FALSE;

		if (rv == 0) /* pattern[1] == "+" */
		{
			pattern0 = s_str_list_nth_string(pattern, 0, error); /* pattern[0] */
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"s_str_list_nth_string\" failed"))
				goto error_return;

			string0 = s_str_list_nth_string(string, 0, error); /* string[0] */
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"s_str_list_nth_string\" failed"))
				goto error_return;

			r = _item_match(pattern0, string0, sets, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"_item_match\" failed"))
				goto error_return;

			tmp = s_str_list_slice(pattern, 2, -1, error); /* pattern[2:] */
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"s_str_list_slice\" failed"))
				return FALSE;

			s_str_list_prepend(tmp, s_strdup("*", error), error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"s_strdup/s_str_list_prepend\" failed"))
				goto error_return;

			s_str_list_prepend(tmp, s_strdup(pattern0, error), error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"s_strdup/s_str_list_prepend\" failed"))
				goto error_return;

			new_string = s_str_list_slice(string, 1, -1, error); /* string[1:] */
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"s_str_list_slice\" failed"))
				return FALSE;

			s = _context_match(tmp, string, sets, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Recursive call to \"_context_match\" failed"))
				goto error_return;

			s_str_list_delete(tmp, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"s_str_list_delete\" failed"))
				goto error_return;

			tmp = NULL;

			s_str_list_delete(new_string, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "_context_match",
						  "Call to \"s_str_list_delete\" failed"))
				goto error_return;

			new_string = NULL;

			return (r && s);
		}
	}

	pattern0 = s_str_list_nth_string(pattern, 0, error); /* pattern[0] */
	if (S_CHK_ERR(error, S_CONTERR,
				  "_context_match",
				  "Call to \"s_str_list_nth_string\" failed"))
		goto error_return;

	string0 = s_str_list_nth_string(string, 0, error); /* string[0] */
	if (S_CHK_ERR(error, S_CONTERR,
				  "_context_match",
				  "Call to \"s_str_list_nth_string\" failed"))
		goto error_return;

	r =  _item_match(pattern0, string0, sets, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "_context_match",
				  "Call to \"_item_match\" failed"))
		goto error_return;

	if (r == TRUE)
	{
		new_string = s_str_list_slice(string, 1, -1, error); /* string[1:] */
		if (S_CHK_ERR(error, S_CONTERR,
					  "_context_match",
					  "Call to \"s_str_list_slice\" failed"))
			return FALSE;


		new_pattern = s_str_list_slice(pattern, 1, -1, error); /* pattern[1:] */
		if (S_CHK_ERR(error, S_CONTERR,
					  "_context_match",
					  "Call to \"s_str_list_slice\" failed"))
			return FALSE;

		s = _context_match(new_pattern, new_string, sets, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "_context_match",
					  "Recursive call to \"_context_match\" failed"))
			goto error_return;

		s_str_list_delete(new_string, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "_context_match",
					  "Call to \"s_str_list_delete\" failed"))
			goto error_return;

		new_string = NULL;

		s_str_list_delete(new_pattern, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "_context_match",
					  "Call to \"s_str_list_delete\" failed"))
			goto error_return;

		new_pattern = NULL;

		return s;
	}

	/* all OK, no error and no match */
	return FALSE;


error_return:
	{
		s_erc local_err = S_SUCCESS;


		if (new_pattern != NULL)
			s_str_list_delete(new_pattern, &local_err);

		if (tmp != NULL)
			s_str_list_delete(tmp, &local_err);

		if (new_string != NULL)
			s_str_list_delete(new_string, &local_err);
	}

	return FALSE;
}
Ejemplo n.º 19
0
S_LOCAL SG2PRewrites *s_read_g2p_rewrites(SDatasource *ds, s_erc *error)
{
	SG2PRewrites *g2p = NULL;
	SEbmlRead *ebmlReader = NULL;
	uint32 id;
	s_bool container_exhausted;
	int scomp;


	S_CLR_ERR(error);

	/* create and initialize ebml reader */
	ebmlReader = S_NEW(SEbmlRead, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "s_read_g2p_rewrites",
				  "Failed to create new SEbmlRead object"))
		goto quit_error;

	S_EBMLREAD_CALL(ebmlReader, read_init)(&ebmlReader, ds, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "s_read_g2p_rewrites",
				  "Failed to initialize SEbmlRead object"))
		goto quit_error;

	/* check that we have the correct doc type */
	scomp = s_strcmp(ebmlReader->header->doctype, "spct_g2p_rewrites", error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "s_read_g2p_rewrites",
				  "Call to \"s_strcmp\" failed"))
		goto quit_error;

	if (scomp != 0)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "s_read_g2p_rewrites",
				  "Ebml file format not of type 'spct_g2p_rewrites', read format is '%s'",
				  ebmlReader->header->doctype);
		goto quit_error;
	}

	/* create and initialize new g2p rewrites object */
	g2p = S_NEW(SG2PRewrites, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "s_read_g2p_rewrites",
				  "Failed to create new 'SG2PRewrites' object"))
		goto quit_error;

	/* read top level container */
	id = S_EBMLREAD_CALL(ebmlReader, container)(ebmlReader, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "s_read_g2p_rewrites",
				  "ebmlRead method \"container\" failed"))
		goto quit_error;

	/* sanity check id */
	S_EBML_ID_SANITY(id, S_G2PREWRITES_EBML,
					 "s_read_g2p_rewrites",
					 "ID mismatch", error);

	while (1)
	{
		container_exhausted = S_EBMLREAD_CALL(ebmlReader, container_at_end)(ebmlReader, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "s_read_g2p_rewrites",
					  "ebmlRead method \"container_at_end\" failed"))
			goto quit_error;

		if (container_exhausted)
			break; /* we are finished reading the g2p rewrites file */

		/* peek id for g2p rewrites elements */
		id = S_EBMLREAD_CALL(ebmlReader, peek_id)(ebmlReader, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "s_read_g2p_rewrites",
					  "ebmlRead method \"peek_id\" failed"))
			goto quit_error;

		switch(id)
		{
		case S_G2PREWRITES_EBML_DEF:
		{
			read_g2p_rewrites_def(g2p, ebmlReader, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "s_read_g2p_rewrites",
						  "Call to \"read_g2p_rewrites_def\" failed"))
				goto quit_error;
			break;
		}
		case S_G2PREWRITES_EBML_SETS:
		{
			S_WARNING(S_WARNERR,
					  "s_read_g2p_rewrites",
					  "G2P Rewrites sets not yet implemented, skipping");

			S_EBMLREAD_CALL(ebmlReader, element_skip)(ebmlReader, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "s_read_g2p_rewrites",
						  "ebmlRead method \"element_skip\" failed"))
				goto quit_error;
			break;
		}
		case S_G2PREWRITES_EBML_RULES_CONTAINER:
		{
			read_g2p_rewrites_rules(g2p, ebmlReader, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "s_read_g2p_rewrites",
						  "Call to \"read_g2p_rewrites_rules\" failed"))
				goto quit_error;

			break;
		}
		case S_G2PREWRITES_EBML_ZEROS:
		{
			read_g2p_rewrites_zeros(g2p, ebmlReader, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "s_read_g2p_rewrites",
						  "Call to \"read_g2p_rewrites_zeros\" failed"))
				goto quit_error;

			break;
		}
		default:
			/* unknown elements, skip */
			S_WARNING(S_FAILURE,
					  "s_read_g2p_rewrites",
					  "Skipping element with unknown id '0x%x'",
					  id);

			S_EBMLREAD_CALL(ebmlReader, element_skip)(ebmlReader, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "s_read_g2p_rewrites",
						  "ebmlRead method \"element_skip\" failed"))
				goto quit_error;
		}
	}

	/* if we get here then everything was OK */
	goto quit;


	/* errors start clean up code here */
quit_error:
	if (g2p != NULL)
		S_DELETE(g2p, "s_read_g2p_rewrites", error); /* sets g2p = NULL */

	/* normal exit start clean up code here */
quit:
	if (ebmlReader != NULL)
		S_DELETE(ebmlReader, "s_read_g2p_rewrites", error);

	return g2p;
}
Ejemplo n.º 20
0
int property_change_system_value( char* name, char* value )
{
	
	typedef struct{
		char name[64];
		char value[64];
		//byte size;
		//byte flag;		// 0 is int, 1 is string
		//byte sync;
		//byte tmp;
	}_s_node_prop_item;
	
	// system value update.
	// ipaddr etc...
	int kc;
	char *ki[ 15 ];
	//char tmp_buf[  sizeof( npi->value ) ];
	char tmp_buf[  64 ];
	int val1, val2, val3, val4;
	_s_node_prop_item tmp_npi;
	_s_node_prop_item *npi;

	npi = &tmp_npi;
	strcpy( npi->name, name );
	strcpy( npi->value, value );
	_d_str( name );
	_d_str( value );
	
	// add the , explain the sys command string.
	if( strcmp( npi->name, "ipaddr" ) == 0 
			|| strcmp( npi->name, "ip" ) == 0 ){
		_d_str( (char*)npi->value );
		memcpy( tmp_buf, npi->value, sizeof( npi->value ) );
		kc = analysis_string_to_strings_by_decollator( tmp_buf, ".", ki, 15 );
		if( kc != 4 )
			return 0;
		g_machine_ip[0] = atoi( ki[0] );
		g_machine_ip[1] = atoi( ki[1] );
		g_machine_ip[2] = atoi( ki[2] );
		g_machine_ip[3] = atoi( ki[3] );
		//debug_show_ip_str(g_machine_ip);
		return 0;
	}
	else if( strcmp( npi->name, "hostip" ) == 0 ){
		_d_str( (char*)npi->value );
		memcpy( tmp_buf, npi->value, sizeof( npi->value ) );
		kc = analysis_string_to_strings_by_decollator( tmp_buf, ".", ki, 15 );
		if( kc != 4 )
			return 0;
		g_send_package_socket_ip[0] = atoi( ki[0] );
		g_send_package_socket_ip[1] = atoi( ki[1] );
		g_send_package_socket_ip[2] = atoi( ki[2] );
		g_send_package_socket_ip[3] = atoi( ki[3] );
		//debug_show_ip_str(g_send_package_socket_ip);
		return 0;
	}
	else if( strcmp( npi->name, "hport" ) == 0 ){
		_d_str( (char*)npi->value );
		val1 = atoi( (char*)npi->value );
		g_send_package_socket_port = val1;
		_d_int( g_send_package_socket_port );
		return 0;
	}
	else if( strcmp( npi->name, "webport" ) == 0 ){
		return 0;
	}
	else if( strcmp( npi->name, "timeout" ) == 0 ){
		_d_str( (char*)npi->value );
		val1 = atoi( (char*)npi->value );
		g_net_time_out = val1;
		_d_int( g_net_time_out );
		return 0;
	}
	else if( strcmp( npi->name, "no" ) == 0 ){
		_d_str( (char*)npi->value );
		val1 = atoi( (char*)npi->value );
		g_machine_no = val1;
		_d_int( g_machine_no );
		return 0;
	}
	else if( strcmp( npi->name, "keyboard" ) == 0 ){
		_d_str( (char*)npi->value );
		_d_buf( (char*)npi->value, sizeof( npi->value ) );
		if( s_strcmp( (char*)npi->value, "disable" ) == 0 ){
			//Key_EnableScan( 0 );
		}
		else{
			//Key_EnableScan( 1 );
		}
		//val1 = atoi( (char*)npi->value );
		//g_machine_no = val1;
		//_d_int( g_machine_no );
		return 0;
	}
	else if( strcmp( npi->name, "hosttype" ) == 0 ){
		_d_str( (char*)npi->value );
		if( strcmp( (char*)npi->value, "tcmd" ) == 0 )
			g_host_type = 1;
		else if( strcmp( (char*)npi->value, "dlc" ) == 0 )
			g_host_type = 2;
		else
			g_host_type = 0;
		
		//val1 = atoi( (char*)npi->value );
		//g_machine_no = val1;
		_d_int( g_host_type );
		return 0;
	}
	return -1;
}
Ejemplo n.º 21
0
/**
 * Compare the elements of two string lists.
 */
S_API sint32 s_str_list_cmp(const s_str_list *sl1, const s_str_list *sl2, s_erc *error)
{
	uint32 sl1_size;
	uint32 sl2_size;
	uint32 cnt;
	const s_str_list_element *se1;
	const s_str_list_element *se2;


	S_CLR_ERR(error);

	if ((sl1 == NULL) || (sl2 == NULL))
		return 0;

	sl1_size = s_str_list_size(sl1, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "s_str_list_cmp",
				  "Call to \"s_str_list_size\" failed"))
		return 0;

	sl2_size = s_str_list_size(sl1, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "s_str_list_cmp",
				  "Call to \"s_str_list_size\" failed"))
		return 0;

	se1 = s_str_list_first(sl1, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "s_str_list_cmp",
				  "Call to \"s_str_list_first\" failed"))
		return 0;

	se2 = s_str_list_first(sl2, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "s_str_list_cmp",
				  "Call to \"s_str_list_first\" failed"))
		return 0;

	cnt = 0;

	while ((se1 != NULL) || (se2 != NULL))
	{
		const char *e1;
		const char *e2;
		int rv;


		e1 = s_str_list_element_get(se1, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "s_str_list_cmp",
					  "Call to \"s_str_list_element_get\" failed"))
			return 0;

		e2 = s_str_list_element_get(se2, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "s_str_list_cmp",
					  "Call to \"s_str_list_element_get\" failed"))
			return 0;

		rv = s_strcmp(e1, e2, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "s_str_list_cmp",
					  "Call to \"s_strcmp\" failed"))
			return 0;

		if (rv != 0)
			return (sint32)cnt;

		se1 = s_str_list_element_next(se1, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "s_str_list_cmp",
					  "Call to \"s_str_list_element_next\" failed"))
			return 0;

		se2 = s_str_list_element_next(se2, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "s_str_list_cmp",
					  "Call to \"s_str_list_element_next\" failed"))
			return 0;

		cnt++;
	}

	if ((sl1_size == sl2_size) && (cnt == sl1_size))
		return -1; /* lists are the same */

	return (sint32)cnt;
}