Esempio n. 1
0
/* function to split into different authors and first and last names.
 * and assign them. Super simplified. Assuming first-name comes first */
void split_create_authors(Book* B, char* full)
{
	int count;
	char *next;
	char first_name[56];
	char last_name[56];

	count = 0;
	next = strtok(full, " ,");
	while (next != NULL) {
		/* first names are even numbers */
		if (count % 2 == 0)
			strncpy(first_name, next, 56);
		else {
			strncpy(last_name, next, 56);
			B->authors = create_author(B, first_name, last_name);
		}
		count++;
		next = strtok(NULL, " ,");
	}
	/* possibility of just one first name */
	if (count == 1) {
		strcpy(last_name, " ");
		B->authors = create_author(B, first_name, last_name);
	}
}
Esempio n. 2
0
void show_about()
{
	GtkWidget *window;
	GtkWidget *image;
	GdkPixbuf *pixbuf;
	GtkWidget *vbox;
	GtkWidget *notebook;
	GtkWidget *scroll;
	GtkWidget *textview;
	GtkWidget *tablabel;
	GtkWidget *action_area;
	GtkWidget *button;

	hand_cursor = gdk_cursor_new (GDK_HAND2);
	regular_cursor = gdk_cursor_new (GDK_XTERM);
      

	pixbuf = gdk_pixbuf_new_from_file_at_size(SKIN_DIR"fetion.svg", 40, 40, NULL);
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
	gtk_window_set_icon(GTK_WINDOW(window), pixbuf);
	g_object_unref(pixbuf);
	gtk_window_set_title(GTK_WINDOW(window), _("About OpenFetion"));
	gtk_widget_set_usize(window, 500, 400);

	vbox = gtk_vbox_new(FALSE, 5);
	pixbuf = gdk_pixbuf_new_from_file_at_size(SKIN_DIR"fetion.svg", 98, 98, NULL);
	image = gtk_image_new_from_pixbuf(pixbuf);
	g_object_unref(pixbuf);
	gtk_box_pack_start(GTK_BOX(vbox), image, FALSE, FALSE, 0);

	notebook = gtk_notebook_new();
	gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_LEFT);
	gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 5);

	tablabel = gtk_label_new(_("Introduction"));
	scroll = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
								 GTK_POLICY_NEVER,
								 GTK_POLICY_AUTOMATIC);
	textview = gtk_text_view_new();
	create_intro(GTK_TEXT_VIEW(textview));
	gtk_container_add(GTK_CONTAINER(scroll), textview);
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
			scroll, tablabel);

	tablabel = gtk_label_new(_("About the author"));
	scroll = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
								 GTK_POLICY_NEVER,
								 GTK_POLICY_AUTOMATIC);
	textview = gtk_text_view_new();
	create_author(GTK_TEXT_VIEW(textview));
	gtk_container_add(GTK_CONTAINER(scroll), textview);
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
			scroll, tablabel);

	tablabel = gtk_label_new(_("Contributor"));
	scroll = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
								 GTK_POLICY_NEVER,
								 GTK_POLICY_AUTOMATIC);
	textview = gtk_text_view_new();
	create_contri(GTK_TEXT_VIEW(textview));
	gtk_container_add(GTK_CONTAINER(scroll), textview);
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
			scroll, tablabel);
	
	tablabel = gtk_label_new(_("License"));
	scroll = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
								 GTK_POLICY_AUTOMATIC,
								 GTK_POLICY_AUTOMATIC);
	textview = gtk_text_view_new();
	create_gpl(GTK_TEXT_VIEW(textview));
	gtk_container_add(GTK_CONTAINER(scroll), textview);
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
			scroll, tablabel);

	action_area = gtk_hbox_new(FALSE, 10);
	gtk_box_pack_start(GTK_BOX(vbox), action_area, FALSE, FALSE, 5);
	button = gtk_button_new_with_label(_("Close"));
	gtk_widget_set_usize(button, 90, 0);
	gtk_box_pack_end(GTK_BOX(action_area), button, FALSE, FALSE, 5);
	g_signal_connect(button, "clicked", G_CALLBACK(close_about), window);

	gtk_container_add(GTK_CONTAINER(window), vbox);
	gtk_widget_show_all(window);
}
Esempio n. 3
0
int
main(int argc, char **argv)
{
    struct server *s = NULL;
    pthread_t pt, ctl;
    int c, is_forward = 0;
    const char *config = SR_CONFIG_FILE;
    int daemon = 0;
    while ((c = getopt(argc,argv,"c:vhfd")) != -1)
    {
        switch(c)
        {
            case 'c':
                config = optarg;
                break;
            case 'h':
                help(argv[0]);
                exit(0);
                break;
            case 'f':
                is_forward = 1;
                break;
            case 'd':
                daemon = 1;
                break;
            case '?':
                printf("Try -h please\n");
                exit(0);
                break;
            case 'v':
                printf("dnspod-sr 0.01\n");
                exit(0);
                break;
            default:
                exit(0);
                break;
        }
    }
    sanity_test(0);
    drop_privilege("./");
    daemonrize(daemon);
    trig_signals(1);
    global_now = time(NULL);    //for read root.z
    g_nameservers[0] = g_nameservers[1] = NULL;
    init_globe();
    init_mempool();
    s = server_init();
    s->is_forward = is_forward;
    read_config(config, (char *)s->logpath, s->forward, g_nameservers);
    // add default dns server 8.8.8.8, 114.114.114.114
    if (g_nameservers[0] == NULL) {
        assert(g_nameservers[1] == NULL);
        g_nameservers[0] = strdup("119.29.29.29");
        g_nameservers[1] = strdup("8.8.4.4");
    }
    if (g_nameservers[1] == NULL) {
        if (strcmp(g_nameservers[0], "119.29.29.29") == 0) {
            g_nameservers[1] = strdup("8.8.4.4");
        } else {
            g_nameservers[1] = strdup("119.29.29.29");
        }
    }
    //
    if (create_fetcher(s, s->nfetcher) < 0)
        dns_error(0, "create worker");
    if (create_author(s, s->nquizzer) < 0)
        dns_error(0, "create author");
    if (pthread_create(&pt, NULL, (void *) time_cron, s) != 0)
        dns_error(0, "time cron error");
    if (pthread_create(&ctl, NULL, (void *)recv_update, s) != 0) {
        dns_error(0, "recv update thread error");
    }
    read_root(s->datasets, s->ttlexp);
    print_basic_debug();
    global_serv = s;
    run_sentinel(s);
    return 0;
}