⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mconf.c

📁 GNUnet是一个安全的点对点网络框架
💻 C
📖 第 1 页 / 共 2 页
字号:
                                                                     pos->                                                                     section,                                                                     pos->                                                                     option,                                                                     val->                                                                     String.                                                                     legalRange                                                                     [msel]))                    {                      show_help (pos->option,                                 gettext_noop                                 ("Internal error! (Choice invalid?)"));                      break;                    }                  return;                case DLG_EXIT_HELP:                  show_help (pos->option, pos->help);                  break;                case DLG_EXIT_ESC:                case DLG_EXIT_ERROR:                case DLG_EXIT_CANCEL:                default:                  return;                }              break;            case GNUNET_GNS_TYPE_MULTIPLE_CHOICE:              /* begin multiple choice */              val = &pos->value;              i = 0;              tlen = 2;              while (val->String.legalRange[i] != NULL)                i++;              GNUNET_GE_ASSERT (ectx, i != 0);              items = GNUNET_malloc (sizeof (DIALOG_LISTITEM) * i);              i = 0;              msel = 0;              while (val->String.legalRange[i] != NULL)                {                  items[i].name = "";                  items[i].text = val->String.legalRange[i];                  tlen += strlen (val->String.legalRange[i]) + 1;                  items[i].help = "";                  items[i].state = 0;                  tmp = val->String.val;                  while (NULL != (tmp = strstr (tmp,                                                val->String.legalRange[i])))                    {                      if (((tmp == val->String.val) ||                           (tmp[-1] == ' ')) &&                          ((strlen (tmp) ==                            strlen (val->String.legalRange[i]))                           || (tmp[strlen (val->String.legalRange[i])] ==                               ' ')))                        {                          items[i].state = 1;                          break;                        }                      tmp++;    /* make sure strstr advances */                    }                  i++;                }              st = dlg_checklist (gettext (pos->option),                                  gettext (pos->description),                                  20,                                  70, 13, i, items, " *", FLAG_CHECK, &msel);              switch (st)                {                case DLG_EXIT_OK:                  tmp = GNUNET_malloc (tlen);                  tmp[0] = '\0';                  i = 0;                  while (val->String.legalRange[i] != NULL)                    {                      if (items[i].state == 1)                        {                          strcat (tmp, items[i].text);                          strcat (tmp, " ");                        }                      i++;                    }                  if (strlen (tmp) > 0)                    tmp[strlen (tmp) - 1] = '\0';                  if (0 != GNUNET_GC_set_configuration_value_choice (cfg,                                                                     ectx,                                                                     pos->                                                                     section,                                                                     pos->                                                                     option,                                                                     tmp))                    {                      GNUNET_free (tmp);                      show_help (pos->option,                                 gettext_noop                                 ("Internal error! (Choice invalid?)"));                      break;                    }                  GNUNET_free (tmp);                  GNUNET_free (items);                  return;                case DLG_EXIT_HELP:                  show_help (pos->option, pos->help);                  break;                case DLG_EXIT_ESC:                case DLG_EXIT_ERROR:                case DLG_EXIT_CANCEL:                default:                  GNUNET_free (items);                  return;                }              GNUNET_free (items);              break;            case GNUNET_GNS_TYPE_DOUBLE:              fitem.text = GNUNET_malloc (64);              GNUNET_snprintf (fitem.text, 64, "%f", pos->value.Double.val);              fitem.text_len = strlen (fitem.text);              fitem.help = pos->help;              st = DLG_EXIT_HELP;              msel = 0;              st = dlg_form (pos->option, "", 20, 70, 15, 1, &fitem, &msel);              switch (st)                {                case DLG_EXIT_OK:                  if (1 != sscanf (fitem.text, "%lf", &dval))                    {                      show_help (pos->option,                                 gettext_noop                                 ("Invalid input, expecting floating point value."));                      break;                    }                  if (0 != GNUNET_GC_set_configuration_value_string (cfg,                                                                     ectx,                                                                     pos->                                                                     section,                                                                     pos->                                                                     option,                                                                     fitem.                                                                     text))                    {                      show_help (pos->option,                                 gettext_noop                                 ("Internal error! (Value invalid?)"));                      break;                    }                  GNUNET_free (fitem.text);                  return;                case DLG_EXIT_HELP:                  show_help (pos->option, pos->help);                  break;                default:                  break;                }              GNUNET_free (fitem.text);              break;            case GNUNET_GNS_TYPE_UINT64:              fitem.text = GNUNET_malloc (64);              GNUNET_snprintf (fitem.text, 64, "%llu", pos->value.UInt64.val);              fitem.text_len = strlen (fitem.text);              fitem.help = pos->help;              st = DLG_EXIT_HELP;              msel = 0;              while (st == DLG_EXIT_HELP)                {                  st = dlg_form (pos->option,                                 "", 20, 70, 15, 1, &fitem, &msel);                  switch (st)                    {                    case DLG_EXIT_OK:                      if (1 != sscanf (fitem.text, "%llu", &lval))                        {                          show_help (pos->option,                                     gettext_noop                                     ("Invalid input, expecting integer."));                          continue;                        }                      if ((lval < pos->value.UInt64.min) ||                          (lval > pos->value.UInt64.max))                        {                          show_help (pos->option,                                     gettext_noop                                     ("Value is not in legal range."));                          continue;                        }                      if (0 != GNUNET_GC_set_configuration_value_number (cfg,                                                                         ectx,                                                                         pos->                                                                         section,                                                                         pos->                                                                         option,                                                                         lval))                        {                          show_help (pos->option,                                     gettext_noop                                     ("Internal error! (Choice invalid?)"));                          continue;                        }                      break;                    case DLG_EXIT_HELP:                      show_help (pos->option, pos->help);                      break;                    default:                      break;                    }                }              GNUNET_free (fitem.text);              return;            default:              GNUNET_GE_BREAK (ectx, 0);              return;            }                   /* end switch type & type */          break;        default:          GNUNET_GE_BREAK (ectx, 0);          break;        }                       /* end switch type & Kind */    }                           /* end while(1) */}intmconf_mainsetup_curses (int argc,                        const char **argv,                        struct GNUNET_PluginHandle *self,                        struct GNUNET_GE_Context *e,                        struct GNUNET_GC_Configuration *cfg,                        struct GNUNET_GNS_Context *gns,                        const char *filename, int is_daemon){  int ret;  struct termios ios_org;  ectx = e;#ifndef MINGW  tcgetattr (1, &ios_org);#endif  dialog_vars.backtitle = _("GNUnet Configuration");  dialog_vars.item_help = 1;  dialog_vars.help_button = 1;  init_dialog (stdin, stderr);  run_menu (gns, GNUNET_GNS_get_tree_root (gns), cfg);  ret = 0;  if ((0 == GNUNET_GC_test_dirty (cfg)) && (0 == ACCESS (filename, R_OK)))    {      end_dialog ();      printf (_("Configuration unchanged, no need to save.\n"));    }  else    {      dialog_vars.help_button = 0;      ret = dialog_yesno (NULL,                          _("Do you wish to save your new configuration?"),                          5, 60);      end_dialog ();      if (ret == DLG_EXIT_OK)        {          if (0 != GNUNET_GC_write_configuration (cfg, filename))            {              /* error message already printed... */              ret = 1;            }          else            {              ret = 0;            }          printf (_("\nEnd of configuration.\n"));        }      else        {          ret = 0;          printf (_("\nYour configuration changes were NOT saved.\n"));        }    }#ifndef MINGW  tcsetattr (1, TCSAFLUSH, &ios_org);#endif  return ret;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -