예제 #1
0
파일: dfnsquee.c 프로젝트: FDOS/freecom
char *dfnsqueeze(const char * const fnam)
{   char *p, *h, *q;

#ifdef SUPPORT_UNC_PATH
    DBG_ENTER("dfnusqueeze", Suppl_dfn)
#else
    DBG_ENTER("dfnsqueeze", Suppl_dfn)
#endif
    DBG_ARGUMENTS( ("fnam=\"%s\"", fnam) )

    if(!fnam || (h = q = eno_strdup(fnam)) == 0)
        DBG_RETURN_S( 0)

#ifdef SUPPORT_UNC_PATH
        if(isUNCpath(q))		/* keep the two backslashes */
            q += 2;
#endif

    p = q;						/* where to begin to squeeze */

    /* First: Flip the slashes */
    while((q = strchr(q, '/')) != 0)
        *q = '\\';

    /* Second: Squeeze & upcase */

    q = p;

    chkHeap
    do {
redo:
        if(*q == '\\') {	/* possibly to be squeezed */
            if(q[1] == '\\') {		/* Squeeze '\\\\' -> '\\' */
                ++q;
                goto redo;
            }
            if(q[1] == '.') {
                if(q[2] == '\\') {		/* squeeze '\\.\\' -> '\\' */
                    q += 2;
                    goto redo;
                }
#if 0			/* this may lead to confusion -- 2000/06/07 ska*/
                if(q[2] == '\0') {		/* squeeze '\\.\0' -> '\\' */
                    *p = '\\';
                    *++p = NUL;
                    break;
                }
#endif
            }
        }
    } while((*p++ = toFUpper(*q++)) != 0);

    chkHeap
    DBG_RETURN_BS( StrTrim(h))
}
예제 #2
0
파일: dmemfupr.c 프로젝트: CivilPol/sdcboot
void *MemFUpr(void * const buf, unsigned length)
{	char *p;

	DBG_ENTER("MemFUpr", Suppl_nls)

	if((p = buf) != 0)
		while(length--)
			*p = toFUpper(*p), ++p;

	DBG_RETURN_S( buf)
}
예제 #3
0
파일: dfnexpan.c 프로젝트: FDOS/freecom
char *dfnexpand(const char * const fnam, char * const path)
{	char *h, *p;				/* intermediate pointers */
	char *dr, *pa, *na, *ex;	/* filename components */
	char pathDr, *pathPa;		/* drive & path of 'path' */
	char *dynPath;

#ifdef SUPPORT_UNC_PATH
	DBG_ENTER("dfnuexpand", Suppl_dfn)
#else
	DBG_ENTER("dfnexpand", Suppl_dfn)
#endif

	assert(fnam);

	DBG_ARGUMENTS( ("fnam=\"%s\", path=\"%s\"", fnam, path) )

	chkHeap
	if((h = dfnsqueeze(fnam)) == 0) 
		DBG_RETURN_S( 0)

#ifdef SUPPORT_UNC_PATH
	if(isUNCpath(h)) {			/* UNC paths are always fully-qualified */
		/* check if the trailing '\\' is present to mark the root direc */
		DBG_RETURN_BS((*UNCpath(h) != '\\')? StrAppChr(h, '\\') : h)
	}
#endif

	chkHeap
	if(!*h || h[1] != ':' || h[2] != '\\') {
	/* the spec is not fully-qualified or completely empty */
		pathDr = 0;
		dynPath = 0;
		if((pathPa = path) != 0 && *pathPa) {
			if(pathPa[1] == ':') {	/* path[] has drive spec */
				pathDr = *path;
				if(!*(pathPa += 2)) {
					pathPa = 0;
					goto noPath;
				}
			}
			if(dfndelim(*pathPa) && !pathPa[1])
				++pathPa;		/* Trans "/" || "\\" --> "" */
noPath:;
		}
		chkHeap
		if(dfnsplit(h, &dr, &pa, &na, &ex)) {
			StrFree(h);
			if(dr) {				/* drive specified */
				if(pathDr && toFUpper(pathDr) != *dr)
					/* The specified path is for a different drive */
					pathPa = 0;
			}
			else {					/* drive spec missing */
				if((dr = StrChar(pathDr? pathDr: 'A' + getdisk())) == 0)
					goto errRet;
			}

			if(!pa || *pa != '\\' && *pa != NUL) {
			/* no path or a relative one */
				if(!pathPa) {				/* path has no path spec in it */
					if((dynPath = dfnpath(*dr)) == 0)
						goto errRet;
					pathPa = dynPath + 2;
				}

				if((p = dfnmerge(0, 0, pathPa, pa, 0)) == 0)
					goto errRet;
 				StrRepl(pa, p);
			}
			h = dfnmerge(0, dr, pa, na, ex);
		} else
			StrFree(h);

errRet:
		chkHeap
		free(dr);
		free(pa);
		free(na);
		free(ex);
		free(dynPath);
	}