예제 #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
파일: dstrrigh.c 프로젝트: CivilPol/sdcboot
char *StrRight(const char * const s, size_t length)
{	unsigned l;

	DBG_ENTER("StrRight", Suppl_dynstr)

	if(!s) return 0;

	chkHeap
	DBG_RETURN_BS(((l = (unsigned)strlen(s)) <= length)
	 ? eno_strdup(s)								/* complete copy */
	 : StrTail(s, l - length))
}
예제 #3
0
파일: dstrchar.c 프로젝트: FDOS/freecom
char *StrChar(int ch)
{	char *h;

	DBG_ENTER("StrChar", Suppl_dynstr)
	DBG_ARGUMENTS( ("ch='%c' (0x02x)", ch > 32? ch: ' ', ch) )

	chkHeap
	if((h = eno_strdup(" ")) != 0)
		*h = ch;

	chkHeap
	DBG_RETURN_S( h)
}
예제 #4
0
파일: dstrconc.c 프로젝트: CivilPol/sdcboot
char *StrConcat(int argcnt, ...)
{	va_list strings;
	char *h, *p, *s;
	unsigned length;

	DBG_ENTER("StrConcat", Suppl_dynstr)
	DBG_ARGUMENTS( ("argcnt=%u cnt=%u", argcnt, argcnt) )

	va_start(strings, argcnt);
	chkHeap
	if((p = eno_strdup("")) == 0)
		DBG_RETURN_S( 0)
	chkHeap
	length = 1;
	while(argcnt--) {
		s = va_arg(strings, char *);
		if(s && *s) {
			chkHeap
			if((h = eno_realloc(p, length += strlen(s))) == 0) {
				free(p);
				DBG_RETURN_S( 0)
			}
			strcat(p = h, s);
		}
예제 #5
0
#ifndef _MICROC_
#include <string.h>
#include <stdlib.h>
#endif
#include <portable.h>
#include "dynstr.h"
#include "eno.loc"

#include "suppldbg.h"

#ifdef RCS_Version
static char const rcsid[] = 
	"$Id: dstrmid.c 1210 2006-06-17 03:25:06Z blairdude $";
#endif

char *StrMiddle(const char * const str, size_t pos, size_t length)
{
	DBG_ENTER("StrMiddle", Suppl_dynstr)

	if(!str) {
		eno_set(EINVAL);
		DBG_RETURN_S(0)
	}

	DBG_ARGUMENTS( ("str=\"%s\", pos=%u, len=%u", str, pos, length) )

	chkHeap
	DBG_RETURN_BS( strlen(str) <= pos? eno_strdup(""): StrLeft(str + pos, length))
}