示例#1
0
文件: efuns.c 项目: Elohim/FGmud
int cmd(string str){
    int i, cols = 3;
    string *ret;
    if(str) i = atoi(str);
    if(i) cols = i;
    ret = explode(format_page(efuns(), cols), "\n");
    this_player()->eventPage(ret);
    return 1;
}
示例#2
0
文件: lfuns.c 项目: Elohim/FGmud
int cmd(string str){
    int i, cols = 2;
    string *ret, *tmp;
    if(str) i = atoi(str);
    if(i) cols = i;
    tmp = sort_array(FUNCTION_D->GetFunctions(), 1);
    ret = explode(format_page(tmp, cols), "\n");
    this_player()->eventPage(ret);
    return 1;
}
示例#3
0
static GtkWidget *
add_new_page(CongNewFileAssistant *assistant, const char *text, GtkAssistantPageType type)
{
	GtkWidget *page = gtk_label_new(text);
	gtk_label_set_line_wrap(GTK_LABEL(page), TRUE);
	gtk_assistant_append_page(assistant->druid, page);
	gtk_assistant_set_page_type(assistant->druid, page, type);
	gtk_assistant_set_page_title(assistant->druid, page, _("Creating a new file"));
	format_page(assistant, page);
	return page;
}
示例#4
0
文件: faq.c 项目: arylwen/terebi
mixed cmd(string args) {
    if( !args || args == "" ) {
        string *files;
        int cols, i, maxi, x, y;

        message("help", mud_name() + " has the following FAQ lists:",
          this_player());
        cols = ((int *)this_player()->GetScreen())[0];
        i = sizeof(files = get_dir(DIR_FAQS "/"));
        while(i--) if( (y =strlen(files[i])) > x ) x = y;
        cols = cols / (x+2);
        message("help", format_page(files, cols), this_player());
        message("prompt", "\nWhich FAQ (general)? ", this_player());
        input_to( (: GetFAQ :) );
        return 1;
    }
示例#5
0
int cmd_groups(string str) {
      string label;

     mapping groups=master()->query_groups();
      string *lists=sort_array(keys(groups),-1);
      string *club;
         int countera=sizeof(lists);

    if(!str) {

       for(countera;countera>0;countera--) {
           club=({});
          label=lists[countera-1];
           club=sort_array((groups[label]),1);

         write("%^GREEN%^%^BOLD%^Group name :: %^RED%^%^BOLD%^"+label+"%^CYAN%^%^BOLD%^");
         write(format_page(club,4));
                   } // End for loop
         return 1; } // end listing of ALL groups if no str is entered
示例#6
0
/* Build the page to look more or less like GnomeDruid would have done it */
static GtkWidget *
add_new_page_with_widget(CongNewFileAssistant *assistant,
                         const char *title,
                         const char *question,
                         const char *info,
                         GtkWidget *widget)
{
	GtkWidget *page, *top_label, *bottom_label;
	char *text;

	page = gtk_vbox_new(FALSE, 0);
	if(question) {
		top_label = gtk_label_new(question);
		g_object_set(top_label,
			     "use-markup", TRUE,
			     "use-underline", TRUE,
			     "mnemonic-widget", widget,
			     "justify", GTK_JUSTIFY_LEFT,
			     "xalign", 0.0,
			     NULL);
		gtk_box_pack_start(GTK_BOX(page), top_label, FALSE, FALSE, 0);
	}
	gtk_box_pack_start(GTK_BOX(page), widget, FALSE, FALSE, 0);
	if(info) {
		text = g_strconcat("<span size=\"small\">", info, "</span>", NULL);
		bottom_label = gtk_label_new(text);
		g_free(text);
		g_object_set(bottom_label,
			     "use-markup", TRUE,
			     "justify", GTK_JUSTIFY_LEFT,
			     "xalign", 0.0,
			     "xpad", 24,
			     NULL);
		gtk_box_pack_start(GTK_BOX(page), bottom_label, FALSE, FALSE, 0);
	}

	gtk_assistant_append_page(assistant->druid, page);
	gtk_assistant_set_page_type(assistant->druid, page, GTK_ASSISTANT_PAGE_CONTENT);
	gtk_assistant_set_page_title(assistant->druid, page, title);
	gtk_assistant_set_page_complete(assistant->druid, page, TRUE);
	format_page(assistant, page);
	return page;
}
示例#7
0
文件: _discern.c 项目: ehershey/pd
int cmd_discern(string str) {
    string x, limbs;
    object tp, ob;

    tp = this_player();
    if (!abil()) {
        notify_fail("What?\n");
        return 0;
    }
    if((string)tp->query_class() != "fighter") return 0;
    if(!str) return notify_fail("Discern what?\n");
    if(tp->query_sp() < 5) {
        notify_fail("You fail.\n");
        return 0;
    }
    ob = present(str, tp);
    if(!ob) ob = parse_objects(tp, str);
    if(!ob) {
        notify_fail("No "+str+" here!\n");
        return 0;
    }
    x = (string)ob->query_type();
    if(!x) {
        notify_fail("That is neither armour or a weapon!\n");
        return 0;
    }
    if(!ob->query_wc()) {
        if(!limbs=ob->query_limbs())
            return notify_fail("That is neither armour or a weapon!\n");
        tp->add_sp(-10);
        message("info", sprintf("%s is of type %s.", capitalize(str),
                                x), tp);
        message("info", sprintf("%s covers your : ", capitalize(str)),
                tp);
        message("info", sprintf("%s", format_page(limbs, 5)), tp);
        return 1;
    }
    message("info", sprintf("%s is of type %s.", capitalize(str), x), tp);
    tp->add_sp(-5);
    return 1;
}
示例#8
0
int main(int argc, char **argv) {
  int i, m, n, lim, chk, page_format;
  FILE *fi, *fo, *f1, *f2;

  /* print usage */
  if (argc < 3) {
    printf("usage: %s <infile> <outfile> [options]\n", argv[0]);
    printf("options:\n");
    printf("  -b <buffer-number>      set buffer number, default and maximum value is 130\n");
    printf("  -db                     enable double buffering\n");
    printf("  -p                      output 1kb pages (task 2)\n");
    printf("  -c                      check correctness when sort completed (debug)\n");
    printf("  -l <record-number>      sort first <record-number> records (debug)\n");
    return -1;
  }

  /* get arguments */
  k = K;
  lim = 0x7fffffff;
  db = chk = page_format = 0;
  for (i = 3; i < argc; i++) {
    if (!strcmp(argv[i], "-b")) {
      sscanf(argv[++i], "%d", &k);
      if (k > K) {
        fprintf(stderr, "error: too many buffer pages.");
        return -1;
      }
    } else if (!strcmp(argv[i], "-l")) {
      sscanf(argv[++i], "%d", &lim);
    } else if (!strcmp(argv[i], "-c")) {
      chk = 1;
    } else if (!strcmp(argv[i], "-db")) {
      db = 1;
    } else if (!strcmp(argv[i], "-p")) {
      page_format = 1;
    }
  }
  k = k / (db + 1) - 1;
  if (k < 2) {
    fprintf(stderr, "error: too few buffer pages.");
    return -1;
  }

  /* open files */
  fi = fopen(argv[1], "rb+");
  if (!fi) {
    fprintf(stderr, "error: file '%s' is not found.\n", argv[1]);
    return -1;
  }
  if (!page_format) {
    if (!strcmp(argv[1], argv[2])) {
      fprintf(stderr, "error: infile cannot be the same as outfile.\n");
      return -1;
    }
    fo = fopen(argv[2], "wb+");
  }
  f1 = tmpfile();
  f2 = tmpfile();

  /* confirm arguments */
  printf("buffer pages:     %d\n", (k + 1) * (db + 1));
  printf("double buffering: %s\n", db ? "yes" : "no");
  printf("output 1kb pages: %s\n", page_format ? "yes" : "no");

  /* start timer */
  time_t start = time(0);
  puts("sorting...");

  /* init mutex, semaphore */
  if (db) {
    for (i = 0; i <= K; i++) {
      pthread_mutex_init(&mutex[i], 0);
      sem_init(&sem[i], 0, 0);
    }
  }
  /* extract useful data, quick sort pages individualy   */
  struct line line;
  for (n = 0; !feof(fi) && n < lim;) {
    buffer[0][n % M].p = ftell(fi);
    line_read(fi, &line);
    buffer[0][n % M].x = line.x;
    buffer[0][n % M].y = line.y;

    n++;

    if (n % M == 0 || feof(fi) || n == lim) {
      int num = n % M ? n % M : M;
      qsort(buffer[0], num, S, record_cmp);
      fwrite(buffer[0], S, num, f1);
    }
  }

  /* merge sort */
  if (db)
    merge_sort_db(f1, f2, 1, 0, n);
  else
    merge_sort(f1, f2, 1, 0, n);

  /* format from useful data to real data */
  if (page_format)
    format_page(argv[2], f1, fi, n);
  else
    format(fo, f1, fi, n);

  /* stop timer */
  time_t end = time(0);
  int sec = (int)difftime(end, start);
  printf("completed, time elapsed: %d min %d sec\n", sec / 60, sec % 60);

  /* check correctness */
  if (chk) {
    printf("checking correctness: ");
    fflush(stdout);
    if (page_format ? check_page(argv[2]) : check(fo))
      puts("yes");
    else
      puts("no");
  }

  /* close files */
  fclose(f1);
  fclose(f2);
  fclose(fi);
  if (!page_format)
    fclose(fo);

  return 0;
}