Example #1
0
int main(int argc, char const *argv[])
{
	/* Leemos la ciudad del input */
	Layout* layout = city_layout_read(stdin);

	/* Lo imprimimos para darle el estado inicial al watcher / judge */
	city_layout_print(layout);

	/* TODO RESOLVER PROBLEMA */
	Master* m = create_master(layout);
	ordenar_colores(m->t);
	juntar_lineas_por_color(m);
	set_lines_goals(m->t);
	solve_puzzle(m, 'l');
	print_telar(m->t);
	tejer(m);

	/* TODO IMPRIMIR DECISIONES */

	print_solucion_output(m->s);
	/* Indicamos al watcher y al judge que ya terminamos */	
	printf("END\n");

	/* Liberamos memoria */
	city_layout_destroy(layout);

	return 0;
}
Example #2
0
/**
 * New master device button clicked.
 * Open up a dialog to prompt for the name, create the device on "ok".
 */
static void signal_new_md(GtkWidget *widget,
                          gpointer data)
{
    GDeviceSetup *gds;
    GtkDialog *popup;
    GtkWidget *entry,
              *label,
              *hbox;
    gint response;
    const gchar *name;

    gds = (GDeviceSetup*)data;

    popup = (GtkDialog*)gtk_dialog_new();
    gtk_container_set_border_width(GTK_CONTAINER(popup), 3);
    gtk_window_set_modal(GTK_WINDOW(popup), TRUE);
    entry = gtk_entry_new();

    label = gtk_label_new("Device Name:");
    hbox = gtk_hbox_new(FALSE, 0);

    gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, FALSE, 3);
    gtk_box_pack_end(GTK_BOX(hbox), entry, TRUE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(popup)), hbox, TRUE, FALSE, 3);

    gtk_dialog_add_button(popup, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
    gtk_dialog_add_button(popup, GTK_STOCK_OK, GTK_RESPONSE_OK);
    gtk_dialog_set_default_response(popup, GTK_RESPONSE_OK);
    gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);

    gtk_widget_show_all(GTK_WIDGET(popup));
    response = gtk_dialog_run(popup);

    if (response == GTK_RESPONSE_OK)
    {
        name = gtk_entry_get_text(GTK_ENTRY(entry));
        create_master(gds, name);
    }

    gtk_widget_hide(GTK_WIDGET(popup));
    gtk_widget_destroy(GTK_WIDGET(popup));

}
Example #3
0
File: plex.c Project: Zirak/plex
int main(int argc, char *argv[]) {
  char *cmd;

  if (argc < 2) {
    cmd = "/bin/sh";
  }
  else {
    cmd = argv[1];
  }

  int master_fd = create_master();
  if (master_fd < 0) {
    return -1;
  }

  char *pts = ptsname(master_fd);

  printf("master = %d\n", master_fd);
  printf("cpath = %s\n", pts);

  int slave_fd = open(pts, O_RDWR);
  pid_t pid = fork();

  if (pid > 0) {
    // Father
    close(slave_fd);
    father(master_fd);
  }
  else if (pid == 0) {
    // Child
    close(master_fd);
    child(slave_fd, pts, cmd);
  }
  else {
    perror("fork");
    return -1;
  }

  return 0;
}
Example #4
0
bool redis_builder::create_cluster(acl::xml& xml)
{
	// get the master redis nodes
	const char* tags = "xml/node";
	const std::vector<acl::xml_node*>& nodes = xml.getElementsByTags(tags);

	if (nodes.empty())
	{
		printf("%s: nodes null\r\n", __FUNCTION__);
		return false;
	}

	// iterate all the master nodes including their's slaves
	std::vector<acl::xml_node*>::const_iterator cit;
	for (cit = nodes.begin(); cit != nodes.end(); ++cit)
	{
		acl::redis_node* master = create_master(**cit);
		if (master != NULL)
			masters_.push_back(master);
	}

	return true;
}