Example #1
0
static int iMatrixGetUnity(const char* name, char* am_name)
{
  /* Convert to American spelling */
  const char* s = strstr(name, "metre");
  if (s)
  {
    int off = s - name;
    strcpy(am_name, name);
    strncpy(am_name+off, "meter", 5);
    return 1;
  }
  else
  {
    s = strstr(name, "litre");
    if (s)
    {
      int off = s - name;
      strcpy(am_name, name);
      strncpy(am_name+off, "liter", 5);   /* don't confuse with litter */
      return 1;
    }
  }

  return 0;
}
Example #2
0
static bool txtParseParam(char* szData, char* presearch,
	char* start, char* finish, char* param, size_t size)
{
	char *cp, *cp1;
	size_t len;

	*param = 0;

	if (presearch != NULL) {
		cp1 = strstr(szData, presearch);
		if (cp1 == NULL) return false;
	}
	else
		cp1 = szData;

	cp = strstr(cp1, start);
	if (cp == NULL) return false;
	cp += strlen(start);
	while (*cp == ' ') ++cp;

	cp1 = strstr(cp, finish);
	if (cp1 == NULL) return false;
	while (*(cp1-1) == ' ' && cp1 > cp) --cp1;

	len = min((size_t)(cp1 - cp), size-1);
	strncpy(param, cp, len);
	param[len] = 0;

	return true;
}
dDAGFunctionNode::dDAGFunctionNode(dList<dDAG*>& allNodes, dDAGTypeNode* const type, const char* const name, const char* const visivility)
	:dDAG(allNodes)
	,m_isStatic(false)
	,m_isPublic(true)
	,m_isConstructor(false)
	,m_loopLayer(0)
	,m_opertatorThis()
	,m_returnType (type)
	,m_body(NULL)
	,m_modifier(NULL)
	,m_functionStart(NULL)
	,m_parameters() 
	,m_blockMap()
{
	m_name = name;

	m_isStatic = strstr (visivility, "static") ? true : false;
	m_isPublic = strstr (visivility, "public") ? true : false;

	if (!m_isStatic) {
		dAssert (0);
		dDAGParameterNode* const operatorThis = new dDAGParameterNode (allNodes, "this", "");
		operatorThis->SetType(new dDAGTypeNode (allNodes, "this"));
		AddParameter(operatorThis);
	}

}
Example #4
0
void NPC_PrecacheWeapons( team_t playerTeam, int spawnflags, char *NPCtype )
{
	int weapons = NPC_WeaponsForTeam( playerTeam, spawnflags, NPCtype );
	gitem_t	*item;
	for ( int curWeap = WP_SABER; curWeap < WP_NUM_WEAPONS; curWeap++ )
	{
		if ( (weapons & ( 1 << curWeap )) )
		{
			item = FindItemForWeapon( ((weapon_t)(curWeap)) );	//precache the weapon
			CG_RegisterItemSounds( (item-bg_itemlist) );
			CG_RegisterItemVisuals( (item-bg_itemlist) );
			//precache the in-hand/in-world ghoul2 weapon model

			char weaponModel[64];
			
			strcpy (weaponModel, weaponData[curWeap].weaponMdl);	
			if (char *spot = strstr(weaponModel, ".md3") ) {
				*spot = 0;
				spot = strstr(weaponModel, "_w");//i'm using the in view weapon array instead of scanning the item list, so put the _w back on
				if (!spot) {
					strcat (weaponModel, "_w");
				}
				strcat (weaponModel, ".glm");	//and change to ghoul2
			}
			gi.G2API_PrecacheGhoul2Model( weaponModel ); // correct way is item->world_model
		}
	}
}
Example #5
0
static void
print_reply_hdr (Call *call, const char *buf, int len)
{
  Call_Private_Data *priv = CALL_PRIVATE_DATA (call);
  const char *eoh;

  if (len <= 0 || priv->done_with_reply_hdr)
    return;

  eoh = strstr (buf, "\r\n\r\n");
  if (eoh)
    {
      priv->done_with_reply_hdr = 1;
      eoh += 4;
    }
  else
    {
      /* no CRLFCRLF: non-conforming server */
      eoh = strstr (buf, "\n\n");
      if (eoh)
	{
	  priv->done_with_reply_hdr = 1;
	  eoh += 2;
	}
      else
	eoh = buf + len;
    }
  print_buf (call, "RH", buf, eoh - buf);
}
Example #6
0
// mode=0: fs, mode=1: mountpoint
char *findmount(char *dev, int mode)
{
	FILE *fp;
	char line[PATH_MAX], *ptr;
	int i;

	if ((fp = fopen("/proc/mounts", "r"))== NULL)
	{
		perror("Could not open output file for reading");
		return(NULL);
	}
	while(!feof(fp))
	{
		if(fgets(line, PATH_MAX, fp) == NULL)
			break;
		if(strstr(line, dev)==line)
		{
			ptr = strstr(line, " ")+1;
			if(!mode)
				ptr = strstr(ptr, " ")+1;
			for(i=0;*(ptr+i)!='\0';i++)
				if(*(ptr+i)==' ')
					*(ptr+i)='\0';
			fclose(fp);
			return(strdup(ptr));
		}
	}
	fclose(fp);
	return(NULL);
}
Example #7
0
/*
a=Range:npt=0.000000-5952.960000
a=x-frequency:xxxxxxx
a=x-pid:xxx
*/
void simple_parse_sdp(char* sdp, int* range, int* freq, int* pid,int* controlId, int* symbolRate, int* modulation,int* programNumber)
{
    char* p;

    RTSP_DBG("======>begin parse sdp\n");

    p = strstr(sdp, "npt=");
    p+=4;
    p = strchr(p, '-');
    p++;
    *range = atoi(p);

    p = strstr(sdp, "frequency=");
    p+=10;
    *freq = atoi(p);

    p = strstr(sdp, "x-pid:");
    p+=6;
    *pid = atoi(p);

    p = strstr(sdp,"control:track");
    p += 13;

    *controlId = atoi(p);

    RTSP_DBG("=========> parse sdp: range=%d freq=%d pid=%d\n", *range, *freq, *pid);
}
Example #8
0
static GList * photos_lastfm_parse (cb_object * capo)
{
    gchar * root = capo->cache->data;
    GList * result_list = NULL;

    while (continue_search (g_list_length (result_list),capo->s) && (root = strstr (root,SIZE_FO) ) != NULL)
    {
        gchar * begin = root + strlen (SIZE_FO);
        if (size_fits (capo->s,&begin) == TRUE)
        {
            gchar * endin = strstr (begin,URL_ENDIN);
            if (endin != NULL)
            {
                gchar * urlb = copy_value (begin,endin);
                if (urlb != NULL)
                {
                    GlyrMemCache * cache = DL_init();
                    cache->data = urlb;
                    cache->size = strlen (urlb);
                    result_list = g_list_prepend (result_list,cache);
                }
            }
        }
        root += (sizeof SIZE_FO) - 1;
    }
    return result_list;
}
    virtual float scoreFactory(const sp<IMediaPlayer>& client,
                               const char* url,
                               float curScore) {
        static const float kOurScore = 0.8;

        if (kOurScore <= curScore)
            return 0.0;

        if (!strncasecmp("http://", url, 7)
                || !strncasecmp("https://", url, 8)
                || !strncasecmp("file://", url, 7)) {
            size_t len = strlen(url);
            if (len >= 5 && !strcasecmp(".m3u8", &url[len - 5])) {
                return kOurScore;
            }

            if (strstr(url,"m3u8")) {
                return kOurScore;
            }

            if ((len >= 4 && !strcasecmp(".sdp", &url[len - 4])) || strstr(url, ".sdp?")) {
                return kOurScore;
            }
        }

        if (!strncasecmp("rtsp://", url, 7)) {
            return kOurScore;
        }

        return 0.0;
    }
Example #10
0
void vApplicationProcessFormInput( char *pcInputString )
{
char *c;

	/* Only interested in processing form input if this is the IO page. */
	c = strstr( pcInputString, "io.shtml" );
	
	if( c )
	{
		/* Is there a command in the string? */
		c = strstr( pcInputString, "?" );
	    if( c )
	    {
			/* Turn the LED's on or off in accordance with the check box status. */
			if( strstr( c, "LED0=1" ) != NULL )
			{
				/* Turn the LEDs on. */
				vParTestSetLED( 3, 1 );
				vParTestSetLED( 4, 1 );
			}
			else
			{
				/* Turn the LEDs off. */
				vParTestSetLED( 3, 0 );
				vParTestSetLED( 4, 0 );
			}
	    }
		else
		{
			/* Commands to turn LEDs off are not always explicit. */
			vParTestSetLED( 3, 0 );
			vParTestSetLED( 4, 0 );
		}
	}
}
Example #11
0
void vApplicationProcessFormInput( char *pcInputString )
{
char *c;
const unsigned long ulYellowLED = 2UL;

	/* Only interested in processing form input if this is the IO page. */
	c = strstr( pcInputString, "io.shtml" );
	
	if( c )
	{
		/* Is there a command in the string? */
		c = strstr( pcInputString, "?" );
	    if( c )
	    {
			/* Turn the LEDs on or off in accordance with the check box status. */
			if( strstr( c, "LED0=1" ) != NULL )
			{
				/* Turn the LEDs on. */
				vParTestSetLED( ulYellowLED, pdTRUE );
			}
			else
			{
				/* Turn the LEDs off. */
				vParTestSetLED( ulYellowLED, pdFALSE );
			}
	    }
		else
		{
			/* Some browsers will only imply that a check box is off. */
			vParTestSetLED( ulYellowLED, pdFALSE );
		}
	}
}
static void
play_tree_add_basepath(play_tree_t* pt, char* bp) {
    int i,bl = strlen(bp),fl;

    if(pt->child) {
        play_tree_t* i;
        for(i = pt->child ; i != NULL ; i = i->next)
            play_tree_add_basepath(i,bp);
        return;
    }

    if(!pt->files)
        return;

    for(i = 0 ; pt->files[i] != NULL ; i++) {
        fl = strlen(pt->files[i]);
        // if we find a full unix path, url:// or X:\ at the beginning,
        // don't mangle it.
        if(fl <= 0 || strstr(pt->files[i],"://") || (strstr(pt->files[i],":\\") == pt->files[i] + 1) || (pt->files[i][0] == '/') )
            continue;
        // if the path begins with \ then prepend drive letter to it.
        if (pt->files[i][0] == '\\') {
            if (pt->files[i][1] == '\\')
                continue;
            pt->files[i] = (char*)realloc(pt->files[i],2+fl+1);
            memmove(pt->files[i] + 2,pt->files[i],fl+1);
            memcpy(pt->files[i],bp,2);
            continue;
        }
        pt->files[i] = (char*)realloc(pt->files[i],bl+fl+1);
        memmove(pt->files[i] + bl,pt->files[i],fl+1);
        memcpy(pt->files[i],bp,bl);
    }
}
Example #13
0
/* extracts the dirname and the basename from the path */
static void splitPath(const char *path, char **dir, char **base) {
	char *ptr;
	const char *dirsep = NULL;
	*base = (char *)path;
	*dir = (char *)".";
	dirsep = PHYSFS_getDirSeparator();
	if (strlen(dirsep) == 1) { /* fast path. */
		ptr = strrchr(path, *dirsep);
	}
	else {
		ptr = strstr(path, dirsep);
		if (ptr != NULL) {
			char *p = ptr;
			while (p != NULL) {
				ptr = p;
				p = strstr(p + 1, dirsep);
			}
		}
	}
	if (ptr != NULL) {
		size_t size = (size_t) (ptr - path);
		*dir = (char *) malloc(size + 1);
		memcpy(*dir, path, size);
		(*dir)[size] = '\0';
		*base = ptr + strlen(dirsep);
	}
}
Example #14
0
static int xml_search(char* data, size_t len, char* node, char** result) {
    char startTag[256];
    char endTag[256];
    char* startOffset;
    char* endOffset;
    
    data = strdup(data);
    
    sprintf(startTag, "<%s>", node);
    sprintf(endTag, "</%s>", node);
    
    startOffset = strstr(data, startTag);
    if (startOffset == NULL) {
        return GS_FAILED;
    }
    
    endOffset = strstr(data, endTag);
    if (endOffset == NULL) {
        return GS_FAILED;
    }
    
    *endOffset = 0;
    
    *result = malloc(strlen(startOffset + strlen(startTag)) + 1);
    strcpy(*result, startOffset + strlen(startTag));
    
    return GS_OK;
}
char *platform_get_openbsd_runtime_cpu(void)
{
    char *model = NULL;
    size_t len = 0;
    char *loc1 = NULL;
    char *loc2 = NULL;

    if (!got_openbsd_cpu) {
        sprintf(openbsd_cpu, "Unknown CPU");

        model = GetModelSysCtl();

        if (model) {
            loc1 = strstr(model, " (");
            if (loc1) {
                *loc1 = 0;
                loc1 += 2;
                loc2 = strstr(loc1, ")");
                if (loc2) {
                    *loc2 = 0;
                }
            }
            if (!strncasecmp(model, "AMIGA", 5)) {
                sprintf(openbsd_cpu, "%s", loc1);
            } else {
                sprintf(openbsd_cpu, "%s", model);
            }
        }

        got_openbsd_cpu = 1;
    }
    return openbsd_cpu;
}
Example #16
0
static void parse_lyrics_page (const gchar * url, GList ** result_list, cb_object * capo)
{
    GlyrMemCache * lyrcache = download_single (url,capo->s,"<!-- eBay Relevance Ad -->");
    if (lyrcache != NULL)
    {
        gchar * lyr_begin = strstr (lyrcache->data,LYRIC_BEGIN);
        if (lyr_begin != NULL)
        {
            gchar * lyr_endin = strstr (lyr_begin,"</div>");
            if (lyr_endin != NULL)
            {
                gchar * lyrics = copy_value (lyr_begin,lyr_endin);
                if (lyrics != NULL)
                {
                    GlyrMemCache * result = DL_init();
                    result->data = strreplace (lyrics,"<br />","");
                    result->size = strlen (result->data);
                    result->dsrc = g_strdup (url);
                    *result_list = g_list_prepend (*result_list,result);
                }
                g_free (lyrics);
            }
        }
        DL_free (lyrcache);
    }
}
Example #17
0
/*
 * Appends a properly quoted CSV field to StringInfo.
 */
static void
append_valid_csv(StringInfoData *buffer, const char *appendStr)
{
	const char *pChar;

	/*
	 * If the append string is null then do nothing.  NULL fields are not
	 * quoted in CSV.
	 */
	if (appendStr == NULL)
		return;

	/* Only format for CSV if appendStr contains: ", comma, \n, \r */
	if (strstr(appendStr, ",") || strstr(appendStr, "\"") ||
		strstr(appendStr, "\n") || strstr(appendStr, "\r"))
	{
		appendStringInfoCharMacro(buffer, '"');

		for (pChar = appendStr; *pChar; pChar++)
		{
			if (*pChar == '"')	/* double single quotes */
				appendStringInfoCharMacro(buffer, *pChar);

			appendStringInfoCharMacro(buffer, *pChar);
		}

		appendStringInfoCharMacro(buffer, '"');
	}
	/* Else just append */
	else
		appendStringInfoString(buffer, appendStr);
}
Example #18
0
static int
slice_cache_compare(const void *arg1, const void *arg2)
{
	const char  *nm1 = ((rdsk_node_t *)arg1)->rn_name;
	const char  *nm2 = ((rdsk_node_t *)arg2)->rn_name;
	char *nm1slice, *nm2slice;
	int rv;

	/*
	 * partitions one and three (slices zero and two) are the most
	 * likely to provide results, so put those first
	 */
	nm1slice = strstr(nm1, "part1");
	nm2slice = strstr(nm2, "part1");
	if (nm1slice && !nm2slice) {
		return (-1);
	}
	if (!nm1slice && nm2slice) {
		return (1);
	}
	nm1slice = strstr(nm1, "part3");
	nm2slice = strstr(nm2, "part3");
	if (nm1slice && !nm2slice) {
		return (-1);
	}
	if (!nm1slice && nm2slice) {
		return (1);
	}

	rv = strcmp(nm1, nm2);
	if (rv == 0)
		return (0);
	return (rv > 0 ? 1 : -1);
}
Example #19
0
/* Parses one message and adds to the list of counters. */
void
parse_message(char *text, struct list *l, char *keyword)
{
    char *name;
    char *message;
    
    /* Check text contains a date. */
    if (strlen(text) < 5) { return; }
    if (!(is_int(text[0]) && is_int(text[1]) && is_int(text[3]) && is_int(text[4]))) { return; }
    if (strstr(text, "-") == NULL) { return; }
    
    name = strtok(text, "-");               /* Name points to date. */
    name = strtok(NULL, "-");               /* Name points to name and message. */
    while (name[0] == ' ') { name++; }
    if (strstr(name, ":") == NULL) { return; }
    name = strtok(name, ":");               /* Name points to name and excludes message. */
    if(keyword==NULL){
        char *new_name = (char *) malloc(strlen(name));
        strcpy(new_name, name);
        list_add(l, new_name);
    } else {
        message = strtok(NULL, ":");
        if(str_cont(message, keyword)){ /* Message contains keyword. */
            char *new_name = (char *) malloc(strlen(name));
            strcpy(new_name, name);
            list_add(l, new_name);
        }    
    }
} 
Example #20
0
static rt_uint32_t read_line(int fd, char* line, rt_uint32_t line_size)
{
        char *pos, *next;
        rt_uint32_t length;

        length = read(fd, line, line_size);
        if (length > 0)
        {
                pos = strstr(line, "\r\n");
                if (pos == RT_NULL)
                {
                        pos = strstr(line, "\n");
                        next = pos ++;
                }
                else next = pos + 2;

                if (pos != RT_NULL)
                {
                        *pos = '\0';

                        /* move back */
                        lseek(fd, -(length - (next - line)), SEEK_CUR);

                        length = pos - line;
                }
                else length = 0;
        }

        return length;
}
Example #21
0
/* *************************************************************** */
TSIZE	STDgetItem(char *Src, char *ItemNM, char *Brk, char *Buf, TINT Size)
{
	TINT i, nSrcLen, nItemLen;
	char *pSrt, *pEnd, *pTmp;

	nSrcLen = strlen(Src);
	nItemLen = strlen(ItemNM);

	pSrt = strstr(Src, ItemNM);
	if ( pSrt == 0x00 )
		return 0;

	if ( Brk == 0x00 )
		pEnd = Src + nSrcLen;
	else
	{
		pEnd = strstr((pSrt + nItemLen), Brk);
		if ( pEnd == 0x00 )
			pEnd = Src + nSrcLen;
	}

	if ( pSrt >= pEnd )
		return 0;

	i = 0;
	for ( pTmp = pSrt + nItemLen; pTmp < pEnd; pTmp++, i++ )
	{
		if ( i >= Size - 1 )
			break;
		Buf[i] = *pTmp;
	}
	Buf[i] = 0x00;

	return i;
}
void QGLContext::makeCurrent()
{
    Q_D(QGLContext);
    if (!d->valid || !d->eglContext || d->eglSurfaceForDevice() == EGL_NO_SURFACE) {
        qWarning("QGLContext::makeCurrent(): Cannot make invalid context current");
        return;
    }

    if (d->eglContext->makeCurrent(d->eglSurfaceForDevice())) {
        QGLContextPrivate::setCurrentContext(this);
        if (!d->workaroundsCached) {
            d->workaroundsCached = true;
            const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
            if (renderer && (strstr(renderer, "SGX") || strstr(renderer, "MBX"))) {
                // PowerVR MBX/SGX chips needs to clear all buffers when starting to render
                // a new frame, otherwise there will be a performance penalty to pay for
                // each frame.
                d->workaround_needsFullClearOnEveryFrame = true;

                // Older PowerVR SGX drivers (like the one in the N900) have a
                // bug which prevents glCopyTexSubImage2D() to work with a POT
                // or GL_ALPHA texture bound to an FBO. The only way to
                // identify that driver is to check the EGL version number for it.
                const char *egl_version = eglQueryString(d->eglContext->display(), EGL_VERSION);
                if (egl_version && strstr(egl_version, "1.3"))
                    d->workaround_brokenFBOReadBack = true;
            }
        }
    }
}
Example #23
0
/* Return the Message type of the given message. */
OtrlMessageType otrl_proto_message_type(const char *message)
{
    char *otrtag;

    otrtag = strstr(message, "?OTR");

    if (!otrtag) {
	if (strstr(message, OTRL_MESSAGE_TAG_BASE)) {
	    return OTRL_MSGTYPE_TAGGEDPLAINTEXT;
	} else {
	    return OTRL_MSGTYPE_NOTOTR;
	}
    }

    if (!strncmp(otrtag, "?OTR?", 5)) return OTRL_MSGTYPE_QUERY;
    if (!strncmp(otrtag, "?OTRv", 5)) return OTRL_MSGTYPE_QUERY;
    if (!strncmp(otrtag, "?OTR:AAIC", 9)) return OTRL_MSGTYPE_DH_COMMIT;
    if (!strncmp(otrtag, "?OTR:AAIK", 9)) return OTRL_MSGTYPE_DH_KEY;
    if (!strncmp(otrtag, "?OTR:AAIR", 9)) return OTRL_MSGTYPE_REVEALSIG;
    if (!strncmp(otrtag, "?OTR:AAIS", 9)) return OTRL_MSGTYPE_SIGNATURE;
    if (!strncmp(otrtag, "?OTR:AAEK", 9)) return OTRL_MSGTYPE_V1_KEYEXCH;
    if (!strncmp(otrtag, "?OTR:AAED", 9)) return OTRL_MSGTYPE_DATA;
    if (!strncmp(otrtag, "?OTR:AAID", 9)) return OTRL_MSGTYPE_DATA;
    if (!strncmp(otrtag, "?OTR Error:", 11)) return OTRL_MSGTYPE_ERROR;

    return OTRL_MSGTYPE_UNKNOWN;
}
Example #24
0
static GList * guitartabs_chordie_parse (cb_object * capo)
{
    GList * result_list = NULL;
    gchar * search_begin = strstr (capo->cache->data,RESULTS_BEGIN);
    if (search_begin != NULL)
    {
        gchar * search_ending = strstr (search_begin,RESULTS_ENDIN);
        if (search_ending != NULL)
        {
            gchar * node  = search_begin;
            gsize nodelen = (sizeof NODE) - 1;
            while (continue_search (g_list_length (result_list),capo->s) && (node = strstr (node + nodelen, NODE) ) != NULL && node >= search_begin && node <= search_ending)
            {
                gchar * url = get_search_value (node,NODE,"\" ");
                if (url != NULL)
                {
                    gchar * name_value = get_search_value (node,"\">","</a>");
                    if (check_title_value (capo->s, name_value) == TRUE)
                    {
                        gchar * content_url = g_strdup_printf ("%s%s",BASE_URL,url);
                        GlyrMemCache * result = parse_result_page (capo->s,content_url);
                        if (result != NULL)
                        {
                            result_list = g_list_prepend (result_list,result);
                        }
                        g_free (content_url);
                    }
                    g_free (name_value);
                    g_free (url);
                }
            }
        }
    }
    return result_list;
}
Example #25
0
void SimpleCrawler::scanHtml(char* html)
{
	NodeInfo info;

	char* nodeBegin = strstr(html,"<");

	while(nodeBegin!=nullptr)
	{
		char *aNext,*imgNext;
		if(aNext = ParseANode(nodeBegin,&info))
		{
			if(!isInVisibleVec(info))
			{
				m_visibleList.push_back(info);
				m_workList.push_back(info);
				m_outputA<<UTF8ToGBK(info.text)<<":\nhost:  "<<info.host<<"\nres:  "<<info.resource<<"\n"<<endl;
			}
		}

		if(imgNext = ParseImgNode(nodeBegin,&info))
		{
			if(!isInVisibleVec(info))
			{
				m_outputImg<<UTF8ToGBK(info.text)<<":\nhost:  "<<info.host<<"\nres:  "<<info.resource<<"\n"<<endl;
			}
		}

		nodeBegin = strstr(nodeBegin+1,"<");
	}
}
Example #26
0
int main(int argc, char *argv[]) {
    char line[80];

    if (argc != 6) {
        fprintf(stderr, "You need to give 5 arguments\n");
        return 1;
    }

    FILE *in = fopen("spooky.csv", "r");
    FILE *file1 = fopen(argv[2], "w");
    FILE *file2 = fopen(argv[4], "w");
    FILE *file3 = fopen(argv[5], "w");

    while (fscanf(in, "%79[^\n]\n", line) == 1) {
        if (strstr(line, argv[1]))
            fprintf(file1, "%s\n", line);
        else if (strstr(line, argv[3]))
            fprintf(file2, "%s\n", line);
        else
            fprintf(file3, "%s\n", line);
    }

    fclose(file1);
    fclose(file2);
    fclose(file3);
    fclose(in);

    return 0;
}
Example #27
0
int ADZ_libIsValidDiskFile(HXCFLOPPYEMULATOR* floppycontext,char * imgfile)
{
	int pathlen;
	char * filepath;
	floppycontext->hxc_printf(MSG_DEBUG,"ADZ_libIsValidDiskFile %s",imgfile);
	if(imgfile)
	{
		pathlen=strlen(imgfile);
		if(pathlen!=0)
		{
			filepath=malloc(pathlen+1);
			if(filepath!=0)
			{
				sprintf(filepath,"%s",imgfile);
				strlower(filepath);
				
				if((strstr( filepath,".adz" )!=NULL) || (strstr( filepath,".adf.gz" )!=NULL))
				{
					floppycontext->hxc_printf(MSG_DEBUG,"ADZ file !");
					free(filepath);
					return LOADER_ISVALID;
				}
				else
				{
					floppycontext->hxc_printf(MSG_DEBUG,"non ADZ file !");
					free(filepath);
					return LOADER_BADFILE;
				}
			}
		}
	}
	
	return LOADER_BADPARAMETER;
}
Example #28
0
char *parseNameFromHgc(char *string)
/** parses out the name of the probe set. free returned string
with freez() */
{
char startPat[64];
char *toRet = NULL;
char *tmp = NULL;

safef(startPat, sizeof(startPat), "%s:", chip);
toRet = strstr(string, startPat);
if(toRet == NULL)
    {
    toRet = string;
    }
else
    {
    toRet++;
    toRet = strstr(toRet, ":");
    if(toRet == NULL)
	errAbort("Can't parse target name from %s.", string);
    toRet++;
    tmp = strstr(toRet, ";");
    if(tmp != NULL)
        *tmp = '\0';
    }
toRet = cloneString(toRet);
return toRet;
}
void FixDumpFileName (XnDevicePrivateData* pDevicePrivateData, XnChar* strFileName)
{
	XnChar strTempFileName[255];
	XnChar* nFind = 0;

	strcpy(strTempFileName, strFileName);

	nFind = strstr(strFileName, "SNSNSN");
	if (nFind != 0)
	{
		nFind[0] = 0;
		sprintf (strTempFileName, "%s%s%s", strFileName, pDevicePrivateData->pSensor->GetFixedParams()->GetSensorSerial(), nFind+6);

		strcpy(strFileName, strTempFileName);		
	}

	nFind = strstr(strFileName, "SETSET");
	if (nFind != 0)
	{
		XnInt32 nSet = 1;		
		XnBool bExists = TRUE;

		nFind[0] = 0;

		while (bExists == TRUE)
		{
			sprintf (strTempFileName, "%sSET%04d%s", strFileName, nSet, nFind+6);
			nSet++;

			xnOSDoesFileExist(strTempFileName, &bExists);
		}
			
		strcpy(strFileName, strTempFileName);		
	}
}
Example #30
0
static void parse_setoption(char string[]) {

   const char * name;
   char * value;

   // init

   name = strstr(string,"name ");
   value = strstr(string,"value ");

   if (name == NULL || value == NULL || name >= value) return; // ignore buttons

   value[-1] = '\0'; // HACK
   name += 5;
   value += 6;

   // update

   option_set(name,value);

   // update transposition-table size if needed

   if (Init && my_string_equal(name,"Hash")) { // Init => already allocated

      ASSERT(!Searching);

      if (option_get_int("Hash") >= 4) {
         trans_free(Trans);
         trans_alloc(Trans);
      }
   }
}