コード例 #1
0
ファイル: autoexpo.c プロジェクト: frantony/magic-lantern
static MENU_SELECT_FUNC(aperture_range_set) {
    int set = av_min;
    RANGE_SET(av, 5, 100);
    
    if(!rear_dial() && same_tv && av_min - set != 0) {
        set_rear();
        iso_curve_set(NULL, delta * -1);
        ec_curve_set(NULL, delta * -1);
    }
}
コード例 #2
0
ファイル: autoexpo.c プロジェクト: frantony/magic-lantern
static MENU_SELECT_FUNC(iso_range_set) {
    int set = iso_min;
    RANGE_SET(iso, 50, 130);
    
    if(!rear_dial() && same_tv && iso_min - set != 0) {
        set_rear();
        aperture_range_set(NULL, delta);
        iso_curve_set(NULL, delta);
    }
}
コード例 #3
0
ファイル: autoexpo.c プロジェクト: frantony/magic-lantern
static MENU_SELECT_FUNC(ec_range_set) { RANGE_SET(ec, -50, 50); }
コード例 #4
0
ファイル: output.c プロジェクト: mmaruska/gnu-make
/*  Called at init.
 *  If Env. var  MAKE_COLORS is set, redefines these
 *  variables color_misc_error ....
 */
void apply_make_colors()
{
  const mapping_def_t valid_names[] = {
    {"enter", 0, &color_dir_enter},
    {"leave", 0, &color_dir_leave},
    {"message", 0, &color_misc_message},
    {"error", 0, &color_misc_error},
    {"fatal", 0, &color_misc_fatal},
    {"run", 0, &color_execution},
    {"erase", &erase_in_line_flag, 0},
  };

  int name_index = -1;
  const char * const MAKE_COLORS = getenv("MAKE_COLORS");
  const char * key_pos = MAKE_COLORS;
  const char * colon_pos = NULL;

  char_range_t name = EMPTY_RANGE; /* delimits the keyword in the EnvVar value */
  char_range_t value = EMPTY_RANGE;
  if (! MAKE_COLORS)
    return;

  /* Example: MAKE_COLORS='erase=no:enter=0;42:leave=0;41:message=0' */
  for (; key_pos != 0; key_pos = colon_pos + 1)
    {
      const char * const assign_pos = strchr(key_pos, '=');
      if (! assign_pos) {
              OS (fatal, NILF, "Assignment ('=') missing in MAKE_COLORS: \"%s\"", key_pos);
      }

      colon_pos = strchr(assign_pos, ':');
      if (! colon_pos)
        colon_pos = assign_pos + strlen(assign_pos);

      /* delimit the keyword & value */
      RANGE_SET(name, key_pos, assign_pos);
      RANGE_SET(value, assign_pos + 1, colon_pos);

      if (RANGE_LEN(name) > 0)
        {
          FIND(valid_names, key, name, name_index);
          if (name_index == -1)
            {
              char * const s = RANGE_DUP(name);
              /* so this works even in out-of-memory, when s is NULL: */
              OS (fatal, NILF, "Invalid name in MAKE_COLORS: \"%s\"", PREVENT_NULL(s));
              free(s);
            }
         }
      else
        OS (fatal, NILF, "Empty name in MAKE_COLORS: \"%s\"", key_pos);

      /* Which kind of statement do we have? */
      if (valid_names[name_index].flag_destination)
        {
          /* Boolean statement */
          int * const destination = valid_names[name_index].flag_destination;
          if (RANGE_LEN(value) <= 0)
            {
              const char * const switch_name = valid_names[name_index].key;
              OS (fatal, NILF, "Empty value for switch \"%s\" in MAKE_COLORS", switch_name);
            }
          else if (RANGE_EQUALS(value, "yes"))
            {
              // DB(DB_VERBOSE, ("Erase in line enabled\n"));
              *destination = 1;
            }
          else if (RANGE_EQUALS(value, "no"))
            {
              // DB(DB_VERBOSE, ("Erase in line disabled\n"));
              *destination = 0;
            }
          else
            {
              /* Invalid (i.e. neither "yes" nor "no") */
              const char * const switch_name = valid_names[name_index].key;
              char * const guilty_part = RANGE_DUP(value);
              OSS (fatal, NILF, "Invalid value for switch \"%s\" in MAKE_COLORS: \"%s\"", switch_name, PREVENT_NULL(guilty_part));
              free(guilty_part);
            }
        }
      else
        {
          /* Colorization statement */
          const int value_is_valid = RANGE_LEN(value) > 0;
          if (value_is_valid)
            {
              // const char * const class_name = valid_names[name_index].key;
              const char * const color = PREVENT_NULL(RANGE_DUP(value));
              const char ** const color_destination = valid_names[name_index].color_destination;
              // DB(DB_VERBOSE, ("Applying color \"%s\" to class \"%s\"\n", color, class_name));
              *color_destination = color;
            }
          else
            {
              const char_range_t guilty_range = { key_pos, colon_pos };
              char * const guilty_part = RANGE_DUP(guilty_range);
              OS(fatal, NILF, "Invalid color mapping in MAKE_COLORS: \"%s\"", PREVENT_NULL(guilty_part));
              free(guilty_part);
            }
        }

      /* Done? */
      if (colon_pos[0] == '\0')
        break;
  }
}