Esempio n. 1
0
int main(int argc, char **argv)
{
  Ihandle *dlg;
  Ihandle *config;

  IupOpen(&argc, &argv);
  IupGLCanvasOpen();
  IupImageLibOpen();

  config = IupConfig();
  IupSetAttribute(config, "APP_NAME", "simple_paint");
  IupConfigLoad(config);

  dlg = create_main_dialog(config);

  /* show the dialog at the last position, with the last size */
  IupConfigDialogShow(config, dlg, "MainWindow");

  /* open a file from the command line (allow file association in Windows) */
  if (argc > 1 && argv[1])
  {
    const char* filename = argv[1];
    open_file(dlg, filename);
  }

  /* initialize the current file, if not already loaded */
  check_new_file(dlg);

  IupMainLoop();

  IupClose();
  return EXIT_SUCCESS;
}
Esempio n. 2
0
int diskv :: set(diskv_idx_t& idx, const void* buff, const uint32_t length)
{
    if (length > MAX_DATA_SIZE || NULL == buff)
    {
        ALARM ("params error. length[%u] length_limit[%u] buff[%p]",
                length, MAX_DATA_SIZE, buff);
        return -1;
    }

    check_new_file(length);
    MyThrowAssert(m_last_file_offset == (uint32_t)lseek(m_append_fd, 0, SEEK_END));
    MyThrowAssert(length == (uint32_t)write(m_append_fd, buff, length));
    idx.offset   = m_last_file_offset;
    idx.file_no  = m_max_file_no - 1;
    idx.data_len = length;
    m_last_file_offset += length;
    return 0;
}