Esempio n. 1
0
int main(int argc, char **argv) {
    opsoup_t ctx;
    int round = 1;
    FILE *f;

    o = &ctx;
    memset(o, 0, sizeof (opsoup_t));

    if(argc == 2 && strcmp(argv[1], "-v") == 0)
        o->verbose = 1;

    if(image_load() != 0)
        return 1;

    init_sync();

    dis_pass1();

    while(dis_pass2(round)) {
        o->nref = 0;
        round++;
    }

    label_reloc_upgrade();

    label_gen_names();

    label_sort();

    f = fopen(OUTPUT_FILE, "w");
    if(f == NULL) {
        printf("main: couldn't open '" OUTPUT_FILE "' for writing: %s\n", strerror(errno));
        return 1;
    }

    label_extern_output(f);

    dis_pass3(f);

    data_output(f);
    data_bss_output(f);

    fclose(f);

    //label_print_unused();

    return 0;
}
Esempio n. 2
0
int CmdCustom::execute (std::string& output)
{
  int rc = 0;

  // Load report configuration.
  std::string reportColumns = context.config.get ("report." + _keyword + ".columns");
  std::string reportLabels  = context.config.get ("report." + _keyword + ".labels");
  std::string reportSort    = context.config.get ("report." + _keyword + ".sort");
  std::string reportFilter  = context.config.get ("report." + _keyword + ".filter");

  std::vector <std::string> columns;
  split (columns, reportColumns, ',');
  validateReportColumns (columns);

  std::vector <std::string> labels;
  split (labels, reportLabels, ',');

  if (columns.size () != labels.size () && labels.size () != 0)
    throw format (STRING_CMD_CUSTOM_MISMATCH, _keyword);

  std::vector <std::string> sortOrder;
  split (sortOrder, reportSort, ',');
  if (sortOrder.size () != 0 &&
      sortOrder[0] != "none")
    validateSortColumns (sortOrder);

  // Add the report filter to any existing filter.
  if (reportFilter != "")
    context.cli2.addFilter (reportFilter);

  // Apply filter.
  handleRecurrence ();
  Filter filter;
  std::vector <Task> filtered;
  filter.subset (filtered);

  std::vector <int> sequence;
  if (sortOrder.size () &&
      sortOrder[0] == "none")
  {
    // Assemble a sequence vector that represents the tasks listed in
    // context.cli2._uuid_ranges, in the order in which they appear. This
    // equates to no sorting, just a specified order.
    sortOrder.clear ();
    for (auto& i : context.cli2._uuid_list)
      for (unsigned int t = 0; t < filtered.size (); ++t)
        if (filtered[t].get ("uuid") == i)
          sequence.push_back (t);
  }
  else
  {
    // There is a sortOrder, so sorting will take place, which means the initial
    // order of sequence is ascending.
    for (unsigned int i = 0; i < filtered.size (); ++i)
      sequence.push_back (i);

    // Sort the tasks.
    if (sortOrder.size ())
      sort_tasks (filtered, sequence, reportSort);
  }

  // Configure the view.
  ViewTask view;
  view.width (context.getWidth ());
  view.leftMargin (context.config.getInteger ("indent.report"));
  view.extraPadding (context.config.getInteger ("row.padding"));
  view.intraPadding (context.config.getInteger ("column.padding"));

  if (context.color ())
  {
    Color label (context.config.get ("color.label"));
    view.colorHeader (label);

    Color label_sort (context.config.get ("color.label.sort"));
    view.colorSortHeader (label_sort);

    // If an alternating row color is specified, notify the table.
    Color alternate (context.config.get ("color.alternate"));
    if (alternate.nontrivial ())
    {
      view.colorOdd (alternate);
      view.intraColorOdd (alternate);
    }
  }

  // Capture columns that are sorted.
  std::vector <std::string> sortColumns;

  // Add the break columns, if any.
  for (auto& so : sortOrder)
  {
    std::string name;
    bool ascending;
    bool breakIndicator;
    context.decomposeSortField (so, name, ascending, breakIndicator);

    if (breakIndicator)
      view.addBreak (name);

    sortColumns.push_back (name);
  }

  // Add the columns and labels.
  for (unsigned int i = 0; i < columns.size (); ++i)
  {
    Column* c = Column::factory (columns[i], _keyword);
    if (i < labels.size ())
      c->setLabel (labels[i]);

    bool sort = std::find (sortColumns.begin (), sortColumns.end (), c->name ()) != sortColumns.end ()
                  ? true
                  : false;

    view.add (c, sort);
  }

  // How many lines taken up by table header?
  int table_header = 0;
  if (context.verbose ("label"))
  {
    if (context.color () && context.config.getBoolean ("fontunderline"))
      table_header = 1;  // Underlining doesn't use extra line.
    else
      table_header = 2;  // Dashes use an extra line.
  }

  // Report output can be limited by rows or lines.
  int maxrows = 0;
  int maxlines = 0;
  context.getLimits (maxrows, maxlines);

  // Adjust for fluff in the output.
  if (maxlines)
    maxlines -= table_header
              + (context.verbose ("blank") ? 1 : 0)
              + (context.verbose ("footnote") ? context.footnotes.size () : 0)
              + (context.verbose ("affected") ? 1 : 0)
              + context.config.getInteger ("reserved.lines");  // For prompt, etc.

  // Render.
  std::stringstream out;
  if (filtered.size ())
  {
    view.truncateRows (maxrows);
    view.truncateLines (maxlines);

    out << optionalBlankLine ()
        << view.render (filtered, sequence)
        << optionalBlankLine ();

    // Print the number of rendered tasks
    if (context.verbose ("affected"))
    {
      out << (filtered.size () == 1
                ? STRING_CMD_CUSTOM_COUNT
                : format (STRING_CMD_CUSTOM_COUNTN, filtered.size ()));

      if (maxrows && maxrows < (int)filtered.size ())
        out << ", " << format (STRING_CMD_CUSTOM_SHOWN, maxrows);

      if (maxlines && maxlines < (int)filtered.size ())
        out << ", "
            << format (STRING_CMD_CUSTOM_TRUNCATED, maxlines - table_header);

      out << "\n";
    }
  }
  else
  {
    context.footnote (STRING_FEEDBACK_NO_MATCH);
    rc = 1;
  }

  feedback_backlog ();
  output = out.str ();
  return rc;
}
Esempio n. 3
0
int CmdCustom::execute (std::string& output)
{
  int rc = 0;

  // Load report configuration.
  std::string reportColumns = context.config.get ("report." + _keyword + ".columns");
  std::string reportLabels  = context.config.get ("report." + _keyword + ".labels");
  std::string reportSort    = context.config.get ("report." + _keyword + ".sort");
  std::string reportFilter  = context.config.get ("report." + _keyword + ".filter");
  if (reportFilter != "")
    reportFilter = "( " + reportFilter + " )";

  std::vector <std::string> columns;
  split (columns, reportColumns, ',');
  validateReportColumns (columns);

  std::vector <std::string> labels;
  split (labels, reportLabels, ',');

  if (columns.size () != labels.size () && labels.size () != 0)
    throw format (STRING_CMD_CUSTOM_MISMATCH, _keyword);

  std::vector <std::string> sortOrder;
  split (sortOrder, reportSort, ',');
  validateSortColumns (sortOrder);

  // Prepend the argument list with those from the report filter.
  context.cli.addRawFilter (reportFilter);

  // Apply filter.
  handleRecurrence ();
  Filter filter;
  std::vector <Task> filtered;
  filter.subset (filtered);

  // Sort the tasks.
  std::vector <int> sequence;
  for (unsigned int i = 0; i < filtered.size (); ++i)
    sequence.push_back (i);

  sort_tasks (filtered, sequence, reportSort);

  // Configure the view.
  ViewTask view;
  view.width (context.getWidth ());
  view.leftMargin (context.config.getInteger ("indent.report"));
  view.extraPadding (context.config.getInteger ("row.padding"));
  view.intraPadding (context.config.getInteger ("column.padding"));

  Color label (context.config.get ("color.label"));
  view.colorHeader (label);

  Color label_sort (context.config.get ("color.label.sort"));
  view.colorSortHeader (label_sort);

  Color alternate (context.config.get ("color.alternate"));
  view.colorOdd (alternate);
  view.intraColorOdd (alternate);

  // Capture columns that are sorted.
  std::vector <std::string> sortColumns;

  // Add the break columns, if any.
  std::vector <std::string>::iterator so;
  for (so = sortOrder.begin (); so != sortOrder.end (); ++so)
  {
    std::string name;
    bool ascending;
    bool breakIndicator;
    context.decomposeSortField (*so, name, ascending, breakIndicator);

    if (breakIndicator)
      view.addBreak (name);

    sortColumns.push_back (name);
  }

  // Add the columns and labels.
  for (unsigned int i = 0; i < columns.size (); ++i)
  {
    Column* c = Column::factory (columns[i], _keyword);
    if (i < labels.size ())
      c->setLabel (labels[i]);

    bool sort = std::find (sortColumns.begin (), sortColumns.end (), c->name ()) != sortColumns.end ()
                  ? true
                  : false;

    view.add (c, sort);
  }

  // How many lines taken up by table header?
  int table_header = 0;
  if (context.verbose ("label"))
  {
    if (context.color () && context.config.getBoolean ("fontunderline"))
      table_header = 1;  // Underlining doesn't use extra line.
    else
      table_header = 2;  // Dashes use an extra line.
  }

  // Report output can be limited by rows or lines.
  int maxrows = 0;
  int maxlines = 0;
  context.getLimits (maxrows, maxlines);

  // Adjust for fluff in the output.
  if (maxlines)
    maxlines -= table_header
              + (context.verbose ("blank") ? 1 : 0)
              + (context.verbose ("footnote") ? context.footnotes.size () : 0)
              + (context.verbose ("affected") ? 1 : 0)
              + context.config.getInteger ("reserved.lines");  // For prompt, etc.

  // Render.
  std::stringstream out;
  if (filtered.size ())
  {
    view.truncateRows (maxrows);
    view.truncateLines (maxlines);

    out << optionalBlankLine ()
        << view.render (filtered, sequence)
        << optionalBlankLine ();

    // Print the number of rendered tasks
    if (context.verbose ("affected"))
    {
      out << (filtered.size () == 1
                ? STRING_CMD_CUSTOM_COUNT
                : format (STRING_CMD_CUSTOM_COUNTN, filtered.size ()));

      if (maxrows && maxrows < (int)filtered.size ())
        out << ", " << format (STRING_CMD_CUSTOM_SHOWN, maxrows);

      if (maxlines && maxlines < (int)filtered.size ())
        out << ", "
            << format (STRING_CMD_CUSTOM_TRUNCATED, maxlines - table_header);

      out << "\n";
    }
  }
  else
  {
    context.footnote (STRING_FEEDBACK_NO_MATCH);
    rc = 1;
  }

  feedback_backlog ();
  output = out.str ();
  return rc;
}
Esempio n. 4
0
void File_Browser::menu_update()
{
    //DJV_DEBUG("File_Browser::menu_update");

    Menu_Item_Group group;

    const List<Shortcut> & shortcut = File_Browser_Prefs::global()->shortcut();

    // Menu:
    //
    // Directory
    // * Up
    // * Previous
    // * Recent
    //   * ...
    //   ---
    // * Current
    // * Home
    // * Desktop
    // * Root
    //   ---
    // * Reload
    //
    // Options
    // * Image Thumbnails
    //   * ...
    // * File Sequencing
    //   * ...
    //   ---
    // * File Types
    //   * ...
    // * Hidden Files
    //   ---
    // * Sort By
    //   * ...
    // * Reverse Sort
    // * Sort Directories First
    //   ---
    // * Navigate
    //   * ...
    //
    // Bookmarks
    // * Add
    // * Delete
    // * Delete All
    //   ---
    // * ...

    group.add(menu_directory, 0, 0, 0, Menu_Item::SUB_MENU);

    group.add(
        menu_directory_up,
        shortcut[File_Browser_Prefs::UP].value,
        _up_callback,
        this);

    group.add(
        menu_directory_prev,
        shortcut[File_Browser_Prefs::PREV].value,
        _prev_callback,
        this);

    group.add(
        menu_directory_recent,
        0,
        0,
        0,
        Menu_Item::SUB_MENU | Menu_Item::DIVIDER);

    _menu_recent = group.add(
        File_Browser_Prefs::global()->recent(),
        List<int>(),
        _recent_callback,
        this);

    group.end();

    group.add(
        menu_directory_current,
        shortcut[File_Browser_Prefs::CURRENT].value,
        _current_callback,
        this);

# if ! defined(DJV_WINDOWS)

    group.add(
        menu_directory_home,
        shortcut[File_Browser_Prefs::HOME].value,
        _home_callback,
        this);

# endif // DJV_WINDOWS

    group.add(
        menu_directory_desktop,
        shortcut[File_Browser_Prefs::DESKTOP].value,
        _desktop_callback,
        this);

# if defined(DJV_WINDOWS)

    group.add(
        menu_directory_drive,
        0,
        0,
        0,
        Menu_Item::SUB_MENU | Menu_Item::DIVIDER);

    _menu_drive = group.add(
        directory::drives(),
        List<int>(),
        _drive_callback,
        this);

    group.end();

# else // DJV_WINDOWS

    group.add(
        menu_directory_root,
        shortcut[File_Browser_Prefs::ROOT].value,
        _root_callback,
        this,
        Menu_Item::DIVIDER);

# endif // DJV_WINDOWS

    group.add(
        menu_directory_reload,
        shortcut[File_Browser_Prefs::RELOAD].value,
        _reload_callback,
        this);

    group.end();

    group.add(menu_option, 0, 0, 0, Menu_Item::SUB_MENU);

    group.add(menu_option_image, 0, 0, 0, Menu_Item::SUB_MENU);
    
    _menu_image = group.add(
        label_image(),
        List<int>(),
        _image_callback,
        this,
        Menu_Item::RADIO,
        _image);
    
    group.end();

    group.add(menu_option_seq, 0, 0, 0, Menu_Item::SUB_MENU);
    
    _menu_seq = group.add(
        Seq::label_compress(),
        List<int>() <<
        shortcut[File_Browser_Prefs::SEQ_OFF].value <<
        shortcut[File_Browser_Prefs::SEQ_SPARSE].value <<
        shortcut[File_Browser_Prefs::SEQ_RANGE].value,
        _seq_callback,
        this,
        Menu_Item::RADIO,
        _seq);
    
    group.end();

    group.add(menu_option_type, 0, 0, 0, Menu_Item::SUB_MENU);
    
    _menu_type = group.add(
        _type_label,
        List<int>(),
        _type_callback,
        this,
        Menu_Item::RADIO,
        _type + 1);

    group.end();

    group.add(
        menu_option_hidden,
        shortcut[File_Browser_Prefs::HIDDEN].value,
        _hidden_callback,
        this,
        Menu_Item::TOGGLE | Menu_Item::DIVIDER,
        _hidden);

    group.add(menu_option_sort, 0, 0, 0, Menu_Item::SUB_MENU);
    
    _menu_sort = group.add(
        label_sort(),
        List<int>() <<
        shortcut[File_Browser_Prefs::SORT_NAME].value <<
        shortcut[File_Browser_Prefs::SORT_SIZE].value <<
#       if ! defined(DJV_WINDOWS)
        shortcut[File_Browser_Prefs::SORT_USER].value <<
#       endif
        shortcut[File_Browser_Prefs::SORT_TIME].value,
        _sort_callback,
        this,
        Menu_Item::RADIO,
        _sort);

    group.end();

    group.add(
        menu_option_sort_reverse,
        shortcut[File_Browser_Prefs::SORT_REVERSE].value,
        _sort_reverse_callback,
        this,
        Menu_Item::TOGGLE,
        _sort_reverse);

    group.add(
        menu_option_sort_directory,
        shortcut[File_Browser_Prefs::SORT_DIRECTORY].value,
        _sort_directory_callback,
        this,
        Menu_Item::TOGGLE | Menu_Item::DIVIDER,
        _sort_directory);

    group.add(menu_option_navigate, 0, 0, 0, Menu_Item::SUB_MENU);
    
    _menu_navigate = group.add(
        label_navigate(),
        List<int>(),
        _navigate_callback,
        this,
        Menu_Item::RADIO,
        File_Browser_Prefs::global()->navigate());
    
    group.end();

    group.end();

    group.add(menu_bookmark, 0, 0, 0, Menu_Item::SUB_MENU);

    group.add(
        menu_bookmark_add,
        shortcut[File_Browser_Prefs::BOOKMARK_ADD].value,
        _bookmark_add_callback,
        this);

    group.add(
        menu_bookmark_del,
        0,
        _bookmark_del_callback,
        this);

    group.add(
        menu_bookmark_del_all,
        0,
        _bookmark_del_all_callback,
        this,
        Menu_Item::DIVIDER);

    _menu_bookmark = group.add(
        File_Browser_Prefs::global()->bookmark(), List<int>() <<
        shortcut[File_Browser_Prefs::BOOKMARK_1].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_2].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_3].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_4].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_5].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_6].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_7].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_8].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_9].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_10].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_11].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_12].value,
        _bookmark_callback,
        this);

    group.end();

    group.end();

    _menu->set(group);
}