示例#1
0
MIR_APP_DLL(int) ProtoGetBufferFormat(const void *pBuffer, const TCHAR **ptszExtension)
{
	if (!memcmp(pBuffer, "\x89PNG", 4)) {
		if (ptszExtension) *ptszExtension = _T(".png");
		return PA_FORMAT_PNG;
	}

	if (!memcmp(pBuffer, "GIF8", 4)) {
		if (ptszExtension) *ptszExtension = _T(".gif");
		return PA_FORMAT_GIF;
	}

	if (!memicmp(pBuffer, "<?xml", 5)) {
		if (ptszExtension) *ptszExtension = _T(".xml");
		return PA_FORMAT_XML;
	}

	if (!memcmp(pBuffer, "\xFF\xD8\xFF\xE0", 4) || !memcmp(pBuffer, "\xFF\xD8\xFF\xE1", 4)) {
		if (ptszExtension) *ptszExtension = _T(".jpg");
		return PA_FORMAT_JPEG;
	}

	if (!memcmp(pBuffer, "BM", 2)) {
		if (ptszExtension) *ptszExtension = _T(".bmp");
		return PA_FORMAT_BMP;
	}

	if (ptszExtension) *ptszExtension = _T("");
	return PA_FORMAT_UNKNOWN;
}
LONG utilStrWordIndex(PSZ pszList, ULONG cbWord, PCHAR pcWord)
{
  ULONG		   ulIdx;
  ULONG      cbList;
  ULONG      cbScanWord;
  PCHAR      pcScanWord;

  if ( pcWord == NULL || cbWord == 0 )
    return -1;

  BUF_SKIP_SPACES( cbWord, pcWord );
  BUF_RTRIM( cbWord, pcWord );
  if ( cbWord == 0 )
    return -1;

  cbList = strlen( pszList );
  for( ulIdx = 0; ; ulIdx++ )
  {
    utilStrCutWord( &cbList, &pszList, &cbScanWord, &pcScanWord );
    if ( cbScanWord == 0 )
      // All words in the list was checked.
      break;

    if ( ( cbScanWord == cbWord ) &&
         ( memicmp( pcScanWord, pcWord, cbScanWord ) == 0 ) )
      // Word found - return list index of word.
      return ulIdx;
  }

  return -1;
}
示例#3
0
static void SetRadixSpec( char *str, unsigned len, unsigned radix, bool clear )
{

    rad_str   *pref;
    rad_str  **owner;

    owner = &RadStrs;
    pref = RadStrs;
    while( pref != NULL ) {
        if( pref->radstr[0] == len
         && memicmp( &pref->radstr[1], str, pref->radstr[0] ) == 0 ) break;
        if( pref->radstr[0] < len ) break;
        owner = &pref->next;
        pref = pref->next;
    }
    if( pref == NULL || pref->radstr[0] != len ) {
        if( clear ) return;
        pref = DbgMustAlloc( sizeof( rad_str ) + len );
        memcpy( &pref->radstr[1], str, len );
        pref->radstr[0] = len;
        pref->next = *owner;
        *owner = pref;
    } else if( clear ) {
        *owner = pref->next;
        _Free( pref );
        return;
    }
    pref->radval = radix;
}
示例#4
0
OVL_EXTERN walk_result sem_FindCue( cue_handle *cueh, void *d )
{
    cue_find    *cd = d;
    char        file[FILENAME_MAX];
    unsigned    len;
    unsigned    match;


    len = DIPCueFile( cueh, file, sizeof( file ) );
    if( len < cd->len )
        return( WR_CONTINUE );
    if( memcmp( &file[len - cd->len], cd->name, cd->len ) == 0 ) {
        match = CMP_SENSITIVE;
    } else if( memicmp( &file[len - cd->len], cd->name, cd->len ) == 0 ) {
        match = CMP_INSENSITIVE;
    } else {
        return( WR_CONTINUE );
    }
    if( match > cd->match ) {
        cd->match = match;
        cd->id = DIPCueFileId( cueh );
        cd->ambig = false;
    } else if( match == cd->match ) {
        cd->ambig = true;
    }
    return( WR_CONTINUE );
}
示例#5
0
static FullTypeRecord *findExeTypeRecord( ResTable *restab,
                            WResTypeInfo *type )
/*********************************************************/
{
    FullTypeRecord      *exe_type;
    StringItem16        *exe_type_name;

    for( exe_type = restab->Dir.Head; exe_type != NULL;
                exe_type = exe_type->Next ) {
        if( type->TypeName.IsName && !(exe_type->Info.type & 0x8000) ) {
            /* if they are both names */
            exe_type_name = (StringItem16 *)((char *)restab->Str.StringBlock +
                            (exe_type->Info.type - restab->Dir.TableSize));
            if( exe_type_name->NumChars == type->TypeName.ID.Name.NumChars
                && !memicmp( exe_type_name->Name, type->TypeName.ID.Name.Name,
                             exe_type_name->NumChars ) ) break;
        } else if( !(type->TypeName.IsName) && exe_type->Info.type & 0x8000 ) {
            /* if they are both numbers */
            if( type->TypeName.ID.Num == (exe_type->Info.type & ~0x8000) ) {
                break;
            }
        }
    }

    if( exe_type == NULL ) {
        /* this is a new type */
        exe_type = addExeTypeRecord( restab, type );
    }

    return( exe_type );
} /* findExeTypeRecord */
示例#6
0
PFEA FindEA(PFEALIST pFeal, PSZ pszName, USHORT usMaxName)
{
    PFEA pFea;
    PBYTE pMax;

    if (!pFeal)
        return NULL;

    pFea = pFeal->list;
    pMax = (PBYTE)pFeal + pFeal->cbList;

    while ((PBYTE)pFea + sizeof (FEA) < pMax)
    {
        PBYTE pName, pValue;

        pName  = (PBYTE)(pFea + 1);
        if (pName >= pMax)
            return NULL;
        pValue = pName + (USHORT)pFea->cbName + 1;
        if (pValue + pFea->cbValue > pMax)
            return NULL;
#if 0
        if (f32Parms.fMessageActive & LOG_EAS)
            Message("FindEA: '%s'", pName);
#endif
        if (pFea->cbName == (BYTE)usMaxName && !memicmp(pName, pszName, usMaxName))
            return pFea;

        pFea = (PFEA)((PBYTE)pFea + sizeof (FEA) + (USHORT)pFea->cbName + 1 + pFea->cbValue);
    }
    return NULL;
}
示例#7
0
void ControlSocket::HandleString(std::string s)
{
    if(_instance->GetConf()->rmcontrolpass.size())
    {
        if(_authed)
        {
            _Execute(s);
        }
        else
        {
            if(s.size() > 3 && !memicmp(s.c_str(),"pw ",3)) // string format: "pw secret12345"
            {
                if(_instance->GetConf()->rmcontrolpass == s.c_str() + 3)
                {
                    logdetail("ControlSocket: Authenticated successfully with: \"%s\"",s.c_str());
                    SendTelnetText("+accepted");
                    _authed = true;
                }
                else
                {
                    SendTelnetText("+wrong password");
                    SetCloseAndDelete(true);
                }
            }
        }
    }
    else
    {
        _Execute(s);
    }
}
示例#8
0
文件: rfc822.c 项目: gpg/geam
/****************
 * Note: For program supplied (and therefore syntactically correct)
 *	 header lines, rfc822_add_header() may be used.
 */
int
insert_header( RFC822 msg, char *line, size_t length )
{
    HDR_LINE hdr;

    if( !length ) {
        msg->in_body = 1;
        return transition_to_body(msg);
    }
    trim_trailing_spaces(line);
    /* Hmmm: should we check for invalid header data here? */

    hdr = malloc( sizeof( *hdr ) + strlen(line) );
    if( !hdr )
        return RFC822ERR_NOMEM;
    hdr->next = NULL;
    hdr->cont = (*line == ' ' || *line == '\t');
    strcpy(hdr->line, line );

    *msg->hdr_lines_head = hdr;
    msg->hdr_lines_head = &hdr->next;

    /* lets help the caller to prevent mail loops
     * It is okay to use length here, also this value
     * not correct due to the space trimming */
    if( length >= 9 && !memicmp(line, "Received:", 9) )
        do_callback( msg, RFC822EVT_RCVD_SEEN );
    return 0;
}
示例#9
0
文件: rfc822.c 项目: gpg/geam
/****************
 * Add header lines to the existing ones.
 * Such a line may include LFs which are used to split the line
 * int several fields.	This must be a valid header line.
 */
int
rfc822_add_header( RFC822 msg, const char *line )
{
    HDR_LINE hdr;
    const char *lf;
    size_t n;
    int do_cb;

    /* send the notification only if we have not processed all header lines */
    do_cb = !msg->in_body && strlen(line) >= 9 && !memicmp(line, "Received:", 9);

    do {
        lf = strchr( line, '\n' );
        n = lf? ( lf - line ) : strlen( line );
        hdr = malloc( sizeof( *hdr ) + n );
        if( !hdr )
            return RFC822ERR_NOMEM;
        hdr->next = NULL;
        hdr->cont = (*line == ' ' || *line == '\t');
        memcpy(hdr->line, line, n );
        hdr->line[n] = 0;

        *msg->hdr_lines_head = hdr;
        msg->hdr_lines_head = &hdr->next;
    } while( lf && *(line=lf+1) );

    if( do_cb )
        do_callback( msg, RFC822EVT_RCVD_SEEN );

    return 0;
}
示例#10
0
文件: h_c.cpp 项目: lecheel/fte-fork
int LookAt(EBuffer *B, int Row, unsigned int Pos, const char *What, hsState State, int NoWord, int CaseInsensitive) {
    STARTFUNC("LookAt{h_c.cpp}");

    int Len = strlen(What);

    if (Row < 0 || Row >= B->RCount) {
        LOG << "Row out of range: " << Row << " vs " << B->RCount << ENDLINE;
        ENDFUNCRC(0);
    }
    char*        pLine       = B->RLine(Row)->Chars;
    unsigned int uLineLength = B->RLine(Row)->Count;
    Pos = B->CharOffset(B->RLine(Row), Pos);
    if (Pos + strlen(What) > uLineLength) { ENDFUNCRC(0); }
    if (NoWord && uLineLength > Pos + Len && ISNAME(pLine[Pos + Len]))
    {
        ENDFUNCRC(0);
    }
    LOG << "Check against [" << What << ']' << ENDLINE;
    if (
        (CaseInsensitive && memicmp(pLine + Pos, What, Len) == 0) ||
        (!CaseInsensitive && memcmp(pLine + Pos, What, Len) == 0)
       )
    {
        ENDFUNCRC(1);
    }
    else
    {
        ENDFUNCRC(0);
    }
}
示例#11
0
文件: vmnet.cpp 项目: cspiegel/garglk
/*
 *   Given an XML buffer, find the end of the <?XML?> header and the start of
 *   the regular XML contents 
 */
const char *TadsXml::strip_xml_header(const char *buf)
{
    const char *p;

    /* skip any initial newlines or whitespace */
    for (p = buf ; isspace(*p) || *p == '\n' || *p == '\r' ; ++p) ;

    /* if it starts with "<?xml", find the end of the directive */
    if (memicmp(p, "<?xml ", 6) == 0)
    {
        int qu;

        /* scan for the matching '>' */
        for (p += 6, qu = 0 ; *p != '\0' ; ++p)
        {
            /* check for quotes */
            if (*p == '"' || *p == '\'')
            {
                /* 
                 *   if we're in a quoted section, and this is the matching
                 *   close quote, leave the quoted section; if we're not in a
                 *   quoted section, this is the opening quote of a quoted
                 *   section 
                 */
                if (qu == 0)
                {
                    /* we weren't in a quoted section, so now we are */
                    qu = *p;
                }
                else if (*p == qu)
                {
                    /* we were in a quoted section, and it's our close quote */
                    qu = 0;
                }
            }
            else if (*p == '?' && *(p+1) == '>')
            {
                /* 
                 *   It's the end of the directive.  Skip the "?>" sequence
                 *   and any subsequent newline characters.  
                 */
                for (p += 2 ; *p == '\n' || *p == '\r' ; ++p) ;

                /* 
                 *   we're now at the start of the XML contents - return the
                 *   current pointer 
                 */
                return p;
            }
        }
    }

    /* 
     *   we either didn't find the start of the <?XML?> directive, or we
     *   couldn't find the end of it - in either case, we don't have a
     *   well-formed directive, so there's nothing to strip: just return the
     *   original buffer 
     */
    return buf;
}
示例#12
0
    /* find a header */
    const char *find_header(const char *name)
    {
        /* remember the name length */
        size_t namelen = strlen(name);

        /* scan the headers */
        for (const char *p = hdrs ; p != 0 ; p = next_header(p))
        {
            /* skip spaces */
            for ( ; *p != '\0' && is_space(*p) ; ++p) ;

            /* check for a match */
            if (memicmp(p, name, namelen) == 0)
            {
                /* skip the name and any subsequent spaces */
                for (p += namelen ; *p != '\0' && is_space(*p) ; ++p) ;

                /* make sure we have a ':' */
                if (*p == ':')
                {
                    /* skip the ':' and subsequent spaces */
                    for (p += 1 ; *p != '\0' && is_space(*p) ; ++p) ;

                    /* this is the start of the header value */
                    return p;
                }
            }
        }

        /* didn't find it */
        return 0;
    }
示例#13
0
/*
 *   Look up a a value by name, returning a pointer to the value string.
 */
const char *CTadsGameInfo::get_val(const char *name) const
{
    /* for efficiency, note the length of the name up front */
    size_t name_len = strlen(name);

    /* scan our list of value entries for the given name */
    for (tads_valinfo *cur = first_val_ ; cur != 0 ; cur = cur->nxt)
    {
        /* 
         *   If the name matches, return the value for this entry.  Note
         *   that, since the name is always a plain ASCII string, we can
         *   perform a simple byte-by-byte case-insensitive comparison using
         *   memicmp. 
         */
        if (cur->name_len == name_len
            && memicmp(cur->name, name, name_len) == 0)
        {
            /* it's the one - return its value */
            return cur->val;
        }
    }

    /* didn't find it - return null */
    return 0;
}
示例#14
0
static walk_result FindCue( cue_handle *ch, void *d )
{
    cue_find    *cd = d;
    char        file[FILENAME_MAX];
    unsigned    len;
    unsigned    match;


    len = CueFile( ch, file, sizeof( file ) );
    if( len < cd->len ) return( WR_CONTINUE );
    if( memcmp( &file[len - cd->len], cd->name, cd->len ) == 0 ) {
        match = CMP_SENSITIVE;
    } else if( memicmp( &file[len - cd->len], cd->name, cd->len ) == 0 ) {
        match = CMP_INSENSITIVE;
    } else {
        return( WR_CONTINUE );
    }
    if( match > cd->match ) {
        cd->match = match;
        cd->id = CueFileId( ch );
        cd->ambig = FALSE;
    } else if( match == cd->match ) {
        cd->ambig = TRUE;
    }
    return( WR_CONTINUE );
}
示例#15
0
  bool NamespacesPolicy::Match(const X509_NAME* subject) {
    error_.resize(0);
    if(!file_) return false;
    std::string subject_str;
    std::string s;
    std::string policy_ca_subject;
    std::string policy_right;
    std::list<std::string> policy_patterns;
    bool right = false;
    bool failure = false;
    X509_NAME_to_string(subject_str, subject);
    bool permit = false;
    for(;;) {
      right = false;
      failure = false;
      get_one_rule(*file_, s);
      if(s.empty()) break;
      //logger.msg(INFO, "Get rule from namespaces file: %s", s.c_str());

      policy_ca_subject.resize(0);
      if(!get_issuer(s, policy_ca_subject, error_)) failure = true;
      //If the "SELF" token is contained.
      //According to the specification: 
      //The (quoted) issuerDirectoryName may be replaced by the single 
      //token “SELF”, in which case this policy applies to the issuer 
      //whose hash corresponds to the hash contained in the namespaces file name
      if(memicmp(policy_ca_subject.c_str(), selfissuer.c_str(), policy_ca_subject.length()) == 0) {
        policy_ca_subject.resize(0);
        policy_ca_subject = issuer_;
      }

      policy_right.resize(0);
      if(!get_right(s, policy_right, error_)) failure = true;
      else { right = (policy_right == "permit"); }

      policy_patterns.resize(0);
      if(!get_subject(s, policy_patterns, error_)) failure = true;

      if((!policy_ca_subject.empty()) && (!failure)) {
        //According to eugridpma's namespaces format specification: 
        //The policy can either permit or deny the issuer the right 
        //to issue subjects with specific names. A denial overrides 
        //any permissive statements in the same file.
        bool r = match_all(issuer_, subject_str, policy_ca_subject, policy_patterns);
        if(r && right) {
          //logger.msg(INFO, "The issuer: %s is permitted to sign the subject: %s", issuer_.c_str(), subject_str.c_str());
          permit = true;
        }
        else if(r && !right) { //Denial overrides
          //logger.msg(INFO, "The issuer: %s is explicitly denied to sign the subject: %s", issuer_.c_str(), subject_str.c_str());
          return false;
        }
        else {
          //logger.msg(INFO, "The subject: %s and issuer: %s in the verified certificate does not match any namespaces policies files", subject_str.c_str(), issuer_.c_str());
        }
      };
    };
    return permit;
  }
示例#16
0
void main()
  {
    char buffer[80];

    if( memicmp( buffer, "Hello", 5 ) < 0 ) {
      printf( "Less than\n" );
    }
  }
示例#17
0
const char *get_relative_path(const char *p)
{
	char home[MAX_PATH];
	GetBlackboxPath(home, MAX_PATH);
	int n = strlen(home);
	if (0 == memicmp(p, home, n)) return p + n;
	return p;
}
示例#18
0
    void processOption(const char *option, const char *value, StringBuffer &eclccCmd, StringBuffer &eclccProgName, IPipeProcess &pipe, bool isLocal)
    {
        if (memicmp(option, "eclcc-", 6) == 0 || *option=='-')
        {
            //Allow eclcc-xx-<n> so that multiple values can be passed through for the same named debug symbol
            const char * start = option + (*option=='-' ? 1 : 6);
            const char * finger = (*start=='-') ? start+1 : start; //support leading double dash
            const char * dash = strrchr(finger, '-');     // position of trailing dash, if present
            StringAttr optName;
            if (dash && (dash != start))
                optName.set(start, dash-start);
            else
                optName.set(start);

            if (!optName)
                return;

            if (stricmp(optName, "hook") == 0)
            {
                if (isLocal)
                    throw MakeStringException(0, "eclcc-hook option can not be set per-workunit");  // for security reasons
                eclccProgName.set(value);
            }
            else if (stricmp(optName, "compileOption") == 0)
                eclccCmd.appendf(" -Wc,%s", value);
            else if (stricmp(optName, "linkOption") == 0)
                eclccCmd.appendf(" -Wl,%s", value);
            else if (stricmp(optName, "includeLibraryPath") == 0)
                eclccCmd.appendf(" -I%s", value);
            else if (stricmp(optName, "libraryPath") == 0)
                eclccCmd.appendf(" -L%s", value);
            else if (strnicmp(optName, "-allow", 6)==0)
            {
                if (isLocal)
                    throw MakeStringException(0, "eclcc-allow option can not be set per-workunit");  // for security reasons
                eclccCmd.appendf(" -%s=%s", optName.get(), value);
            }
            else if (*optName == 'd')
            {
                //Short term work around for the problem that all debug names get lower-cased
                eclccCmd.appendf(" -D%s=%s", optName.get()+1, value);
            }
            else
                eclccCmd.appendf(" -%s=%s", optName.get(), value);
        }
        else if (strchr(option, '-'))
        {
            StringBuffer envVar;
            if (isLocal)
                envVar.append("WU_");
            envVar.append(option);
            envVar.toUpperCase();
            envVar.replace('-','_');
            pipe.setenv(envVar, value);
        }
        else
            eclccCmd.appendf(" -f%s=%s", option, value);
    }
示例#19
0
 static std::string::size_type find(const char* s, int s_length, const char* to_find, int to_find_length) {
   int n = s_length - to_find_length;
   std::string::size_type pos = 0;
   while(n-- >= 0) {
     if(memicmp(s, to_find, to_find_length) == 0) return pos;
     ++s; ++pos;
   }
   return std::string::npos;
 }
示例#20
0
    Boolean StringStartWith (const char * string, const char * startWithString,Boolean CaseSensative)
    {
        int stringLen = StrLen (string);
        int startWithStringLen = StrLen (startWithString);

        if(CaseSensative)
           return stringLen >= startWithStringLen && 0 == memcmp (string, startWithString, startWithStringLen);
        else
            return stringLen >= startWithStringLen && 0 == memicmp (string, startWithString, startWithStringLen);
    }
示例#21
0
const char *get_relative_path(HINSTANCE h, const char *path)
{
    char basedir[MAX_PATH];
    int l;
    get_exe_path(h, basedir, sizeof basedir);
    l = strlen(basedir);
    if (l && 0 == memicmp(path, basedir, l))
        return path + l;
    return path;
}
示例#22
0
文件: SYM.C 项目: robsonfr/ultrahle
void sym_patchnames(void)
{
    int i,j;
    char *p;

    for(j=0; ospatch[j]; j++)
    {
        p=strchr(ospatch[j],' ');
        if(!p)
        {
            print("ERROR in ospatch.h (%s)\n",ospatch[j]);
            return;
        }
        else
        {
            if(p[-1]=='*')
            {
                ospatchwild[j]=1;
                ospatchlen[j]=p-ospatch[j]-1;
            }
            else
            {
                ospatchwild[j]=0;
                ospatchlen[j]=p-ospatch[j];
            }
        }
    }

    for(i=0; i<symnum; i++)
    {
        p=strchr(sym[i].text,'%');
        if(p) continue; // patch disabled
        p=strchr(sym[i].text,'#');
        if(!p)
        {   // no patch yet, add one from ospatch[] if applicable
            for(j=0; ospatch[j]; j++)
            {
                if(strlen(sym[i].text)<ospatchlen[j]) continue;
                if(memicmp(sym[i].text,ospatch[j],ospatchlen[j])) continue;
                if(!ospatchwild[j] && sym[i].text[ospatchlen[j]]>32) continue;
                // match
                {
                    char buf[256];
//                    print("- symbol patch %s [%s,%i] => ",sym[i].text,ospatch[j],ospatchlen[j]);
                    sprintf(buf,"%s %s",sym[i].text,ospatch[j]+ospatchlen[j]+1);
                    p=strchr(ospatch[j],'#');
                    if(!p) p="0";
                    sym_add(sym[i].addr,buf,atoi(p+1));
//                    print("%s\n",sym[i].text);
                }
                break;
            }
        }
    }
}
示例#23
0
文件: common.cpp 项目: Godzil/osXdk
bool get_switch(const char *&ptr_arg,const char *ptr_switch)
{
	int	lenght=strlen(ptr_switch);
	if ((!ptr_arg) || memicmp(ptr_arg,ptr_switch,lenght))
	{
		// Not a match
		return false;
	}
	// Validate the parameter
	ptr_arg+=lenght;
	return true;
}
示例#24
0
static unsigned decodeMon(const char *mon)
{
    if (strlen(mon)>=3) {
        const char *p="janfebmaraprmayjunjulaugsepoctnovdec";
        for (unsigned i=1;i<=12;i++) {
            if (memicmp(p,mon,3)==0)
                return i;
            p += 3;
        }
    }
    return NotFound;
}
示例#25
0
static unsigned decodeDay(const char *day)
{ // not this uses sun as 0
    if (strlen(day)>=3) {
        const char *p="sunmontuewedthufrisat";
        for (unsigned i=0;i<7;i++) {
            if (memicmp(p,day,3)==0)
                return i;
            p += 3;
        }
    }
    return NotFound;
}
示例#26
0
void main(void)
{
    char *a = "AAA";
    char *b = "BBB";
    char *c = "aaa";

    printf("Comparing %s and %s with memcmp %d\n",
           a, b, memcmp(a, b, sizeof(a)));

    printf("Comparing %s and %s with memicmp %d\n",
           a, b, memicmp(a, c, sizeof(a)));
}
示例#27
0
static walk_result FindTheMad( mad_handle mh, void *d )
{
    struct find_mad     *fd = d;
    char                buff[80];
//    char                *p;

    MADNameFile( mh, buff, sizeof( buff ) );
//    p = SkipPathInfo( buff, 0 );
    SkipPathInfo( buff, 0 );
    if( memicmp( buff, fd->name, fd->len ) == 0 ) {
        fd->mad = mh;
        return( WR_STOP );
    }
    MADNameDescription( mh, buff, sizeof( buff ) );
    NormalizeString( buff );
    if( memicmp( buff, fd->name, fd->len ) == 0 ) {
        fd->mad = mh;
        return( WR_STOP );
    }
    return( WR_CONTINUE );
}
示例#28
0
static  macro_entry     *FindMacroEntry( char *macro, uint macro_len ) {
//======================================================================

// Find a macro.

    macro_entry *me;

    for( me = MacroList; me != NULL; me = me->link ) {
        if( me->name_len != macro_len ) continue;
        if( memicmp( me->name, macro, macro_len ) == 0 ) return( me );
    }
    return( NULL );
}
示例#29
0
文件: fiad.c 项目: eswartz/emul
int	openfiad(char *filename, int *handle)
{
	struct  tifile *ff;
	char	path[80];
	char	dosname[14];
	char	fdrname[12];
	char	tiname[12];
	int	ti;
	struct	fdrstruc *fdr;


	_fmode=O_BINARY;

	if ((ti=*handle=getfreeti(0))!=-1)
	{
	ff=&tifiles[ti];
	fdr=&ff->fdr;

	if (split(filename,path,tiname))
	{
		memset(fdrname,0x20,10);
		memcpy(fdrname,tiname,strlen(tiname));
		ti2dos(tiname,dosname);
		strcat(path,dosname);
		if ((_dos_open(path,O_RDWR|O_BINARY,&ff->doshandle))==0)
		{
			if (read(ff->doshandle,fdr,128)==128)
			{
				noansi(fdr->name);
				if (memicmp(fdr,fdrname,10)==0 &&
				    ((fdr->flags&F_VARIABLE) ? fdr->reclen : 1))
				{
					tifiles[ti].inuse=1;
						Error=0;
						return 1;
				}
			}
			Error=NOTTIEMUL;
			close(ff->doshandle);
			return 0;
		}
		else
		{
			Error=BADFILE;
			close(ff->doshandle);
			return 0;
		}
	}
	}
	return 0;			// split sets Error
}
int lookupIpAddressByMacAddress(char *mac_address, char *ipaddress)
{
        int retval = -1;
        for (int loop = 0; loop < AdapterCount; loop++)
        {
                if (memicmp(adapters[loop].MacAddress,mac_address,strlen(mac_address)) == 0)
                {
                        strcpy(ipaddress,adapters[loop].IpAddress);
                        retval = 0;
                }
        }

        return retval;
}