Beispiel #1
0
int
cparsing(int argc, char** argv)
{
  int res = 0; 
  XQC_Implementation* impl;

  void* store = create_store();

  for (res = 0; res < argc; res++) {
    printf("####%s\n", argv[res]);
  }

  if ( zorba_implementation(&impl, store) != XQC_NO_ERROR)
    return 1;

  printf("executing C parsing example 1\n");
  res = cparsing_example_1(impl);
  if (!res) { impl->free(impl); return 1; };
  printf("\n");

  printf("executing C parsing example 2\n");
  res = cparsing_example_2(impl);
  if (!res) { impl->free(impl); return 1; };
  printf("\n");

  printf("executing C parsing example 3\n");
  res = cparsing_example_3(impl);
  if (!res) { impl->free(impl); return 1; };
  printf("\n");

  impl->free(impl);
  shutdown_store(store);
  return 0;
}
Beispiel #2
0
void ui_init(void)
{
    RAII_VARIABLE(GtkBuilder *, builder, gtk_builder_new(), xgtk_builder_object_unref);
    GError     *error = NULL;

    if(!gtk_builder_add_from_file(builder, UI_FILE, &error))
    {
        g_warning("%s", error->message);
        exit(1);
    }
    ui = g_malloc0_n(1, sizeof(JahUI));
    
    /* Get UI pointers from the Glade file */
    JAH_GET_WIDGET(builder, main_window, ui);
    JAH_GET_WIDGET(builder, connect_dialog, ui);
    JAH_GET_OBJECT(builder, connect_server_combobox_entry, GTK_ENTRY, ui);
    JAH_GET_OBJECT(builder, connect_username_combobox_entry, GTK_ENTRY, ui);
    JAH_GET_OBJECT(builder, statusbar, GTK_STATUSBAR, ui);
    JAH_GET_OBJECT(builder, worker_list_store, GTK_LIST_STORE, ui);
    JAH_GET_OBJECT(builder, call_client_list_view, GTK_TREE_VIEW, ui);

    gtk_builder_connect_signals(builder, NULL);

    gtk_widget_show(ui->main_window);
    
    store = create_store();
    create_view(store, ui->call_client_list_view);
    gtk_widget_show(GTK_WIDGET(ui->call_client_list_view));
}
Beispiel #3
0
int
cerror(int argc, char** argv)
{
  int res = 0; 
  XQC_Implementation* impl;

  void* store = create_store();

  if ( zorba_implementation(&impl, store) != XQC_NO_ERROR)
    return 1;

  printf("executing C example 1\n");
  res = cerror_example_1(impl);
  if (!res) { impl->free(impl); return 1; };
  printf("\n");

  printf("executing C example 2\n");
  res = cerror_example_2(impl);
  if (!res) { impl->free(impl); return 1; };
  printf("\n");

  printf("executing C example 3\n");
  res = cerror_example_3(impl);
  if (!res) { impl->free(impl); return 1; };
  printf("\n");

  impl->free(impl);
  shutdown_store(store);

  return 0;
}
__unused struct module *init()
{
	create_store();

	m.rpcs = NULL;
	m.rpc_count = 0;
	m.ns = ns;
	m.datastore = &root;

	return &m;
}
Beispiel #5
0
int
csequences(int argc, char** argv)
{
  int res = 0; 
  XQC_Implementation* impl;

  void* store = create_store();

  if ( zorba_implementation(&impl, store) != XQC_NO_ERROR)
    return 1;

  printf("executing C csequences 1\n");
  res = csequences_1(impl);
  if (!res) { impl->free(impl); return 1; };
  printf("\n");

  printf("executing C csequences 2\n");
  res = csequences_2(impl);
  if (!res) { impl->free(impl); return 1; };
  printf("\n");

  printf("executing C csequences 3\n");
  res = csequences_3(impl);
  if (!res) { impl->free(impl); return 1; };
  printf("\n");

  printf("executing C csequences 4\n");
  res = csequences_4(impl);
  if (!res) { impl->free(impl); return 1; };
  printf("\n");

  printf("executing C csequences 5\n");
  res = csequences_5(impl);
  if (!res) { impl->free(impl); return 1; };
  printf("\n");

  impl->free(impl);
  shutdown_store(store);
   
  return 0;
}
/** \brief  Create listview with compile time features
 *
 * \return  GtkScrolledWindow
 */
static GtkWidget *create_content_widget(void)
{
    GtkWidget *view;
    GtkWidget *scrolled;
    GtkTreeStore *store;
    GtkCellRenderer *text_renderer;
    GtkTreeViewColumn *column_desc;
    GtkTreeViewColumn *column_macro;
    GtkTreeViewColumn *column_state;


    scrolled = gtk_scrolled_window_new(NULL, NULL);
   store = create_store();
    view =  gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));

    text_renderer = gtk_cell_renderer_text_new();

    column_desc = gtk_tree_view_column_new_with_attributes(
            "Description", text_renderer,
            "text", 0,
            NULL);
    column_macro = gtk_tree_view_column_new_with_attributes(
            "Macro", text_renderer,
            "text", 1,
            NULL);
    column_state = gtk_tree_view_column_new_with_attributes(
            "Enabled", text_renderer,
            "text", 2,
            NULL);

    gtk_tree_view_append_column(GTK_TREE_VIEW(view), column_desc);
    gtk_tree_view_append_column(GTK_TREE_VIEW(view), column_macro);
    gtk_tree_view_append_column(GTK_TREE_VIEW(view), column_state);

    gtk_widget_set_size_request(scrolled, 800, 600);
    gtk_container_add(GTK_CONTAINER(scrolled), view);

    gtk_widget_show_all(scrolled);
    return scrolled;
}
Beispiel #7
0
void merchant_driver(int cn,int ret,int lastact)
{
	struct merchant_driver_data *dat;
        int co,in,n;
	struct msg *msg,*next;

        dat=set_data(cn,DRD_MERCHANTDRIVER,sizeof(struct merchant_driver_data));
	if (!dat) return;	// oops...

        if (ch[cn].arg) {
		dat->open=6; dat->close=23;
		merchant_driver_parse(cn,dat);
		ch[cn].arg=NULL;
	}
	if (!ch[cn].store) {
		if (dat->pricemulti) create_store(cn,dat->ignore,dat->pricemulti);
		else create_store(cn,dat->ignore,400);
		if (dat->special) {
			for (n=0; n<5; n++) add_special_store(cn);
		}
	}
	
	// loop through our messages
	for (msg=ch[cn].msg; msg; msg=next) {
		next=msg->next;

                // did we see someone?
		if (msg->type==NT_CHAR) {
			
                        co=msg->dat1;

			// dont talk to someone we cant see, and dont talk to ourself
			if (!char_see_char(cn,co) || cn==co) { remove_message(cn,msg); continue; }

			// dont talk to someone far away
			if (char_dist(cn,co)>10) { remove_message(cn,msg); continue; }

			// dont talk to the same person twice
			if (mem_check_driver(cn,co,7)) { remove_message(cn,msg); continue; }

			quiet_say(cn,"Hello %s! If you'd like to trade, say: '°c4%s, trade°c0!",ch[co].name,ch[cn].name);
			mem_add_driver(cn,co,7);
		}

                // talk back
		if (msg->type==NT_TEXT) {
			analyse_text_driver(cn,msg->dat1,(char*)msg->dat2,msg->dat3);

			if ((msg->dat1==1 || msg->dat1==2) && (co=msg->dat3)!=cn) {	// talk, and not our talk
				if (strcasestr((char*)msg->dat2,ch[cn].name) &&
				    strcasestr((char*)msg->dat2,"trade")) {
					/*if (abuser(ch[co].ID)) {
						switch(RANDOM(3)) {
                                                        case 0:		murmur(cn,"I hate cheaters."); break;
							case 1:		emote(cn,"clenches his fists and stares at %s.",ch[co].name); break;
							case 2:		murmur(cn,"I wish the cheaters would leave me alone."); break;
						}
					}*/
					ch[co].merchant=cn;
				}
			}			
		}

		// got an item?
		if (msg->type==NT_GIVE) {
			co=msg->dat1;

                        if ((in=ch[cn].citem)) {	// we still have it
				// let it vanish
				destroy_item(ch[cn].citem);
				ch[cn].citem=0;
			}
		}

                remove_message(cn,msg);
	}

        // do something. whenever possible, call do_idle with as high a tick count
	// as reasonable when doing nothing.

	if (dat->dayx) {	// we have day / night positions
		if (!opening_time(dat->open,dat->close)) {	// we're closed
                        if (dat->doorx && !is_closed(dat->doorx,dat->doory)) {	// door is still open
				if (!is_room_empty(dat->storefx,dat->storefy,dat->storetx,dat->storety)) {	// store is not empty
					quiet_say(cn,"We're closing, please leave now!");
					do_idle(cn,TICKS);
					return;
				} else {
					if (use_item_at(cn,dat->doorx,dat->doory,0)) return;
					do_idle(cn,TICKS);
					return;
				}
			}
			if (secure_move_driver(cn,dat->nightx,dat->nighty,dat->nightdir,ret,lastact)) return;
		} else {	// we're open
                        if (dat->doorx && is_closed(dat->doorx,dat->doory)) {	// door is still closed
                                if (use_item_at(cn,dat->doorx,dat->doory,0)) return;
				do_idle(cn,TICKS);
				return;			
			}

			if (secure_move_driver(cn,dat->dayx,dat->dayy,dat->daydir,ret,lastact)) return;			
		}
	} else {		// just one position
		if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,dat->dir,ret,lastact)) return;		
	}

        if (ticker>dat->last_talk+TICKS*60 && !RANDOM(25)) {
		switch(RANDOM(11)) {
			case 0:		murmur(cn,"My back itches."); break;
			case 1:		whisper(cn,"There's something stuck between your teeth."); break;
			case 2:		murmur(cn,"Oh yeah, those were the days."); break;
			case 3:		murmur(cn,"Now where did I put it?"); break;
			case 4:		murmur(cn,"Oh my, life is hard but unfair."); break;
			case 5:		murmur(cn,"Beware of the fire snails!"); break;	
			case 6:		murmur(cn,"Ishtar! Oh, what has become of us!"); break;
			case 7:		murmur(cn,"The demons will get you."); break;
			case 8:		emote(cn,"scratches %s back",hisname(cn)); break;
			case 9:		if (map[ch[cn].x+ch[cn].y*MAXMAP].flags&MF_INDOORS) emote(cn,"stares at the ceiling");
					else emote(cn,"stares at the sky");
					break;
			case 10:	emote(cn,"twiddles %s thumbs",hisname(cn)); break;

			default:	break;
		}
		
		dat->last_talk=ticker;
	}
	if (dat->special && ticker>dat->lastadd+TICKS*60*60*12) {
		add_special_store(cn);
		dat->lastadd=ticker;
	}

	if (ticker>dat->memcleartimer) {
		mem_erase_driver(cn,7);
		dat->memcleartimer=ticker+TICKS*60*60*12;
	}

        do_idle(cn,TICKS*2);
}
Beispiel #8
0
GtkWidget *
do_iconview_edit (GtkWidget *do_widget)
{
  if (!window)
    {
      GtkWidget *icon_view;
      GtkListStore *store;
      GtkCellRenderer *renderer;

      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

      gtk_window_set_screen (GTK_WINDOW (window),
                             gtk_widget_get_screen (do_widget));
      gtk_window_set_title (GTK_WINDOW (window), "Editing and Drag-and-Drop");

      g_signal_connect (window, "destroy",
                        G_CALLBACK (gtk_widget_destroyed), &window);

      store = create_store ();
      fill_store (store);

      icon_view = gtk_icon_view_new_with_model (GTK_TREE_MODEL (store));
      g_object_unref (store);

      gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (icon_view),
                                        GTK_SELECTION_SINGLE);
      gtk_icon_view_set_item_orientation (GTK_ICON_VIEW (icon_view),
                                          GTK_ORIENTATION_HORIZONTAL);
      gtk_icon_view_set_columns (GTK_ICON_VIEW (icon_view), 2);
      gtk_icon_view_set_reorderable (GTK_ICON_VIEW (icon_view), TRUE);

      renderer = gtk_cell_renderer_pixbuf_new ();
      gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (icon_view),
                                  renderer, TRUE);
      gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (icon_view),
                                          renderer,
                                          set_cell_color,
                                          NULL, NULL);

      renderer = gtk_cell_renderer_text_new ();
      gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (icon_view),
                                  renderer, TRUE);
      g_object_set (renderer, "editable", TRUE, NULL);
      g_signal_connect (renderer, "edited", G_CALLBACK (edited), icon_view);
      gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_view),
                                      renderer,
                                      "text", COL_TEXT,
                                      NULL);

      gtk_container_add (GTK_CONTAINER (window), icon_view);
    }

  if (!gtk_widget_get_visible (window))
    gtk_widget_show_all (window);
  else
    {
      gtk_widget_destroy (window);
      window = NULL;
    }

  return window;
}