コード例 #1
0
int
main (int argc, char *argv[])
{
	GList	*symbols;
	GList	*l;
	ScSymbol	*s;
	gchar *sc_tags;
	
	gtk_init_check(&argc, &argv);
	
	g_debug ("============= file ============");
	symbols = sc_ctags_exec_get_symbols (CTAGS_EXEC_FILE, "../src/sc-plugin.c");
	for (l = symbols; l != NULL; l = g_list_next (l))
	{
		s = (ScSymbol*)l->data;
		g_debug ("name: %s\n sign: %s", s->name, s->signature);
		g_object_unref (s);
	}
	g_list_free (symbols);
	
	g_debug ("============= folder ============");
	symbols = sc_ctags_exec_get_symbols (CTAGS_EXEC_PROJECT, "../src");
	for (l = symbols; l != NULL; l = g_list_next (l))
	{
		s = (ScSymbol*)l->data;
		g_debug ("name: %s\n sign: %s", s->name, s->signature);
		g_object_unref (s);
	}
	g_list_free (symbols);

	g_debug ("============= generating SC_TAGS ==============");

	sc_tags = sc_ctags_build_project_sctags ("..", TRUE);
	if (sc_tags)
	{
		g_debug ("File SC_TAGS created: %s", sc_tags);
		g_free (sc_tags);
	}
	else
	{
		g_debug ("Error creating SC_TAGS");
	}
	
	gchar *pro = sc_utils_get_project_dir ("test-ctags.c");

	g_debug ("Project dir: %s", pro);

	g_free(pro);

	regexp_test ();
	
	return 0;
}
コード例 #2
0
ファイル: wavefile.c プロジェクト: krichter722/gwave
/*
 * Read a waveform data file.
 *  If the format name is non-NULL, only tries reading in specified format.
 *  If format not specified, tries to guess based on filename, and if
 *  that fails, tries all of the readers until one sucedes.
 *  Returns NULL on failure after printing an error message.
 * 
 * TODO: use some kind of callback or exception so that client
 * can put the error messages in a GUI or somthing.
 */
WaveFile *wf_read(char *name, char *format)
{
	FILE *fp;
	SpiceStream *ss;
	int i;

	unsigned int tried = 0; /* bitmask of formats. */

	g_assert(NFormats <= 8*sizeof(tried));
	fp = fopen64(name, "r");
	if(fp == NULL) {
		perror(name);
		return NULL;
	}

	if(format == NULL) {
		for(i = 0; i < NFormats; i++) {
			if(!format_tab[i].creg) {
				format_tab[i].creg = regexp_compile(format_tab[i].fnrexp);
			}
			if(regexp_test(format_tab[i].creg, name))
			{
				tried |= 1<<i;
				ss = ss_open_internal(fp, name, format_tab[i].name);
				if(ss) {
					ss_msg(INFO, "wf_read", "%s: read with format \"%s\"", name, format_tab[i].name);
					return wf_finish_read(ss);
				}

				if(fseek(fp, 0L, SEEK_SET) < 0) {
					perror(name);
					return NULL;
				}
					
			}
		}
		if(tried == 0)
			ss_msg(INFO, "wf_read", "%s: couldn't guess a format from filename suffix.", name);
		/* no success with formats whose regexp matched filename,
		* try the others.
		*/
		for(i = 0; i < NFormats; i++) {
			if((tried & (1<<i)) == 0) {
				ss = ss_open_internal(fp, name, format_tab[i].name);
				if(ss)
					return wf_finish_read(ss);
				tried |= 1<<i;
				if(fseek(fp, 0L, SEEK_SET) < 0) {
					perror(name);
					return NULL;
				}
			}
		}
		ss_msg(ERR, "wf_read", "%s: couldn't read with any format\n", name);
		return NULL;
	} else { /* use specified format only */
		ss = ss_open_internal(fp, name, format);
		if(ss)
			return wf_finish_read(ss);
		else
			return NULL;
	}
}