コード例 #1
0
int main (int argc, char *argv[])
{
    int i;
    int result = 0;
    iolib_open ();
    strlib_open ();
    mathlib_open ();

    lua_register("argv", lua_getargv);

    if (argc < 2)
        manual_input();
    else
    {
        for (i=1; i<argc; i++)
            if (strcmp(argv[i], "--") == 0)
            {
                lua_argc = argc-i-1;
                lua_argv = argv+i;
                break;
            }
        for (i=1; i<argc; i++)
        {
            if (strcmp(argv[i], "--") == 0)
                break;
            else if (strcmp(argv[i], "-") == 0)
                manual_input();
            else if (strcmp(argv[i], "-v") == 0)
                printf("%s  %s\n(written by %s)\n\n",
                       LUA_VERSION, LUA_COPYRIGHT, LUA_AUTHORS);
            else
            {
                result = lua_dofile (argv[i]);
                if (result)
                    fprintf(stderr, "lua: error trying to run file %s\n", argv[i]);
            }
        }
    }
    return result;
}
コード例 #2
0
ファイル: lua.c プロジェクト: sunaku/swig-ruby-ffi
static int pmain (lua_State *l) {
  struct Smain *s = (struct Smain *)lua_touserdata(l, 1);
  int status;
  int interactive = 0;
  if (s->argv[0] && s->argv[0][0]) progname = s->argv[0];
  L = l;
  lua_userinit(l);  /* open libraries */
  status = handle_luainit();
  if (status == 0) {
    status = handle_argv(s->argv, &interactive);
    if (status == 0 && interactive) manual_input();
  }
  s->status = status;
  return 0;
}
コード例 #3
0
ファイル: seiseki_sort_6.c プロジェクト: Ry0/cpp_learning
  /*データ入力*/
void input(student a[], int stu, int sub){
  int judge,retry,errer_counter=0;
  int i,j;

  while(1){
      printf("成績データをマニュアル入力\t・・・(0)\n乱数で一連の動作を確認\t\t・・・(1)\n外部データの読み込みを行う\t・・・(2)\n");
      scanf("%d", &judge);
      if(judge==0){
        manual_input(a, stu, sub);
        break;
      }else if(judge==1){
        random_input(a, stu, sub);
        break;
      }else if(judge==2){
        external_data_input(a, stu, sub);
        break;
      }else{
        printf("0,1,2のいずれかを入力してください\n");
      }
    }
}
コード例 #4
0
int main (int argc, char *argv[])
{
    int i;
    lua_open();
    lua_pushstring("> ");
    lua_setglobal("_PROMPT");
    lua_userinit();
    if (argc < 2) {  /* no arguments? */
        if (isatty(0)) {
            printf("%s  %s\n", LUA_VERSION, LUA_COPYRIGHT);
            manual_input(1);
        }
        else
            ldo(lua_dofile, NULL);  /* executes stdin as a file */
    }
    else for (i=1; i<argc; i++) {
            if (argv[i][0] == '-') {  /* option? */
                switch (argv[i][1]) {
                case 0:
                    ldo(lua_dofile, NULL);  /* executes stdin as a file */
                    break;
                case 'i':
                    manual_input(1);
                    break;
                case 'q':
                    manual_input(0);
                    break;
                case 'd':
                    lua_setdebug(1);
                    break;
                case 'v':
                    printf("%s  %s\n(written by %s)\n\n",
                           LUA_VERSION, LUA_COPYRIGHT, LUA_AUTHORS);
                    break;
                case 'e':
                    i++;
                    if (ldo(lua_dostring, argv[i]) != 0) {
                        fprintf(stderr, "lua: error running argument `%s'\n", argv[i]);
                        return 1;
                    }
                    break;
                default:
                    print_message();
                    exit(1);
                }
            }
            else if (strchr(argv[i], '='))
                assign(argv[i]);
            else {
                int result = ldo(lua_dofile, argv[i]);
                if (result) {
                    if (result == 2) {
                        fprintf(stderr, "lua: cannot execute file ");
                        perror(argv[i]);
                    }
                    exit(1);
                }
            }
        }
#ifdef DEBUG
    lua_close();
#endif
    return 0;
}
コード例 #5
0
ファイル: lua.c プロジェクト: sunaku/swig-ruby-ffi
static int handle_argv (char *argv[], int *interactive) {
  if (argv[1] == NULL) {  /* no more arguments? */
    if (stdin_is_tty()) {
      print_version();
      manual_input();
    }
    else
      file_input(NULL);  /* executes stdin as a file */
  }
  else {  /* other arguments; loop over them */
    int i;
    for (i = 1; argv[i] != NULL; i++) {
      if (argv[i][0] != '-') break;  /* not an option? */
      switch (argv[i][1]) {  /* option */
        case '-': {  /* `--' */
          if (argv[i][2] != '\0') {
            print_usage();
            return 1;
          }
          i++;  /* skip this argument */
          goto endloop;  /* stop handling arguments */
        }
        case '\0': {
          file_input(NULL);  /* executes stdin as a file */
          break;
        }
        case 'i': {
          *interactive = 1;
          break;
        }
        case 'v': {
          print_version();
          break;
        }
        case 'e': {
          const char *chunk = argv[i] + 2;
          if (*chunk == '\0') chunk = argv[++i];
          if (chunk == NULL) {
            print_usage();
            return 1;
          }
          if (dostring(chunk, "=<command line>") != 0)
            return 1;
          break;
        }
        case 'l': {
          const char *filename = argv[i] + 2;
          if (*filename == '\0') filename = argv[++i];
          if (filename == NULL) {
            print_usage();
            return 1;
          }
          if (load_file(filename))
            return 1;  /* stop if file fails */
          break;
        }
        case 'c': {
          l_message(progname, "option `-c' is deprecated");
          break;
        }
        case 's': {
          l_message(progname, "option `-s' is deprecated");
          break;
        }
        default: {
          print_usage();
          return 1;
        }
      }
    } endloop:
    if (argv[i] != NULL) {
      const char *filename = argv[i];
      getargs(argv, i);  /* collect arguments */
      lua_setglobal(L, "arg");
      return file_input(filename);  /* stop scanning arguments */
    }
  }
  return 0;
}
コード例 #6
0
int main (int argc, char *argv[])
{
  int i;

  OleInitialize(NULL);

  SetConsoleTitle(LUACOM_VERSION);

#if defined(LUA4)
  lua_State *lua_state = lua_open(0);
  lua_baselibopen (lua_state);
  lua_mathlibopen (lua_state);
  lua_iolibopen   (lua_state);
  lua_strlibopen (lua_state);
#elif defined(LUA5)
  lua_State *lua_state = lua_open();
  luaopen_base (lua_state);
  luaopen_math (lua_state);
  luaopen_io   (lua_state);
  luaopen_string (lua_state);
  luaopen_table (lua_state);
#endif

  lua_pushstring(lua_state, "> "); lua_setglobal(lua_state, "_PROMPT");

  luacom_open(lua_state);
  init_windows(lua_state);
  if (argc < 2) {  /* no arguments? */
    if (isatty(0)) {
      printf("%s  %s\n", LUACOM_VERSION, LUACOM_COPYRIGHT);
      manual_input(lua_state, 1);
    }
    else
      ldo(lua_state, lua_dofile, NULL);  /* executes stdin as a file */
  }
  else for (i=1; i<argc; i++) {
    if (argv[i][0] == '-') {  /* option? */
      switch (argv[i][1]) {
        case 0:
          ldo(lua_state, lua_dofile, NULL);  /* executes stdin as a file */
          break;
        case 'i':
          manual_input(lua_state, 1);
          break;
        case 'q':
          manual_input(lua_state, 0);
          break;
        case 'v':
          printf("%s  %s\n(written by %s)\n\n",
                 LUACOM_VERSION, LUACOM_COPYRIGHT, LUACOM_AUTHORS);
          break;
        case 'e':
          i++;
          if (ldo(lua_state, lua_dostring, argv[i]) != 0) {
            fprintf(stderr, "lua: error running argument `%s'\n", argv[i]);
            return 1;
          }
          break;
        default:
          print_message();
          exit(1);
      }
    }
    else if (strchr(argv[i], '='))
      assign(lua_state, argv[i]);
    else {
      int result = ldo(lua_state, lua_dofile, argv[i]);
      if (result) {
        if (result == 2) {
          fprintf(stderr, "lua: cannot execute file ");
          perror(argv[i]);
        }
        exit(1);
      }
    }
  }

  luacom_close(lua_state);
  lua_close(lua_state);

  OleUninitialize();

  return 0;
}
コード例 #7
0
ファイル: colua.c プロジェクト: neechbear/colloquy
static int handle_argv (char *argv[], struct Options *opt) {
  if (opt->stacksize > 0) argv++;  /* skip option `-s' (if present) */
  if (*argv == NULL) {  /* no more arguments? */
    if (isatty(0)) {
      manual_input(1, 1);
    }
    else
      ldo(lua_dofile, NULL);  /* executes stdin as a file */
  }
  else {  /* other arguments; loop over them */
    int i;
    for (i = 0; argv[i] != NULL; i++) {
      if (argv[i][0] != '-') {  /* not an option? */
        if (strchr(argv[i], '='))
          assign(argv[i]);
        else
          if (file_input(argv[i]) != EXIT_SUCCESS)
            return EXIT_FAILURE;  /* stop if file fails */
        }
        else switch (argv[i][1]) {  /* option */
          case 0: {
            ldo(lua_dofile, NULL);  /* executes stdin as a file */
            break;
          }
          case 'i': {
            manual_input(0, 1);
            break;
          }
          case 'q': {
            manual_input(0, 0);
            break;
          }
          case 'c': {
            opt->toclose = 1;
            break;
          }
          case 'v': {
            print_version();
            break;
          }
          case 'e': {
            i++;
            if (argv[i] == NULL) {
              print_message();
              return EXIT_FAILURE;
            }
            if (ldo(lua_dostring, argv[i]) != 0) {
              fprintf(stderr, "colua: error running argument `%.99s'\n", argv[i]);
              return EXIT_FAILURE;
            }
            break;
          }
          case 'f': {
            i++;
            if (argv[i] == NULL) {
              print_message();
              return EXIT_FAILURE;
            }
            getargs(argv+i);  /* collect remaining arguments */
            lua_setglobal(L, "arg");
            return file_input(argv[i]);  /* stop scanning arguments */
          }
          case 's': {
            fprintf(stderr, "colua: stack size (`-s') must be the first option\n");
            return EXIT_FAILURE;
          }
          default: {
            print_message();
            return EXIT_FAILURE;
          }
        }
    }
  }
  return EXIT_SUCCESS;
}
コード例 #8
0
ファイル: mainwindow.cpp プロジェクト: londbell/doc_manager
//    ui->listWidget_2->setCurrentRow(originalRowIndex);
        ui->listWidget_2->setCurrentRow(0);
}

void MainWindow::initSignalsAndSlots()
{
    //双击表格某单元格,根据该行id,从数据库里读取信息
    connect(ui->tableWidget,SIGNAL(cellDoubleClicked(int,int)),this,SLOT(showText(int,int)));
    connect(ui->tableWidget,SIGNAL(cellClicked(int,int)),this,SLOT(updateTheRightSideBar(int,int)));
    connect(ui->menu_action_add_file,SIGNAL(triggered()),this,SLOT(addFile()));

    connect(ui->menu_action_remove_file,SIGNAL(triggered()),this,SLOT(removeDocument()));
    connect(ui->menu_action_add_category,SIGNAL(triggered()),this,SLOT(addCategory()));
    connect(ui->menu_action_remove_category,SIGNAL(triggered()),this,SLOT(removeCategory()));
    connect(ui->menu_action_change_category,SIGNAL(triggered()),this,SLOT(changeCategory()));
    connect(ui->menu_action_manual_input,SIGNAL(triggered()),this,SLOT(manual_input()));
    connect(ui->menu_action_addto_favorite,SIGNAL(triggered()),this,SLOT(add_to_favorite()));
    connect(ui->menu_action_remove_favorite,SIGNAL(triggered()),this,SLOT(remove_outof_favorite()));
    connect(searchSquare,SIGNAL(returnPressed()),this,SLOT(search()));
    connect(ui->menu_action_about,SIGNAL(triggered()),this,SLOT(about()));

    connect(ui->menu_action_open_file,SIGNAL(triggered()),this,SLOT(openFile()));
}

void MainWindow::showText(int a, int b)
{
    QMessageBox::about(this,"Tsignal",ui->tableWidget->item(a,b)->text());
}

void MainWindow::updateTheRightSideBar(int a, int b)
{