Ejemplo n.º 1
0
Archivo: events.c Proyecto: gnehzr/uzbl
/*
 * build event string and send over the supported interfaces
 * custom_event == NULL indicates an internal event
*/
void
send_event(int type, const gchar *details, const gchar *custom_event) {
    GString *event_message = g_string_new("");
    gchar *buf, *p_val = NULL;

    /* expand shell vars */
    if(details) {
        buf = g_strdup(details);
        p_val = parseenv(buf ? g_strchug(buf) : " ");
        g_free(buf);
    }

    /* check for custom events */
    if(custom_event) {
        g_string_printf(event_message, "EVENT [%s] %s %s\n",
                uzbl.state.instance_name, custom_event, p_val);
    }
    /* check wether we support the internal event */
    else if(type < LAST_EVENT) {
        g_string_printf(event_message, "EVENT [%s] %s %s\n",
                uzbl.state.instance_name, event_table[type], p_val);
    }

    if(event_message->str) {
        if(uzbl.state.events_stdout)
            send_event_stdout(event_message);
        send_event_socket(event_message);

        g_string_free(event_message, TRUE);
    }
    g_free(p_val);
}
Ejemplo n.º 2
0
/*-------------------------------------------------------------------------*/
void ccinit(int argc, char *argv[])
{
    char buffer[260];
    strcpy(copyright, COPYRIGHT);
    strcpy(version, STRING_VERSION);

    outfile[0] = 0;

#ifdef CPREPROCESSOR
    banner("ocpp Version %s %s", version, copyright);
#else

    banner("%s Version %s %s", chosenAssembler->progname, version, copyright);

    /* parse the environment and command line */
    if (chosenAssembler->envname && !parseenv(chosenAssembler->envname))
        usage(argv[0]);
#endif
#ifdef MICROSOFT
    GetModuleFileNameA(NULL, buffer, sizeof(buffer));  //FIXME NULL as int   
#else
    strcpy(buffer, argv[0]);
#endif
    parseconfigfile(buffer);
    if (!parse_args(&argc, argv, TRUE) || (!clist && argc == 1))
        usage(argv[0]);

    /* tack the environment includes in */
    addinclude();

    /* Scan the command line for file names or response files */
    {
        int i;
        for (i = 1; i < argc; i++)
            if (argv[i][0] == '@')
                parsefile(0, argv[i] + 1);
            else
                InsertAnyFile(argv[i], 0,  - 1);
    }

    if ((clist && clist->next) && has_output_file)
        fatal("Cannot specify output file for multiple input files\n");

    if (has_output_file && !cparams.prm_compileonly)
    {
#ifndef CPREPROCESSOR
        if (chosenAssembler->insert_noncompile_file)
            chosenAssembler->insert_noncompile_file(outfile);
#endif
        has_output_file = FALSE;
    }
    /* Set up a ctrl-C handler so we can exit the prog */
    signal(SIGINT, ctrlchandler);
    if (setjmp(ctrlcreturn))
        exit(1);
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
	io s;

	parseenv();
	parseargs(argc, argv);
	initconn(&s);
	c = &s;
	atexit(quit);
	greeting(&s);
	getlatest(&s);

	exit(EXIT_SUCCESS);
}
Ejemplo n.º 4
0
/* The main function */
int main() {
	parseenv();
	run_eztrace();
	fetch_traces();

	/* Before checking the bintrace we need to init the structur of event */
	init_tabevent();

	/*After that we retrieve the event of the trace */
	parseevent();

	// Check for eztrace_convert success
	run_eztrace_convert();

	clean();

	return EXIT_SUCCESS;
}
Ejemplo n.º 5
0
int aa_parseoptions(struct aa_hardware_params *p, aa_renderparams * r, int *argc, char **argv)
{
	int i, y;
	int supported;
	if (!inparse)
		parseenv(p, r);
	if (argc == NULL || argv == NULL)
		return 1;
	supported = p != NULL ? p->supported : aa_defparams.supported;
	if (p == NULL)
		p = &aa_defparams;
	if (r == NULL)
		r = &aa_defrenderparams;
	for (i = 1; i < *argc; i++) {
		if (strcmp(argv[i], "-font") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "font name expected\n");
				return (0);
			}
			for (y = 0; aa_fonts[y] != NULL; y++) {
				if (!strcmp(argv[i], aa_fonts[y]->name) ||
					!strcmp(argv[i], aa_fonts[y]->shortname)) {
					p->font = aa_fonts[y];
					aa_remove(i, argc, argv);
					break;
				}
			}
			if (aa_fonts[i] == NULL) {
				fprintf(stderr, "font name expected\n");
				return (0);
			}
			i--;
		} else if (strcmp(argv[i], "-normal") == 0) {
			aa_remove(i, argc, argv);
			i--;
			supported |= AA_NORMAL_MASK;
			p->supported = supported;
		} else if (strcmp(argv[i], "-nonormal") == 0) {
			aa_remove(i, argc, argv);
			i--;
			supported &= ~AA_NORMAL_MASK;
			p->supported = supported;
		} else if (strcmp(argv[i], "-bold") == 0) {
			aa_remove(i, argc, argv);
			i--;
			supported |= AA_BOLD_MASK;
			p->supported = supported;
		} else if (strcmp(argv[i], "-nobold") == 0) {
			aa_remove(i, argc, argv);
			i--;
			supported &= ~AA_BOLD_MASK;
			p->supported = supported;
		} else if (strcmp(argv[i], "-boldfont") == 0) {
			aa_remove(i, argc, argv);
			i--;
			supported |= AA_BOLDFONT_MASK;
			p->supported = supported;
		} else if (strcmp(argv[i], "-noboldfont") == 0) {
			aa_remove(i, argc, argv);
			i--;
			supported &= ~AA_BOLDFONT_MASK;
			p->supported = supported;
		} else if (strcmp(argv[i], "-dim") == 0) {
			aa_remove(i, argc, argv);
			i--;
			supported |= AA_DIM_MASK;
			p->supported = supported;
		} else if (strcmp(argv[i], "-nodim") == 0) {
			aa_remove(i, argc, argv);
			i--;
			supported &= ~AA_DIM_MASK;
			p->supported = supported;
		} else if (strcmp(argv[i], "-reverse") == 0) {
			aa_remove(i, argc, argv);
			i--;
			supported |= AA_REVERSE_MASK;
			p->supported = supported;
		} else if (strcmp(argv[i], "-extended") == 0) {
			aa_remove(i, argc, argv);
			i--;
			supported |= AA_EXTENDED;
			p->supported = supported;
		} else if (strcmp(argv[i], "-eight") == 0) {
			aa_remove(i, argc, argv);
			i--;
			supported |= AA_EIGHT;
			p->supported = supported;
		} else if (strcmp(argv[i], "-noreverse") == 0) {
			aa_remove(i, argc, argv);
			i--;
			supported &= ~AA_REVERSE_MASK;
			p->supported = supported;
		} else if (strcmp(argv[i], "-inverse") == 0) {
			aa_remove(i, argc, argv);
			i--;
			r->inversion = 1;
		} else if (strcmp(argv[i], "-noinverse") == 0) {
			aa_remove(i, argc, argv);
			i--;
			r->inversion = 0;
		} else if (strcmp(argv[i], "-nodither") == 0) {
			aa_remove(i, argc, argv);
			i--;
			r->dither = AA_NONE;
		} else if (strcmp(argv[i], "-floyd_steinberg") == 0) {
			aa_remove(i, argc, argv);
			i--;
			r->dither = AA_FLOYD_S;
		} else if (strcmp(argv[i], "-error_distribution") == 0) {
			aa_remove(i, argc, argv);
			i--;
			r->dither = AA_ERRORDISTRIB;
		} else if (strcmp(argv[i], "-random") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "Random dithering value expected\n");
				return (0);
			}
			r->randomval = atol(argv[i]);
			aa_remove(i, argc, argv);
			i--;
		} else if (strcmp(argv[i], "-bright") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "Bright value expected(0-255)\n");
				return (0);
			}
			r->bright = atol(argv[i]);
			aa_remove(i, argc, argv);
			i--;
		} else if (strcmp(argv[i], "-contrast") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "Contrast value expected(0-255)\n");
				return (0);
			}
			r->contrast = atol(argv[i]);
			aa_remove(i, argc, argv);
			i--;
		} else if (strcmp(argv[i], "-width") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "width expected\n");
				return (0);
			}
			p->width = atol(argv[i]);
			aa_remove(i, argc, argv);
			i--;
		} else if (strcmp(argv[i], "-recwidth") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "width expected\n");
				return (0);
			}
			p->recwidth = atol(argv[i]);
			aa_remove(i, argc, argv);
			i--;
		} else if (strcmp(argv[i], "-minwidth") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "width expected\n");
				return (0);
			}
			p->minwidth = atol(argv[i]);
			aa_remove(i, argc, argv);
			i--;
		} else if (strcmp(argv[i], "-maxwidth") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "width expected\n");
				return (0);
			}
			p->maxwidth = atol(argv[i]);
			aa_remove(i, argc, argv);
			i--;
		} else if (strcmp(argv[i], "-height") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "height expected\n");
				return (0);
			}
			p->height = atol(argv[i]);
			aa_remove(i, argc, argv);
			i--;
		} else if (strcmp(argv[i], "-recheight") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "height expected\n");
				return (0);
			}
			p->recheight = atol(argv[i]);
			aa_remove(i, argc, argv);
			i--;
		} else if (strcmp(argv[i], "-minheight") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "height expected\n");
				return (0);
			}
			p->minheight = atol(argv[i]);
			aa_remove(i, argc, argv);
			i--;
		} else if (strcmp(argv[i], "-maxheight") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "height expected\n");
				return (0);
			}
			p->maxheight = atol(argv[i]);
			aa_remove(i, argc, argv);
			i--;
		} else if (strcmp(argv[i], "-gamma") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "Gamma value expected\n");
				return (0);
			}
			r->gamma = atof(argv[i]);
			aa_remove(i, argc, argv);
			i--;
		} else if (strcmp(argv[i], "-dimmul") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "Dimmul value expected\n");
				return (0);
			}
			p->dimmul = atof(argv[i]);
			aa_remove(i, argc, argv);
			i--;
		} else if (strcmp(argv[i], "-boldmul") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "Dimmul value expected\n");
				return (0);
			}
			p->boldmul = atof(argv[i]);
			aa_remove(i, argc, argv);
			i--;
		} else if (strcmp(argv[i], "-driver") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "Driver name expected\n");
				return (0);
			}
			aa_recommendhidisplay(argv[i]);
			aa_remove(i, argc, argv);
			i--;
		} else if (strcmp(argv[i], "-kbddriver") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "Driver name expected\n");
				return (0);
			}
			aa_recommendhikbd(argv[i]);
			aa_remove(i, argc, argv);
			i--;
		} else if (strcmp(argv[i], "-mousedriver") == 0) {
			aa_remove(i, argc, argv);
			if (*argc == i) {
				fprintf(stderr, "Driver name expected\n");
				return (0);
			}
			aa_recommendhimouse(argv[i]);
			aa_remove(i, argc, argv);
			i--;
		}
	}
	return (1);
}