Beispiel #1
0
char *
_XlcFileName(
    XLCd lcd,
    const char *category)
{
    char *siname;
    char cat[XLC_BUFSIZE], dir[XLC_BUFSIZE];
    int i, n;
    char *args[NUM_LOCALEDIR];
    char *file_name = NULL;

    if (lcd == (XLCd)NULL)
	return NULL;

    siname = XLC_PUBLIC(lcd, siname);

    if (category)
	lowercase(cat, category);
    else
	cat[0] = '\0';
    xlocaledir(dir,XLC_BUFSIZE);
    n = _XlcParsePath(dir, args, NUM_LOCALEDIR);
    for (i = 0; i < n; ++i) {
	char buf[PATH_MAX], *name;

	name = NULL;
	if ((5 + (args[i] ? strlen (args[i]) : 0) + strlen(cat)) < PATH_MAX) {
	    sprintf(buf, "%s/%s.dir", args[i], cat);
	    name = resolve_name(siname, buf, RtoL);
	}
	if (name == NULL) {
	    continue;
	}
	if (*name == '/') {
	    /* supposed to be absolute path name */
	    file_name = name;
	} else {
	    file_name = Xmalloc(2 + (args[i] ? strlen (args[i]) : 0) +
				(name ? strlen (name) : 0));
	    if (file_name != NULL)
		sprintf(file_name, "%s/%s", args[i], name);
	    Xfree(name);
	}
	if (isreadable(file_name)) {
	    break;
	}
	Xfree(file_name);
	file_name = NULL;
	/* Then, try with next dir */
    }
    return file_name;
}
Beispiel #2
0
  std::vector<int> parse_ints (const std::string& spec, int last)
  {
    std::vector<int> V;
    if (!spec.size()) throw Exception ("integer sequence specifier is empty");
    std::string::size_type start = 0, end;
    int num[3];
    int i = 0;
    try {
      do {
        end = spec.find_first_of (",:", start);
        std::string token (strip (spec.substr (start, end-start)));
        lowercase (token);
        if (token == "end") {
          if (last == std::numeric_limits<int>::max())
            throw Exception ("value of \"end\" is not known in number sequence \"" + spec + "\"");
          num[i] = last;
        }
        else num[i] = to<int> (spec.substr (start, end-start));

        char last_char = end < spec.size() ? spec[end] : '\0';
        if (last_char == ':') {
          i++;
          if (i > 2) throw Exception ("invalid number range in number sequence \"" + spec + "\"");
        }
        else {
          if (i) {
            int inc, last;
            if (i == 2) {
              inc = num[1];
              last = num[2];
            }
            else {
              inc = 1;
              last = num[1];
            }
            if (inc * (last - num[0]) < 0) inc = -inc;
            for (; (inc > 0 ? num[0] <= last : num[0] >= last) ; num[0] += inc) V.push_back (num[0]);
          }
          else V.push_back (num[0]);
          i = 0;
        }

        start = end+1;
      }
      while (end < spec.size());
    }
    catch (Exception& E) {
      throw Exception (E, "can't parse integer sequence specifier \"" + spec + "\"");
    }

    return (V);
  }
void MaskellSolidSolnPhase::initThermoXML(XML_Node& phaseNode, const std::string& id_)
{
    if (id_.size() > 0 && phaseNode.id() != id_) {
        throw CanteraError("MaskellSolidSolnPhase::initThermoXML",
                           "phasenode and Id are incompatible");
    }

    // Check on the thermo field. Must have:
    // <thermo model="MaskellSolidSolution" />
    if (phaseNode.hasChild("thermo")) {
        XML_Node& thNode = phaseNode.child("thermo");
        std::string mString = thNode.attrib("model");
        if (lowercase(mString) != "maskellsolidsolnphase") {
            throw CanteraError("MaskellSolidSolnPhase::initThermoXML",
                               "Unknown thermo model: " + mString);
        }

        // Parse the enthalpy of mixing constant
        if (thNode.hasChild("h_mix")) {
            set_h_mix(fpValue(thNode.child("h_mix").value()));
        } else {
            throw CanteraError("MaskellSolidSolnPhase::initThermoXML",
                               "Mixing enthalpy parameter not specified.");
        }

        if (thNode.hasChild("product_species")) {
            std::string product_species_name = thNode.child("product_species").value();
            product_species_index = static_cast<int>(speciesIndex(product_species_name));
            if (product_species_index == -1) {
                throw CanteraError("MaskellSolidSolnPhase::initThermoXML",
                                   "Species " + product_species_name + " not found.");
            }
            if (product_species_index == 0) {
                reactant_species_index = 1;
            } else {
                reactant_species_index = 0;
            }
        }
    } else {
        throw CanteraError("MaskellSolidSolnPhase::initThermoXML",
                           "Unspecified thermo model");
    }

    // Confirm that the phase only contains 2 species
    if (m_kk != 2) {
        throw CanteraError("MaskellSolidSolnPhase::initThermoXML",
                "MaskellSolidSolution model requires exactly 2 species.");
    }

    // Call the base initThermo, which handles setting the initial state.
    VPStandardStateTP::initThermoXML(phaseNode, id_);
}
Beispiel #4
0
/* Parse a URI string into a struct URI. Any parts of the URI that are absent
   will become NULL entries in the structure, except for the port which will be
   -1. Returns NULL on error. See RFC 3986, section 3 for syntax. */
struct uri *uri_parse(struct uri *uri, const char *uri_s)
{
    const char *p, *q;

    uri_init(uri);

    /* Scheme, section 3.1. */
    p = uri_s;
    if (!is_alpha_char(*p))
        goto fail;
    for (q = p; is_alpha_char(*q) || is_digit_char(*q) || *q == '+' || *q == '-' || *q == '.'; q++)
        ;
    if (*q != ':')
        goto fail;
    uri->scheme = mkstr(p, q);
    /* "An implementation should accept uppercase letters as equivalent to
       lowercase in scheme names (e.g., allow "HTTP" as well as "http") for the
       sake of robustness..." */
    lowercase(uri->scheme);

    /* Authority, section 3.2. */
    p = q + 1;
    if (*p == '/' && *(p + 1) == '/') {
        char *authority = NULL;

        p += 2;
        for (q = p; !(*q == '/' || *q == '?' || *q == '#' || *q == '\0'); q++)
            ;
        authority = mkstr(p, q);
        if (uri_parse_authority(uri, authority) == NULL) {
            free(authority);
            goto fail;
        }
        free(authority);

        p = q;
    }
    if (uri->port == -1)
        uri->port = scheme_default_port(uri->scheme);

    /* Path, section 3.3. We include the query and fragment in the path. The
       path is also not percent-decoded because we just pass it on to the origin
       server. */
    q = strchr(p, '\0');
    uri->path = mkstr(p, q);

    return uri;

fail:
    uri_free(uri);
    return NULL;
}
void PDSS_IonsFromNeutral::constructPDSSXML(VPStandardStateTP* tp, size_t spindex,
        const XML_Node& speciesNode,
        const XML_Node& phaseNode, const std::string& id)
{
    const XML_Node* tn = speciesNode.findByName("thermo");
    if (!tn) {
        throw CanteraError("PDSS_IonsFromNeutral::constructPDSSXML",
                           "no thermo Node for species " + speciesNode.name());
    }
    if (lowercase(tn->attrib("model")) != "ionfromneutral") {
        throw CanteraError("PDSS_IonsFromNeutral::constructPDSSXML",
                           "thermo model for species isn't IonsFromNeutral: "
                           + speciesNode.name());
    }
    const XML_Node* nsm = tn->findByName("neutralSpeciesMultipliers");
    if (!nsm) {
        throw CanteraError("PDSS_IonsFromNeutral::constructPDSSXML",
                           "no Thermo::neutralSpeciesMultipliers Node for species " + speciesNode.name());
    }

    IonsFromNeutralVPSSTP* ionPhase = dynamic_cast<IonsFromNeutralVPSSTP*>(tp);
    if (!ionPhase) {
        throw CanteraError("PDSS_IonsFromNeutral::constructPDSSXML", "Dynamic cast failed");
    }
    neutralMoleculePhase_ = ionPhase->neutralMoleculePhase_;

    std::vector<std::string> key;
    std::vector<std::string> val;

    numMult_ = ctml::getPairs(*nsm,  key, val);
    idNeutralMoleculeVec.resize(numMult_);
    factorVec.resize(numMult_);
    tmpNM.resize(neutralMoleculePhase_->nSpecies());

    for (size_t i = 0; i < numMult_; i++) {
        idNeutralMoleculeVec[i] = neutralMoleculePhase_->speciesIndex(key[i]);
        factorVec[i] =  fpValueCheck(val[i]);
    }
    specialSpecies_ = 0;
    const XML_Node* ss = tn->findByName("specialSpecies");
    if (ss) {
        specialSpecies_ = 1;
    }
    const XML_Node* sss = tn->findByName("secondSpecialSpecies");
    if (sss) {
        specialSpecies_ = 2;
    }
    add2RTln2_ = true;
    if (specialSpecies_ == 1) {
        add2RTln2_ = false;
    }
}
Beispiel #6
0
void Client::startAuth(AuthMechanism chosen_auth_mechanism)
{
	m_chosen_auth_mech = chosen_auth_mechanism;

	switch (chosen_auth_mechanism) {
		case AUTH_MECHANISM_FIRST_SRP: {
			// send srp verifier to server
			NetworkPacket resp_pkt(TOSERVER_FIRST_SRP, 0);
			char *salt, *bytes_v;
			std::size_t len_salt, len_v;
			salt = NULL;
			getSRPVerifier(getPlayerName(), m_password,
				&salt, &len_salt, &bytes_v, &len_v);
			resp_pkt
				<< std::string((char*)salt, len_salt)
				<< std::string((char*)bytes_v, len_v)
				<< (u8)((m_password == "") ? 1 : 0);
			free(salt);
			free(bytes_v);
			Send(&resp_pkt);
			break;
		}
		case AUTH_MECHANISM_SRP:
		case AUTH_MECHANISM_LEGACY_PASSWORD: {
			u8 based_on = 1;

			if (chosen_auth_mechanism == AUTH_MECHANISM_LEGACY_PASSWORD) {
				m_password = translatePassword(getPlayerName(), m_password);
				based_on = 0;
			}

			std::string playername_u = lowercase(getPlayerName());
			m_auth_data = srp_user_new(SRP_SHA256, SRP_NG_2048,
				getPlayerName().c_str(), playername_u.c_str(),
				(const unsigned char *) m_password.c_str(),
				m_password.length(), NULL, NULL);
			char *bytes_A = 0;
			size_t len_A = 0;
			SRP_Result res = srp_user_start_authentication(
				(struct SRPUser *) m_auth_data, NULL, NULL, 0,
				(unsigned char **) &bytes_A, &len_A);
			FATAL_ERROR_IF(res != SRP_OK, "Creating local SRP user failed.");

			NetworkPacket resp_pkt(TOSERVER_SRP_BYTES_A, 0);
			resp_pkt << std::string(bytes_A, len_A) << based_on;
			Send(&resp_pkt);
			break;
		}
		case AUTH_MECHANISM_NONE:
			break; // not handled in this method
	}
}
void main()
{
	char szDir[512];
	char szDir2[512];
	printf("Syndicate DEV Mode unlocker\nSupported OS: Windows XP x86/x64, Windows Vista x86/x64, Windows 7 x86/x64\nCode: Reaver\nUses \"ForceLibrary\" by yoda\n\n");
	GetCurrentDirectoryA(400, szDir);
	sprintf_s(szDir2, "%s\\TeknoSyn.dll", szDir);
	while(1)
	{
		printf("Press CTRL+C to close\nRescanning all processes\n");
		char bla[256];
		HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
		if (hProcessSnap == (HANDLE)-1) 
			return;

		PROCESSENTRY32 pe32 = {0};
		pe32.dwSize = sizeof(PROCESSENTRY32);

		BOOL bContinue = ::Process32First(hProcessSnap, &pe32);
		while (bContinue)
		{
			sprintf_s(bla, "%s", pe32.szExeFile);
			bool found = false;
			LPSTR Game = "";
			lowercase(bla);
			if(!strcmp(bla, "syndicate.exe"))
			{
				found = true;
				Game = "Syndicate";
			}
			if(found == true)
			{
				printf("%s found, injecting\n", Game);
				DWORD base = (DWORD)RemoteLoadLibrary(pe32.th32ProcessID, szDir2);
				if(base == 0) 
				{
					printf("Injection failed, make sure the dll is in same dir as this program.\n");
				}
				else
				{
					printf("Injected to base 0x%08x, have fun!\n", base);
					_getch();
					exit(0);
				}
			}
			bContinue = ::Process32Next(hProcessSnap, &pe32);
		}
		::CloseHandle(hProcessSnap);
		printf("Nothing found, rescanning in 10seconds\n");
		Sleep(10000);
	}
}
Beispiel #8
0
std::basic_string <CharType, TraitsType, AllocType>
titlecase( const std::basic_string <CharType, TraitsType, AllocType> & s )
{
	std::basic_string <CharType, TraitsType, AllocType> result = lowercase( s );
	typename std::basic_string <CharType, TraitsType, AllocType> ::iterator iter = result.begin();
	while (iter != result.end())
		{
		*iter = toupper( *iter );
		iter = std::find_if( iter, result.end(), std::not1( std::ptr_fun <int, int> ( std::isalpha ) ) );
		iter = std::find_if( iter, result.end(),            std::ptr_fun <int, int> ( std::isalpha )   );
		}
	return result;
}
Beispiel #9
0
void _nfoParse(t_infnode * ginfo, char * buffer, int bsize)
{
  int ps, n, cp;
  int nSize = 0;
  int cMax = 0;
  char * cbuffer = NULL;

  char ltoken[5][10] = {"TITLE:", "TYPE:", "COMPANY:", "LANGUAGE:", "YEAR:" };

  for(n = 0; n < 5; n++){

    nSize = strlen(ltoken[n]);
    cMax = 0;
    cbuffer = NULL;
   

    switch (n)
    {
       case 0: cbuffer = ginfo->title; cMax = 128; break;
       case 1: cbuffer = ginfo->genre; cMax = 128; break;
       case 2: cbuffer = ginfo->company; cMax = 28; break;
       case 3: cbuffer = ginfo->lang; cMax = 28; break;
       case 4: cbuffer = ginfo->year; cMax = 5; break;
    }

    for(ps = 0; ps < (bsize - nSize); ps ++)
    {
       if(memcmp(&buffer[ps], ltoken[n], nSize)!=0)
          continue; //no son iguales +1

       ps+=nSize;

       while((ps < bsize) && (buffer[ps] == ' ')) ps++;

       for(cp = 0; (cp < cMax) && (ps < bsize) && (buffer[ps] != 0x0d); ps++)
       {
          if(buffer[ps]!='"')
          {
            cbuffer[cp] = buffer[ps];
            cp++;
          }
            
       }
       cbuffer[cp] = '\0';
    }
    
    lowercase(cbuffer, true); //Primera mayus.

  }

}
Beispiel #10
0
/* convert Ruby color to C color */
rgba
convert_rb_color_to_rgba(VALUE cval)
{
  rgba my_color;

  if (is_gosu_color(cval)) return convert_gosu_to_rgba_color(cval);
    
  /* current color for actions */
  switch(TYPE(cval)) {
    char * try_color;
  case T_SYMBOL:
    try_color = lowercase(sym2string(cval));

    my_color = find_color_from_string(try_color);

    break;
  case T_ARRAY:
    my_color.red = NUM2DBL(rb_ary_entry(cval, red));
    my_color.green = NUM2DBL(rb_ary_entry(cval, green));
    my_color.blue = NUM2DBL(rb_ary_entry(cval, blue));

    if(NUM2INT(rb_funcall(cval, rb_intern("length"), 0)) > 3) 
      my_color.alpha = NUM2DBL(rb_ary_entry(cval, alpha));
    else
      my_color.alpha = 1;

    break;

    /* hex literals */
  case T_FIXNUM:
  case T_BIGNUM:
    return convert_gosu_to_rgba_color(rb_funcall(gosu_color_class(),
                                                 rb_intern("new"), 1, cval));
    break;
        
  default:
    rb_raise(rb_eArgError, "unsupported argument type for color. Got type 0x%x\n", TYPE(cval) );
  }

  /* a valid color */
  if(is_a_color(my_color))
    return my_color;

  /* special condition for when color is taken from outside range of bitmap. Color is just ignored */
  else if(not_a_color(my_color))
    return not_a_color_v;

  /* anything else should fail */
  else
    rb_raise(rb_eArgError, "invalid colour specified (negative value given)\n");
}
Beispiel #11
0
// Perform case-insensitive match of string against pattern
static int match_prefix(const char *pattern, int pattern_len, const char *str) {
  const char *or_str;
  int i, j, len, res;

  if ((or_str = (const char *) memchr(pattern, '|', pattern_len)) != NULL) {
    res = match_prefix(pattern, or_str - pattern, str);
    return res > 0 ? res :
        match_prefix(or_str + 1, (pattern + pattern_len) - (or_str + 1), str);
  }

  i = j = 0;
  res = -1;
  for (; i < pattern_len; i++, j++) {
    if (pattern[i] == '?' && str[j] != '\0') {
      continue;
    } else if (pattern[i] == '$') {
      return str[j] == '\0' ? j : -1;
    } else if (pattern[i] == '*') {
      i++;
      if (pattern[i] == '*') {
        i++;
        len = (int) strlen(str + j);
      } else {
        len = (int) strcspn(str + j, "/");
      }
      if (i == pattern_len) {
        return j + len;
      }
      do {
        res = match_prefix(pattern + i, pattern_len - i, str + j + len);
      } while (res == -1 && len-- > 0);
      return res == -1 ? -1 : j + res + len;
    } else if (lowercase(&pattern[i]) != lowercase(&str[j])) {
      return -1;
    }
  }
  return j;
}
void MolarityIonicVPSSTP::initThermoXML(XML_Node& phaseNode, const std::string& id)
{
    if ((int) id.size() > 0 && phaseNode.id() != id) {
        throw CanteraError("MolarityIonicVPSSTP::initThermoXML",
                           "phasenode and Id are incompatible");
    }

    // Check on the thermo field. Must have one of:
    //     <thermo model="MolarityIonicVPSS" />
    //     <thermo model="MolarityIonicVPSSTP" />
    if (!phaseNode.hasChild("thermo")) {
        throw CanteraError("MolarityIonicVPSSTP::initThermoXML",
                           "no thermo XML node");
    }
    XML_Node& thermoNode = phaseNode.child("thermo");
    std::string mStringa = thermoNode.attrib("model");
    std::string mString = lowercase(mStringa);
    if (mString != "molarityionicvpss" && mString != "molarityionicvpsstp") {
        throw CanteraError("MolarityIonicVPSSTP::initThermoXML",
                           "Unknown thermo model: " + mStringa + " - This object only knows \"MolarityIonicVPSSTP\" ");
    }

    // Go get all of the coefficients and factors in the activityCoefficients
    // XML block
    if (thermoNode.hasChild("activityCoefficients")) {
        XML_Node& acNode = thermoNode.child("activityCoefficients");
        for (size_t i = 0; i < acNode.nChildren(); i++) {
            XML_Node& xmlACChild = acNode.child(i);
            // Process a binary interaction
            if (lowercase(xmlACChild.name()) == "binaryneutralspeciesparameters") {
                readXMLBinarySpecies(xmlACChild);
            }
        }
    }

    // Go down the chain
    GibbsExcessVPSSTP::initThermoXML(phaseNode, id);
}
Beispiel #13
0
u32 parseImageTransform(const std::string& s)
{
	int total_transform = 0;

	std::string transform_names[8];
	transform_names[0] = "i";
	transform_names[1] = "r90";
	transform_names[2] = "r180";
	transform_names[3] = "r270";
	transform_names[4] = "fx";
	transform_names[6] = "fy";

	std::size_t pos = 0;
	while(pos < s.size())
	{
		int transform = -1;
		for(int i = 0; i <= 7; ++i)
		{
			const std::string &name_i = transform_names[i];

			if(s[pos] == ('0' + i))
			{
				transform = i;
				pos++;
				break;
			}
			else if(!(name_i.empty()) &&
				lowercase(s.substr(pos, name_i.size())) == name_i)
			{
				transform = i;
				pos += name_i.size();
				break;
			}
		}
		if(transform < 0)
			break;

		// Multiply total_transform and transform in the group D4
		int new_total = 0;
		if(transform < 4)
			new_total = (transform + total_transform) % 4;
		else
			new_total = (transform - total_transform + 8) % 4;
		if((transform >= 4) ^ (total_transform >= 4))
			new_total += 4;

		total_transform = new_total;
	}
	return total_transform;
}
Beispiel #14
0
  /*
   *   Import and initialize a ThermoPhase object
   *
   * param phaseNode This object must be the phase node of a
   *             complete XML tree
   *             description of the phase, including all of the
   *             species data. In other words while "phase" must
   *             point to an XML phase object, it must have
   *             sibling nodes "speciesData" that describe
   *             the species in the phase.
   * param id   ID of the phase. If nonnull, a check is done
   *             to see if phaseNode is pointing to the phase
   *             with the correct id.
   *
   * This routine initializes the lengths in the current object and
   * then calls the parent routine.
   */
  void IdealSolnGasVPSS::initThermoXML(XML_Node& phaseNode, std::string id) {
    IdealSolnGasVPSS::initLengths();

    if (phaseNode.hasChild("thermo")) {
      XML_Node& thermoNode = phaseNode.child("thermo");
      std::string model = thermoNode["model"];
      if (model == "IdealGasVPSS") {
	m_idealGas = 1;
      } else if (model == "IdealSolnVPSS") {
	m_idealGas = 0;
      } else {
	throw CanteraError("IdealSolnGasVPSS::initThermoXML",
			   "Unknown thermo model : " + model);
      }
    }

    /*
     * Form of the standard concentrations. Must have one of:
     *
     *     <standardConc model="unity" />
     *     <standardConc model="molar_volume" />
     *     <standardConc model="solvent_volume" />
     */
    if (phaseNode.hasChild("standardConc")) {
      if (m_idealGas) {
	throw CanteraError("IdealSolnGasVPSS::initThermoXML",
			   "standardConc node for ideal gas");
      }
      XML_Node& scNode = phaseNode.child("standardConc");
      string formStringa = scNode.attrib("model");
      string formString = lowercase(formStringa);
      if (formString == "unity") {
	m_formGC = 0;
      } else if (formString == "molar_volume") {
	m_formGC = 1;
      } else if (formString == "solvent_volume") {
	m_formGC = 2;
      } else {
	throw CanteraError("initThermoXML",
			   "Unknown standardConc model: " + formStringa);
      }
    } else {
      if (!m_idealGas) {
	throw CanteraError("initThermoXML",
			   "Unspecified standardConc model");
      }
    }

    VPStandardStateTP::initThermoXML(phaseNode, id);
  }
Beispiel #15
0
	//	Find the next list after the current active who's name contains the
	//	filter string - then make it the active_list.
	//
	void List_Container::find_next_matching(const char *filter)
	{
		for (size_t i=active_list+1; i<active_list+size(); ++i)
		{
			size_t check = i % size();
			std::string lowercase(saved_item_lists[check].get_name());
			std::transform(lowercase.begin(), lowercase.end(), lowercase.begin(), tolower);
			if (lowercase.find(filter, 0) != std::string::npos)
			{
				active_list = check;
				break;
			}
		}
	}
Beispiel #16
0
	void Run()
	{
		/*infostream<<"wrapDegrees(100.0) = "<<wrapDegrees(100.0)<<std::endl;
		infostream<<"wrapDegrees(720.5) = "<<wrapDegrees(720.5)<<std::endl;
		infostream<<"wrapDegrees(-0.5) = "<<wrapDegrees(-0.5)<<std::endl;*/
		assert(fabs(wrapDegrees(100.0) - 100.0) < 0.001);
		assert(fabs(wrapDegrees(720.5) - 0.5) < 0.001);
		assert(fabs(wrapDegrees(-0.5) - (-0.5)) < 0.001);
		assert(fabs(wrapDegrees(-365.5) - (-5.5)) < 0.001);
		assert(lowercase("Foo bAR") == "foo bar");
		assert(is_yes("YeS") == true);
		assert(is_yes("") == false);
		assert(is_yes("FAlse") == false);
	}
Beispiel #17
0
/**
 * Obtiene la tabla necesaria para poder hacer consultas
 * sobre el DBF en cuestión
 * @return Tabla de localización, NULL si hay error
 */
TABLA_LOCALIZ *componerTablaLocaliz(FICHERODBF *ficheroDBF) {
    FILA_LOCALIZ *filaLocaliz = NULL;
	CAMPO_DBF5 *campoActual;

	char terminCampos = 'X';
	int desplaz = sizeof(CABEC_DBF5);
	int i, j;
	int numCamposDBF = 0;
	unsigned int despRelativo = 0;
    
    /* TODO Adaptarlo a otros tipos de DBF */
	/* Cuenta de los campos del DBF */
	while(terminCampos != 0x0d) {
		desplaz += sizeof(CAMPO_DBF5);
		numCamposDBF++;
		terminCampos = *(ficheroDBF->fichero->content + desplaz);
	}
    
	/* Elabora una tabla auxiliar para facilitar la búsqueda */
	ficheroDBF->campos = (unsigned char *) malloc(numCamposDBF * sizeof(CAMPO_DBF5));
    memcpy(ficheroDBF->campos, ficheroDBF->fichero->content + sizeof(CABEC_DBF5), 
           numCamposDBF * sizeof(CAMPO_DBF5));
    
	for(i = 0; i < numCamposDBF; i++)
        lowercase(((CAMPO_DBF5 *)ficheroDBF->campos)[i].nombre);
        
	/* Crea la tabla de localización */
	ficheroDBF->tablaLocaliz = (TABLA_LOCALIZ *) malloc(sizeof(TABLA_LOCALIZ));
    ficheroDBF->tablaLocaliz->numCampos = numCamposDBF;
	ficheroDBF->tablaLocaliz->filas = (FILA_LOCALIZ *) malloc(numCamposDBF * sizeof(FILA_LOCALIZ));
		
    for(j = 0; j < numCamposDBF; j++) {
        filaLocaliz = ficheroDBF->tablaLocaliz->filas + j;
        campoActual = (CAMPO_DBF5 *)ficheroDBF->campos + j;
            
        memcpy(filaLocaliz->nombre, campoActual, 11);
        filaLocaliz->direcRel = despRelativo;
        filaLocaliz->longitud = campoActual->longitud;
        filaLocaliz->tipo = campoActual->tipo;
        filaLocaliz->decimales = campoActual->decimales;
                
        /*printf("%s %i %i %c %i\n", filaLocaliz->nombre, filaLocaliz->direcRel,
            filaLocaliz->longitud, filaLocaliz->tipo, filaLocaliz->decimales);*/
			
		despRelativo += campoActual->longitud;
	}
	
	return ficheroDBF->tablaLocaliz;
}
Beispiel #18
0
static const char *dict_env_lookup(DICT *dict, const char *name)
{
    dict->error = 0;

    /*
     * Optionally fold the key.
     */
    if (dict->flags & DICT_FLAG_FOLD_FIX) {
	if (dict->fold_buf == 0)
	    dict->fold_buf = vstring_alloc(10);
	vstring_strcpy(dict->fold_buf, name);
	name = lowercase(vstring_str(dict->fold_buf));
    }
    return (safe_getenv(name));
}
Beispiel #19
0
static const char *dict_ht_lookup(DICT *dict, const char *name)
{
    DICT_HT *dict_ht = (DICT_HT *) dict;

    /*
     * Optionally fold the key.
     */
    if (dict->flags & DICT_FLAG_FOLD_FIX) {
	if (dict->fold_buf == 0)
	    dict->fold_buf = vstring_alloc(10);
	vstring_strcpy(dict->fold_buf, name);
	name = lowercase(vstring_str(dict->fold_buf));
    }
    DICT_ERR_VAL_RETURN(dict, DICT_ERR_NONE, htable_find(dict_ht->table, name));
}
Beispiel #20
0
// .SetProp(entity, "property", value) Sets the property to the specified value. Value can be num, string, ptr, depends on the property.
int entity_SetProp(lua_State* ls)
{
	DEBUGOUT("entity_SetProp");
	luaCountArgs(ls, 3);

	Entity* e = _getReferencedEntity(ls);

	string prop = lowercase(lua_tostring(ls, 2));

	int result = e->LuaSetProp(ls, prop, 3);

	if (!result)
		console->AddMessage("Entity.SetProp() '" + prop + "' Unknown");

	return 0;
}
Beispiel #21
0
int	_strcasecmp(char *s1, char *s2)
{
  while (*s1 && *s2)
    {
      if (lowercase(*s1) - lowercase(*s2))
	return (lowercase(*s1) - lowercase(*s2));
      s1++;
      s2++;
    }
  return (lowercase(*s1) - lowercase(*s2));
}
Beispiel #22
0
/* error checking functions */
void
check_mask(VALUE mask) 
{
  char * try_mask;

  if(TYPE(mask) != T_ARRAY && TYPE(mask) != T_SYMBOL)
    rb_raise(rb_eArgError, "array or symbol parameter required");

  /* is it a valid mask symbol? */
  if(TYPE(mask) == T_SYMBOL) {
    try_mask = lowercase(sym2string(mask));
    if(*try_mask == '_') try_mask++;
    if(not_a_color(find_color_from_string(try_mask))) {
      rb_raise(rb_eArgError, "unrecognized mask symbol: %s\n", sym2string(mask));
    }
  }
}
Beispiel #23
0
Kinetics* KineticsFactory::newKinetics(const string& model)
{
    string lcmodel = lowercase(model);
    if (lcmodel == "none") {
        return new Kinetics();
    } else if (lcmodel == "gaskinetics") {
        return new GasKinetics();
    } else if (lcmodel == "interface") {
        return new InterfaceKinetics();
    } else if (lcmodel == "edge") {
        return new EdgeKinetics();
    } else if (lcmodel == "aqueouskinetics") {
        return new AqueousKinetics();
    } else {
        throw UnknownKineticsModel("KineticsFactory::newKinetics", model);
    }
}
Beispiel #24
0
/**
 * Transforms a word into a 64-bit signature.
 */
unsigned long long sign_word(char * word)
{
    unsigned long long sig;
    char * cursor;
    sig = 0;
    cursor = word;
    while (cursor[0] != (char)0) {
        if (sig > sig*26) {
            printf("word overflow: %s\n", word);
            exit(0);
        }
        sig *= 26;
        sig += (lowercase(cursor[0]) - 'a');
        cursor += 1;
    }
    return sig;
}
Beispiel #25
0
int main(int argc, char *argv[])
{
  char a = 'a';
  char b = 'b';
  char c = 'c';

  printf("a is less than b: %d\n", compare(&a, &b));
  printf("b is equal to b: %d\n", compare(&b, &b));
  printf("c is greater than b: %d\n", compare(&c, &b));

  printf("--------\n");

  char before = 'A';
  printf("Before: %c\n", before);
  lowercase(&before);
  printf("After: %c\n", before);
}
Beispiel #26
0
static int dict_env_update(DICT *dict, const char *name, const char *value)
{
    dict->error = 0;

    /*
     * Optionally fold the key.
     */
    if (dict->flags & DICT_FLAG_FOLD_FIX) {
	if (dict->fold_buf == 0)
	    dict->fold_buf = vstring_alloc(10);
	vstring_strcpy(dict->fold_buf, name);
	name = lowercase(vstring_str(dict->fold_buf));
    }
    if (setenv(name, value, 1))
	msg_fatal("setenv: %m");

    return (DICT_STAT_SUCCESS);
}
Beispiel #27
0
Invocation::Invocation(int argc, char ** argv) {
	time_t nowTime = time(0);
	struct tm * curTime = localtime(&nowTime);
	cout << " Start time: ";
	printColoredText(getNum(curTime->tm_hour, 2) + ":" + getNum(curTime->tm_min, 2) + ":" + getNum(curTime->tm_sec, 2) + " " + getNum(curTime->tm_mday, 2) + "." + getNum(curTime->tm_mon + 1, 2) + "." + toa((curTime->tm_year + 1900)) + "\n", CC_CYAN);
	params = new Parameters();
	info = new Information();
	SetConsoleTitleA((char *)string("ATester (Invoker " + params->getInvocationID() + ")").c_str());
	cout << " Invoker ID: ";
	printColoredText(params->getInvocationID(), CC_CYAN);
	cout << endl << endl;
	string s, t;
	for (int i = 1; i < argc; ++i) {
		s = (string)argv[i];
		t = lowercase(s);
		if (flagsDict.count(t)) cmdParams.pb(t); else cmdParams.pb(s);
	}
}
Beispiel #28
0
void Misc::processText(std::string& text) {
    std::string::iterator it = text.begin();

    while (it != text.end()) {
		lowercase(*it);

		if (*it == '<') {
			// Tag de HTML encontrado
			int itPos = std::distance(text.begin(), it);
			int closeTagPos = text.find('>', itPos);
			text.replace(itPos, closeTagPos - itPos + 1, " ");
		} else if (esPuntuacion(*it)) {
			text.erase(it);
		} else {
			++it;
		}
    }
}
Beispiel #29
0
int satisfies(char key[4]) {
    struct dec dec;
    char * tok;
    int i;

    dec_init(&dec, cipher, cipher_length, key, 3);
    while (NULL != (tok = dec_token(&dec))) {
        i=0;
        while (tok[i] != (char)0)
        {
            tok[i] = lowercase(tok[i]);
            ++i;
        }
        if (!in_dict(tok)) {
            return 0;
        }
    }
    return 1;
}
Beispiel #30
0
int main (int argc, const char * argv[]) {
    const char *filename;
    clock_t timer;
    int tableSize = 1000;
    struct hashMap* hashTable = createMap(tableSize);
    timer = clock();

    if(argc >= 2)
        filename = argv[1];
    else
        filename = "dictionary.txt"; /*specify your input text file here*/

    FILE* dictionary = fopen(filename, "r");
    if(dictionary == NULL) {
        char err[255];
        sprintf(err, "Failure opening file %s; exiting.\n", filename);
        perror(err);
        exit(EXIT_FAILURE);
    }

    loadDictionary(dictionary,hashTable);
    timer = clock() - timer;
    printf("Dictionary loaded in %f seconds\n", (float)timer / (float)CLOCKS_PER_SEC);

    char* word = (char*)malloc(256*sizeof(char));
    int quit=0;
    while(!quit) {
        printf("Enter a word: ");
        scanf("%s",word);
        if(containsKey(hashTable, lowercase(word)))
            printf("'%s' is spelled correctly.\n", word);
        else
            printf("'%s' is spelled incorrectly; please try again.\n", word);
        /* Don't remove this. It is used for grading*/
        if(strcmp(word,"quit")==0)
          quit=!quit;
    }
    free(word);

    fclose(dictionary);

    return 0;
}