Exemplo n.º 1
0
/** Parse window style. */
void ParseWindowStyle(const TokenNode *tp) {

   const TokenNode *np;

   Assert(tp);

   for(np = tp->subnodeHead; np; np = np->next) {
      switch(np->type) {
      case TOK_FONT:
         SetFont(FONT_BORDER, np->value);
         break;
      case TOK_WIDTH:
         settings.borderWidth = ParseUnsigned(np, np->value);
         break;
      case TOK_HEIGHT:
         settings.titleHeight = ParseUnsigned(np, np->value);
         break;
      case TOK_ACTIVE:
         ParseActiveWindowStyle(np);
         break;
      case TOK_INACTIVE:
         ParseInactiveWindowStyle(np);
         break;
      default:
         InvalidTag(np, TOK_WINDOWSTYLE);
         break;
      }
   }

}
Exemplo n.º 2
0
/** Parse a swallow tray component. */
void ParseSwallow(const TokenNode *tp, TrayType *tray) {

   TrayComponentType *cp;
   const char *name;
   const char *temp;
   int width, height;

   Assert(tp);
   Assert(tray);

   name = FindAttribute(tp->attributes, NAME_ATTRIBUTE);
   if(name == NULL) {
      name = tp->value;
   }

   temp = FindAttribute(tp->attributes, WIDTH_ATTRIBUTE);
   if(temp) {
      width = ParseUnsigned(tp, temp);
   } else {
      width = 0;
   }

   temp = FindAttribute(tp->attributes, HEIGHT_ATTRIBUTE);
   if(temp) {
      height = ParseUnsigned(tp, temp);
   } else {
      height = 0;
   }

   cp = CreateSwallow(name, tp->value, width, height);
   if(cp) {
      AddTrayComponent(tray, cp);
   }

}
Exemplo n.º 3
0
Arquivo: parse.c Projeto: Nehamkin/jwm
/** Parse a spacer tray component. */
void ParseSpacer(const TokenNode *tp, TrayType *tray) {

   TrayComponentType *cp;
   int width;
   int height;
   char *str;

   Assert(tp);
   Assert(tray);

   /* Get the width. */
   str = FindAttribute(tp->attributes, WIDTH_ATTRIBUTE);
   if(str) {
      width = ParseUnsigned(tp, str);
   } else {
      width = 0;
   }

   /* Get the height. */
   str = FindAttribute(tp->attributes, HEIGHT_ATTRIBUTE);
   if(str) {
      height = ParseUnsigned(tp, str);
   } else {
      height = 0;
   }

   /* Create the spacer. */
   cp = CreateSpacer(width, height);
   if(JLIKELY(cp)) {
      AddTrayComponent(tray, cp);
   }

}
Exemplo n.º 4
0
Arquivo: parse.c Projeto: Nehamkin/jwm
/** Parse a clock tray component. */
void ParseClock(const TokenNode *tp, TrayType *tray)
{
   TrayComponentType *cp;
   const char *format;
   const char *zone;
   const char *temp;
   int width, height;

   Assert(tp);
   Assert(tray);

   format = FindAttribute(tp->attributes, "format");
   zone = FindAttribute(tp->attributes, "zone");

   temp = FindAttribute(tp->attributes, WIDTH_ATTRIBUTE);
   if(temp) {
      width = ParseUnsigned(tp, temp);
   } else {
      width = 0;
   }

   temp = FindAttribute(tp->attributes, HEIGHT_ATTRIBUTE);
   if(temp) {
      height = ParseUnsigned(tp, temp);
   } else {
      height = 0;
   }

   cp = CreateClock(format, zone, width, height);
   if(JLIKELY(cp)) {
      ParseTrayComponentActions(tp, cp, AddClockAction);
      AddTrayComponent(tray, cp);
   }

}
Exemplo n.º 5
0
Arquivo: parse.c Projeto: Nehamkin/jwm
/** Parse window style. */
void ParseWindowStyle(const TokenNode *tp)
{
   const TokenNode *np;
   const char *decorations;

   decorations = FindAttribute(tp->attributes, "decorations");
   if(decorations) {
      if(!strcmp(decorations, "motif")) {
         settings.handles = 1;
      } else if(!strcmp(decorations, "flat")) {
         settings.handles = 0;
      } else {
         ParseError(tp, "invalid WindowStyle decorations: %s\n", decorations);
      }
   } else {
      settings.handles = 0;
   }

   for(np = tp->subnodeHead; np; np = np->next) {
      switch(np->type) {
      case TOK_FONT:
         SetFont(FONT_BORDER, np->value);
         break;
      case TOK_WIDTH:
         settings.borderWidth = ParseUnsigned(np, np->value);
         break;
      case TOK_HEIGHT:
         settings.titleHeight = ParseUnsigned(np, np->value);
         break;
      case TOK_CORNER:
         settings.cornerRadius = ParseUnsigned(np, np->value);
         break;
      case TOK_ACTIVE:
         ParseActiveWindowStyle(np);
         break;
      case TOK_FOREGROUND:
         SetColor(COLOR_TITLE_FG, np->value);
         break;
      case TOK_BACKGROUND:
         ParseGradient(np->value, COLOR_TITLE_BG1, COLOR_TITLE_BG2);
         break;
      case TOK_OUTLINE:
         SetColor(COLOR_BORDER_LINE, np->value);
         break;
      case TOK_OPACITY:
         settings.inactiveClientOpacity = ParseOpacity(tp, np->value);
         break;
      default:
         InvalidTag(np, TOK_WINDOWSTYLE);
         break;
      }
   }
}
Exemplo n.º 6
0
void cRawParser::ParseCID(cXmlNode& node) {
    USE_PREFIX(node);
    cCarriedItem cid;
    cid.name = ParseString(node, wxT(RAWXML_CID), wxT("name"), NULL, useprefix).ToAscii();
    cid.nametxt = ParseString(node, wxT(RAWXML_CID), wxT("nametxt"), NULL, useprefix).ToAscii();
    cid.pluralnametxt = ParseString(node, wxT(RAWXML_CID), wxT("pluralnametxt"), NULL, useprefix).ToAscii();
    wxLogVerbose(wxString::Format(_("Adding cid %s to %s."), wxString(cid.name.c_str(), wxConvLocal).c_str(), m_output.GetFullPath().c_str()));

    cXmlNode child(node.children());
    while (child) {
        DO_CONDITION_COMMENT(child);

        if (child(RAWXML_CID_SHAPE)) {
            USE_PREFIX(child);
            cid.shape.shaped = ParseUnsigned(child, wxT(RAWXML_CID_SHAPE), wxT("shaped"));
            if (cid.shape.shaped) {
                cid.shape.shape1 = ParseString(child, wxT(RAWXML_CID_SHAPE), wxT("shape1"), NULL, useprefix).ToAscii();
                cid.shape.shape2 = ParseString(child, wxT(RAWXML_CID_SHAPE), wxT("shape1"), NULL, useprefix).ToAscii();
            } else {
                cid.shape.MakeBillboard();
                cid.shape.fts = ParseString(child, wxT(RAWXML_CID_SHAPE), wxT("ftx"), NULL, useprefix).ToAscii();
            }
            OPTION_PARSE(float, cid.shape.unk9, ParseFloat(child, wxT(RAWXML_CID_SHAPE), wxT("distance")));
            OPTION_PARSE(unsigned long, cid.shape.defaultcolour, ParseUnsigned(child, wxT(RAWXML_CID_SHAPE), wxT("defaultcolour")));
            OPTION_PARSE(float, cid.shape.scalex, ParseFloat(child, wxT(RAWXML_CID_SHAPE), wxT("scalex")));
            OPTION_PARSE(float, cid.shape.scaley, ParseFloat(child, wxT(RAWXML_CID_SHAPE), wxT("scaley")));
        } else if (child(RAWXML_CID_MORE)) {
            USE_PREFIX(child);
            OPTION_PARSE(unsigned long, cid.addonpack, ParseUnsigned(child, wxT(RAWXML_CID_MORE), wxT("addonpack")));
            ParseStringOption(cid.icon, child, wxT("icon"), NULL, useprefix);
        } else if (child(RAWXML_CID_EXTRA)) {
Exemplo n.º 7
0
/** Parse move mode. */
void ParseMoveMode(const TokenNode *tp) {

   const char *str;

   str = FindAttribute(tp->attributes, COORDINATES_ATTRIBUTE);
   if(str) {
      settings.moveStatusType = ParseStatusWindowType(tp, str);
   }

   str = FindAttribute(tp->attributes, DELAY_ATTRIBUTE);
   if(str) {
      settings.desktopDelay = ParseUnsigned(tp, str);
   }

   if(JLIKELY(tp->value)) {
      if(!strcmp(tp->value, OUTLINE_VALUE)) {
         settings.moveMode = MOVE_OUTLINE;
      } else if(!strcmp(tp->value, OPAQUE_VALUE)) {
         settings.moveMode = MOVE_OPAQUE;
      } else {
         ParseError(tp, "invalid move mode: %s", tp->value);
      }
   } else {
      ParseError(tp, "move mode not specified");
   }

}
Exemplo n.º 8
0
void cRawParser::ParseGSI(cXmlNode& node) {
    USE_PREFIX(node);
	wxString name = ParseString(node, wxT(RAWXML_GSI), wxT("name"), NULL, useprefix);
    wxLogVerbose(wxString::Format(_("Adding gsi %s to %s."), name.c_str(), m_output.GetFullPath().c_str()));
	
	cGUISkinItem gsi;
		
	gsi.name = name.ToAscii();
	wxString tex = ParseString(node, wxT(RAWXML_GSI), wxT("tex"), NULL, useprefix);
	gsi.texture = tex.ToAscii();
	OPTION_PARSE(unsigned long, gsi.unk2, ParseUnsigned(node, RAWXML_GSI, "unk"));
	
	if (node.hasProp("type")) {
		gsi.gsi_type = ParseUnsigned(node, RAWXML_GSI, "type");
		
		foreach(const cXmlNode& child, node.children()) {
			USE_PREFIX(child);
			DO_CONDITION_COMMENT_FOR(child);
			
			if (child(RAWXML_GSI_POSITION)) {
				unsigned long p = HandleUnsignedContent(child.wxcontent(), child, RAWXML_GSI_POSITION);
				gsi.values.push_back(p);
			} else if (child.element()) {
				throw MakeNodeException<RCT3Exception>(wxString::Format(_("Unknown tag '%s' in gsi(%s) tag"), child.wxname().c_str(), name.c_str()), child);
			}
		}
	} else {
Exemplo n.º 9
0
static void
ParseExtensionValue(const char *p, const char *end, int16_t &value_r)
{
  int value = ParseUnsigned(p, end);
  if (value >= 0)
    value_r = value;
}
Exemplo n.º 10
0
Arquivo: parse.c Projeto: Nehamkin/jwm
/** Parse a menu. */
Menu *ParseMenu(const TokenNode *start)
{
   const char *value;
   Menu *menu;

   menu = Allocate(sizeof(Menu));

   value = FindAttribute(start->attributes, HEIGHT_ATTRIBUTE);
   if(value) {
      menu->itemHeight = ParseUnsigned(start, value);
   } else {
      menu->itemHeight = 0;
   }

   value = FindAttribute(start->attributes, LABELED_ATTRIBUTE);
   if(value && !strcmp(value, TRUE_VALUE)) {
      value = FindAttribute(start->attributes, LABEL_ATTRIBUTE);
      if(!value) {
         value = DEFAULT_TITLE;
      }
      menu->label = CopyString(value);
   } else {
      menu->label = NULL;
   }

   menu->items = NULL;
   ParseMenuItem(start->subnodeHead, menu, NULL);

   return menu;

}
Exemplo n.º 11
0
static bool
ParseListResultsLine(WifiConfiguredNetworkInfo &dest, char *src)
{
  char *endptr;
  dest.id = ParseUnsigned(src, &endptr);
  if (endptr == src || *endptr != '\t')
    return false;

  src = endptr + 1;

  char *tab = strchr(src, '\t');
  if (tab == nullptr)
    return false;

  *tab = 0;
  dest.ssid = src;

  src = tab + 1;

  tab = strchr(src, '\t');
  if (tab != nullptr)
    *tab = 0;

  dest.bssid = src;
  return true;
}
Exemplo n.º 12
0
/** Parse a button tray component. */
void ParseTrayButton(const TokenNode *tp, TrayType *tray) {

   TrayComponentType *cp;
   const char *icon;
   const char *label;
   const char *popup;
   const char *temp;
   unsigned int width, height;
   char border;

   Assert(tp);
   Assert(tray);

   icon = FindAttribute(tp->attributes, ICON_ATTRIBUTE);
   label = FindAttribute(tp->attributes, LABEL_ATTRIBUTE);
   popup = FindAttribute(tp->attributes, POPUP_ATTRIBUTE);

   temp = FindAttribute(tp->attributes, BORDER_ATTRIBUTE);
   if(temp && !strcmp(temp, FALSE_VALUE)) {
      border = 0;
   } else {
      border = 1;
   }

   temp = FindAttribute(tp->attributes, WIDTH_ATTRIBUTE);
   if(temp) {
      width = ParseUnsigned(tp, temp);
   } else {
      width = 0;
   }

   temp = FindAttribute(tp->attributes, HEIGHT_ATTRIBUTE);
   if(temp) {
      height = ParseUnsigned(tp, temp);
   } else {
      height = 0;
   }

   cp = CreateTrayButton(icon, label, tp->value, popup, width, height, border);
   if(JLIKELY(cp)) {
      AddTrayComponent(tray, cp);
   }

}
Exemplo n.º 13
0
Arquivo: parse.c Projeto: kuailexs/jwm
/** Parse popup style. */
void ParsePopupStyle(const TokenNode *tp)
{
   static const StringMappingType enable_mapping[] = {
      { "button", POPUP_BUTTON   },
      { "clock",  POPUP_CLOCK    },
      { "false",  POPUP_NONE     },
      { "pager",  POPUP_PAGER    },
      { "task",   POPUP_TASK     },
      { "true",   POPUP_ALL      }
   };
   const TokenNode *np;
   const char *str;
   char *tok;

   tok = FindAttribute(tp->attributes, "enabled");
   if(tok) {
      settings.popupMask = POPUP_NONE;
      tok = strtok(tok, ",");
      while(tok) {
         const int x = FindValue(enable_mapping,
                                 ARRAY_LENGTH(enable_mapping), tok);
         if(JLIKELY(x >= 0)) {
            settings.popupMask |= x;
         } else {
            ParseError(tp, "invalid value for 'enabled': \"%s\"", tok);
         }
         tok = strtok(NULL, ",");
      }
   }

   str = FindAttribute(tp->attributes, "delay");
   if(str) {
      settings.popupDelay = ParseUnsigned(tp, str);
   }

   for(np = tp->subnodeHead; np; np = np->next) {
      switch(np->type) {
      case TOK_FONT:
         SetFont(FONT_POPUP, np->value);
         break;
      case TOK_FOREGROUND:
         SetColor(COLOR_POPUP_FG, np->value);
         break;
      case TOK_BACKGROUND:
         SetColor(COLOR_POPUP_BG, np->value);
         break;
      case TOK_OUTLINE:
         SetColor(COLOR_POPUP_OUTLINE, np->value);
         break;
      default:
         InvalidTag(np, TOK_POPUPSTYLE);
         break;
      }
   }

}
Exemplo n.º 14
0
RoughTime
ConstDataNode::GetAttributeRoughTime(const TCHAR *name) const
{
  const TCHAR *p = GetAttribute(name);
  if (p == nullptr)
    return RoughTime::Invalid();

  TCHAR *endptr;
  unsigned hours = ParseUnsigned(p, &endptr, 10);
  if (endptr == p || *endptr != ':' || hours >= 24)
    return RoughTime::Invalid();

  p = endptr + 1;
  unsigned minutes = ParseUnsigned(p, &endptr, 10);
  if (endptr == p || *endptr != 0 || minutes >= 60)
    return RoughTime::Invalid();

  return RoughTime(hours, minutes);
}
Exemplo n.º 15
0
/** Parse a clock tray component. */
void ParseClock(const TokenNode *tp, TrayType *tray) {

   TrayComponentType *cp;
   const char *format;
   const char *zone;
   const char *command;
   const char *temp;
   int width, height;

   Assert(tp);
   Assert(tray);

   format = FindAttribute(tp->attributes, FORMAT_ATTRIBUTE);

   zone = FindAttribute(tp->attributes, ZONE_ATTRIBUTE);

   if(tp->value && strlen(tp->value) > 0) {
      command = tp->value;
   } else {
      command = NULL;
   }

   temp = FindAttribute(tp->attributes, WIDTH_ATTRIBUTE);
   if(temp) {
      width = ParseUnsigned(tp, temp);
   } else {
      width = 0;
   }

   temp = FindAttribute(tp->attributes, HEIGHT_ATTRIBUTE);
   if(temp) {
      height = ParseUnsigned(tp, temp);
   } else {
      height = 0;
   }

   cp = CreateClock(format, zone, command, width, height);
   if(JLIKELY(cp)) {
      AddTrayComponent(tray, cp);
   }

}
Exemplo n.º 16
0
static bool
ReadUnsigned(const char *string, unsigned &out)
{
  char *endptr;
  unsigned tmp = ParseUnsigned(string, &endptr, 0);
  if (endptr == string)
    return false;

  out = tmp;
  return true;
}
Exemplo n.º 17
0
static void
ParseCommandLine(Args &args)
{
  path = args.ExpectNextPath();

#ifdef USE_GDI
  TCHAR *endptr;
  unsigned _id = ParseUnsigned(path.c_str(), &endptr);
  if (StringIsEmpty(endptr))
    id = ResourceId(_id);
#endif
}
Exemplo n.º 18
0
/**
 * Parse the first #n characters from the input string.  If the string
 * is not long enough, nothing is parsed.  This is used to account for
 * columns that are longer than specified; according to LXNav, this is
 * used for decimal places (which are ignored by this function).
 */
static void
ParseExtensionValueN(const char *p, const char *end, size_t n,
                     int16_t &value_r)
{
  if (n > (size_t)(p - end))
    /* string is too short */
    return;

  int value = ParseUnsigned(p, p + n);
  if (value >= 0)
    value_r = value;
}
Exemplo n.º 19
0
Arquivo: parse.c Projeto: kuailexs/jwm
/** Parse window style. */
void ParseWindowStyle(const TokenNode *tp)
{
   const TokenNode *np;

   settings.windowDecorations = ParseDecorations(tp);
   for(np = tp->subnodeHead; np; np = np->next) {
      switch(np->type) {
      case TOK_FONT:
         SetFont(FONT_BORDER, np->value);
         break;
      case TOK_WIDTH:
         settings.borderWidth = ParseUnsigned(np, np->value);
         break;
      case TOK_HEIGHT:
         settings.titleHeight = ParseUnsigned(np, np->value);
         break;
      case TOK_CORNER:
         settings.cornerRadius = ParseUnsigned(np, np->value);
         break;
      case TOK_ACTIVE:
         ParseActiveWindowStyle(np);
         break;
      case TOK_FOREGROUND:
         SetColor(COLOR_TITLE_FG, np->value);
         break;
      case TOK_BACKGROUND:
         ParseGradient(np->value, COLOR_TITLE_BG1, COLOR_TITLE_BG2);
         break;
      case TOK_OUTLINE:
         ParseGradient(np->value, COLOR_TITLE_DOWN, COLOR_TITLE_UP);
         break;
      case TOK_OPACITY:
         settings.inactiveClientOpacity = ParseOpacity(tp, np->value);
         break;
      default:
         InvalidTag(np, TOK_WINDOWSTYLE);
         break;
      }
   }
}
Exemplo n.º 20
0
Arquivo: parse.c Projeto: Nehamkin/jwm
/** Parse desktop configuration. */
void ParseDesktops(const TokenNode *tp) {

   TokenNode *np;
   const char *width;
   const char *height;
   int desktop;

   Assert(tp);

   width = FindAttribute(tp->attributes, WIDTH_ATTRIBUTE);
   if(width != NULL) {
      settings.desktopWidth = ParseUnsigned(tp, width);
   }
   height = FindAttribute(tp->attributes, HEIGHT_ATTRIBUTE);
   if(height != NULL) {
      settings.desktopHeight = ParseUnsigned(tp, height);
   }
   settings.desktopCount = settings.desktopWidth * settings.desktopHeight;

   desktop = 0;
   for(np = tp->subnodeHead; np; np = np->next) {
      if(desktop >= settings.desktopCount) {
         break;
      }
      switch(np->type) {
      case TOK_BACKGROUND:
         ParseDesktopBackground(-1, np);
         break;
      case TOK_DESKTOP:
         ParseDesktop(desktop, np);
         desktop += 1;
         break;
      default:
         InvalidTag(np, TOK_DESKTOPS);
         break;
      }
   }

}
Exemplo n.º 21
0
/*
 * Scan Results look like:
 * bssid                   frequency     signal_level  flags                                                   ssid
 * bc:14:01:e1:d6:78       2412          178           [WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][WPS][ESS]       FunnyMaple
 * 00:22:a4:b8:f3:31       2437          185           [WEP][ESS]                                              BELL778
 * 98:fc:11:3e:58:ea       2462          169           [WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][WPS][ESS]       Cisco54414
 * bc:14:01:e1:d6:79       2412          176           [WPA2-PSK-CCMP][ESS]
 * 44:94:fc:36:22:48       2412          173           [WPA2-PSK-CCMP][WPS][ESS]                               NETGEAR14
 *
 * Fields are delimited by single tabs.
 *
 * Items of interest which are:
 * - bssid  binary ssid
 * - signal_level a number, bigger is better.
 * - network type. A wireless router may support one or all of WEP, WPA, and WPA2.
 *                 WPA and WPA2 are handled the same. WPA/WPA2 are preferred over WEP.
 * - ssid ascii ssid. ssid could be empty if ssid broadcast is disabled.
 */
static bool
ParseScanResultsLine(WifiVisibleNetwork &dest, char *src)
{
  char *tab = strchr(src, '\t'); // seek "frequency"
  if (tab == nullptr)
    return false;

  *tab = 0;
  dest.bssid = src;

  src = tab + 1;

  src = strchr(src + 1, '\t'); // seek "signal level"
  if (src == nullptr)
    return false;

  ++src;

  char *endptr;
  dest.signal_level = ParseUnsigned(src, &endptr);
  if (endptr == src || *endptr != '\t')
    return false;

  src = endptr + 1;

  tab = strchr(src, '\t'); // seek "ssid"
  if (tab == nullptr)
    return false;

  *tab = 0;

  // src points to the flags.
  if (strstr(src, "WPA") != NULL)
    dest.security = WPA_SECURITY;
  else if (strstr(src, "WEP") != NULL)
    dest.security = WEP_SECURITY;
  else
    dest.security = OPEN_SECURITY;

  src = tab + 1;

  tab = strchr(src, '\t');
  if (tab != nullptr)
    *tab = 0;

  if (StringIsEmpty(src))
    return false;

  dest.ssid = src;
  return true;
}
Exemplo n.º 22
0
Arquivo: parse.c Projeto: Nehamkin/jwm
/** Parse a button tray component. */
void ParseTrayButton(const TokenNode *tp, TrayType *tray)
{

   TrayComponentType *cp;
   const char *icon;
   const char *label;
   const char *popup;
   const char *temp;
   unsigned int width, height;

   Assert(tp);
   Assert(tray);

   icon = FindAttribute(tp->attributes, ICON_ATTRIBUTE);
   label = FindAttribute(tp->attributes, LABEL_ATTRIBUTE);
   popup = FindAttribute(tp->attributes, "popup");

   temp = FindAttribute(tp->attributes, WIDTH_ATTRIBUTE);
   if(temp) {
      width = ParseUnsigned(tp, temp);
   } else {
      width = 0;
   }

   temp = FindAttribute(tp->attributes, HEIGHT_ATTRIBUTE);
   if(temp) {
      height = ParseUnsigned(tp, temp);
   } else {
      height = 0;
   }

   cp = CreateTrayButton(icon, label, popup, width, height);
   if(JLIKELY(cp)) {
      AddTrayComponent(tray, cp);
      ParseTrayComponentActions(tp, cp, AddTrayButtonAction);
   }

}
Exemplo n.º 23
0
bool
LX16xxConfigWidget::SaveUnsignedSetting(LX1600::Setting key, unsigned idx,
                                        LX1600::SettingsMap &settings)
{
  const std::string old_value = device.GetLX16xxSetting(key);
  unsigned value = ParseUnsigned(old_value.c_str());
  if (!SaveValue(idx, value))
    return false;

  NarrowString<32> buffer;
  buffer.UnsafeFormat("%u", value);
  settings[key] = std::string(buffer.c_str(), buffer.end());
  return true;
}
Exemplo n.º 24
0
static unsigned
WaitUnsignedValue(LXDevice &device, LX1600::Setting key,
                  unsigned default_value)
{
  PopupOperationEnvironment env;
  const auto x = device.WaitLX16xxSetting(key, env, TIMEOUT);
  if (!x.empty()) {
    char *endptr;
    unsigned long y = ParseUnsigned(x.c_str(), &endptr);
    if (endptr > x.c_str() && *endptr == 0)
      return (unsigned)y;
  }

  return default_value;
}
Exemplo n.º 25
0
bool
FlarmDevice::GetBaudRate(unsigned &baud_id, OperationEnvironment &env)
{
  TCHAR buffer[12];
  if (!GetConfig("BAUD", buffer, ARRAY_SIZE(buffer), env))
    return false;

  TCHAR *end_ptr;
  unsigned value = ParseUnsigned(buffer, &end_ptr, 10);
  if (end_ptr == buffer)
    return false;

  baud_id = value;
  return true;
}
Exemplo n.º 26
0
bool
FlarmDevice::GetRange(unsigned &range, OperationEnvironment &env)
{
  TCHAR buffer[12];
  if (!GetConfig("RANGE", buffer, ARRAY_SIZE(buffer), env))
    return false;

  TCHAR *end_ptr;
  unsigned value = ParseUnsigned(buffer, &end_ptr, 10);
  if (end_ptr == buffer)
    return false;

  range = value;
  return true;
}
Exemplo n.º 27
0
Arquivo: parse.c Projeto: Nehamkin/jwm
/** Parse snap mode for moving windows. */
void ParseSnapMode(const TokenNode *tp)
{
   const char *distance;
   static const StringMappingType mapping[] = {
      { "border", SNAP_BORDER },
      { "none",   SNAP_NONE   },
      { "screen", SNAP_SCREEN }
   };

   distance = FindAttribute(tp->attributes, "distance");
   if(distance) {
      settings.snapDistance = ParseUnsigned(tp, distance);
   }
   settings.snapMode = ParseTokenValue(mapping, ARRAY_LENGTH(mapping), tp,
                                       settings.snapMode);
}
Exemplo n.º 28
0
Arquivo: parse.c Projeto: Nehamkin/jwm
/** Parse move mode. */
void ParseMoveMode(const TokenNode *tp)
{
   const char *str;
   static const StringMappingType mapping[] = {
      { "opaque",    MOVE_OPAQUE    },
      { "outline",   MOVE_OUTLINE   }
   };

   str = FindAttribute(tp->attributes, "delay");
   if(str) {
      settings.desktopDelay = ParseUnsigned(tp, str);
   }

   settings.moveStatusType = ParseStatusWindowType(tp);
   settings.moveMode = ParseTokenValue(mapping, ARRAY_LENGTH(mapping), tp,
                                       settings.moveMode);
}
Exemplo n.º 29
0
bool
ProfileMap::Get(const TCHAR *key, unsigned &value)
{
  // Try to read the profile map
  const TCHAR *str = Get(key);
  if (str == NULL)
    return false;

  // Parse the string for a unsigned number
  TCHAR *endptr;
  unsigned tmp = ParseUnsigned(str, &endptr, 0);
  if (endptr == str)
    return false;

  // Save parsed value to output parameter value and return success
  value = tmp;
  return true;
}
Exemplo n.º 30
0
void
StatusMessageList::LoadFile(TLineReader &reader)
{
  // Init first entry
  StatusMessage current;
  current.Clear();

  /* Read from the file */
  TCHAR *buffer;
  const TCHAR *key, *value;
  while ((buffer = reader.ReadLine()) != NULL) {
    // Check valid line? If not valid, assume next record (primative, but works ok!)
    if (*buffer == _T('#') || !parse_assignment(buffer, key, value)) {
      // Global counter (only if the last entry had some data)
      if (!current.IsEmpty()) {
        list.append(current);
        current.Clear();

        if (list.full())
          break;
      }
    } else {
      if (_tcscmp(key, _T("key")) == 0) {
        if (current.key == NULL)
          current.key = UnescapeBackslash(value);
      } else if (_tcscmp(key, _T("sound")) == 0) {
        if (current.sound == NULL)
          current.sound = UnescapeBackslash(value);
      } else if (_tcscmp(key, _T("delay")) == 0) {
        TCHAR *endptr;
        unsigned ms = ParseUnsigned(value, &endptr);
        if (endptr > value)
          current.delay_ms = ms;
      } else if (_tcscmp(key, _T("hide")) == 0) {
        if (_tcscmp(value, _T("yes")) == 0)
          current.visible = false;
      }
    }
  }

  if (!current.IsEmpty())
    list.append(current);
}