Beispiel #1
0
char *dfntruename(const char * const fnam)
{	char *h;
	struct REGPACK r;

	DBG_ENTER("dfntruename", Suppl_dfn)

	assert(fnam);

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

	chkHeap
	if((h = eno_malloc(DFN_FILENAME_BUFFER_LENGTH)) != 0) {
#ifdef FEATURE_LONG_FILENAMES
        r.r_ax = 0x7160;
        r.r_cx = 0x02;
#else
		r.r_ax = 0x6000;
#endif
        r.r_ds = FP_SEG(fnam);
		r.r_si = FP_OFF(fnam);
		r.r_es = FP_SEG(h);
		r.r_di = FP_OFF(h);
		chkHeap
        intr( 0x21, &r );
#ifdef FEATURE_LONG_FILENAMES
        if( ( r.r_flags & 1 ) || r.r_ax == 0x7100 ) {
            r.r_ax = 0x6000;
            intr( 0x21, &r );
#endif
		if(( r.r_flags & 1 ) ? r.r_ax : 0) {		/* failed */
			eno_setOSerror( r.r_ax);
			free(h);
			DBG_RETURN_S( 0)
		}
Beispiel #2
0
register char *StrConcat(int argcnt)
{	unsigned cnt, *poi;
	unsigned Xcnt, *Xpoi;
	unsigned length;
	char *h, *p;
	DBG_ENTER1

	cnt = nargs();

	DBG_ENTER2("StrConcat", "dynstr")
	DBG_ARGUMENTS( ("argcnt=%u cnt=%u", argcnt, cnt) )

	Xpoi = poi = cnt * 2 - 2 + &argcnt;
	Xcnt = cnt = min(cnt, *poi);
	for(length = 1; cnt--;)
		if(*--poi) length += strlen(*poi);

	chkHeap
	if((h = p = eno_malloc(length)) == 0)
		DBG_RETURN_S( 0)

	chkHeap
	while(Xcnt--)
		if(*--Xpoi)
			p = stpcpy(p, *Xpoi);

	chkHeap
	DBG_RETURN_S( h)
}
Beispiel #3
0
char *dfnbakname(const char * const fnam)
{	char *p, *q, *h;

	DBG_ENTER("dfnbakname", Suppl_dfn)

	assert(fnam);

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

	/* Allocate 5 bytes more to be absolutely sure that
		the ".BAK" can be appended */
	chkHeap
	if((p = eno_malloc(strlen(fnam) + 5)) == 0)
		DBG_RETURN_S( 0)

	chkHeap
	if((h = strrchr(q = dfnfilename(strcpy(p, fnam)), '.')) == 0)
		h = strchr(q, '\0');

	strcpy(h, ".BAK");

	chkHeap
	DBG_RETURN_S( p)
}
Beispiel #4
0
char *dfnmerge(char *fnam, const char * const dr, const char * const Xpath
 , const char * const nam, const char * const ext)
{	int len;
	const char *path;
	char *p;
	int delim;		/* type of last path component delimiter:
						0: none
						1: a "real" one ('/' or '\\') or none necessary
						2: a colon
					*/

#ifdef SUPPORT_UNC_PATH
	DBG_ENTER("dfnumerge", Suppl_dfn)
#else
	DBG_ENTER("dfnmerge", Suppl_dfn)
#endif
	DBG_ARGUMENTS( ("dr=\"%s\", pa=\"%s\", na=\"%s\", ex=\"%s\", out=%p", dr, Xpath, nam, ext, fnam) )

	path = Xpath;
	if((p = fnam) == 0) {	/* determine file nam length */
#ifdef SUPPORT_UNC_PATH
		len = dr? (*dr == '\\'? strlen(dr) + 1: 3): 1;
#else
		len = dr? 3: 1;		/* add the NUL terminator */
#endif
		if(path) {
			if(*path)
				len += strlen(path) + 1;
			else path = 0;	/* no path component specified */
		}
		if(nam) len += strlen(nam);
		if(ext) len += strlen(ext) + 1;
		if((fnam = p = eno_malloc(len)) == 0)
			DBG_RETURN_S( 0)
		*fnam = NUL;
	}

	if(dr) {
#ifdef SUPPORT_UNC_PATH
		if(*dr == '\\') {
			p = stpcpy(p, dr);
				/* Test if the drive spec already ends with a delimiter */
			delim = isDelim(p[-1]);
		}
		else {
#endif
			if(0 != (*p = *dr))
				++p;
			*p++ = ':';
				/* The colon is not a delimiter for root directories */
			delim = 2;
#ifdef SUPPORT_UNC_PATH
		}
#endif
		*p = NUL;
	}
	else delim = 1;		/* no drive --> no delim necessary */

	if(path) {
		switch(delim) {
		case 0:		/* missing delimiter --> need one unless path
						has one */
			if(!isDelim(*path)) *p++ = '\\';
			break;
		}
		if(!*path)		/* The root dir always requires a backslash */
			*p++ = '\\';
		/* Now, the delimiter is definitely there */
		p = stpcpy(p, path);
		if(0 == (delim = isDelim(p[-1]))) {
			if(p[-1] == ':')
				delim = 2;
		}
	}

	if(nam)	{
		if(!delim) {
			if(!isDelim(*nam))
				*p++ = '\\';
			delim = 1;
		}
		p = stpcpy(p, nam);
	}

	if(ext) {
		if(!delim) {
			*p++ = '\\';
			delim = 1;
		}
		*p++ = '.';
		strcpy(p, ext);
	}

	DBG_RETURN_S( fnam)
}