Exemple #1
0
long x_closedir(XDIR *dir)
{
#if _MINT_
	if (mint)			/* HR 151102 */
	{
		if (dir->type)
		{
			/*
			 * DOS file system.
			 */
	
#if USE_gemdos
			gemdos(26, dir->data.gdata.old_dta);
#else
			Fsetdta(dir->data.gdata.old_dta);
#endif
			free(dir);
			return 0L;
		}
		else
		{
			/*
			 * File system with long filenames.
			 */
	
			long error;
	
#if USE_gemdos
			error = xerror(gemdos(0x12B, dir->data.handle));
#else
			error = xerror(Dclosedir(dir->data.handle));
#endif
			free(dir);
			return error;
		}
	}
	else
#endif
	{
#if USE_gemdos
		gemdos(26, dir->data.gdata.old_dta);
#else
		Fsetdta(dir->data.gdata.old_dta);
#endif
		free(dir);
		return 0L;
	}
}
Exemple #2
0
long x_rewinddir(XDIR *dir)
{
#if _MINT_
	if (mint)			/* HR 151102 */
	{
		if (dir->type)
		{
			/*
			 * DOS file system.
			 */
	
			dir->data.gdata.first = 1;
			return 0L;
		}
		else
		{
			/*
			 * File system with long filenames.
			 */
	
#if USE_gemdos
			return xerror(gemdos(0x12A, dir->data.handle));
#else
			return xerror(Drewinddir(dir->data.handle));
#endif
		}
	}
	else
#endif
	{
		dir->data.gdata.first = 1;
		return 0L;
	}
}
Exemple #3
0
char *x_getpath(int drive, int *error)
{
	char *buffer, *h;

	if ((buffer = malloc(sizeof(LNAME))) == NULL)			/* HR 240203 */
	{
		*error = ENSMEM;
		return NULL;
	}

	buffer[0] = (char) (((drive == 0) ? x_getdrv(): (drive - 1)) + 'A');
	buffer[1] = ':';

#if USE_gemdos
	if ((*error = xerror((int) gemdos(71, buffer + 2, drive))) < 0)
#else
	if ((*error = xerror(Dgetpath(buffer + 2, drive))) < 0)
#endif
	{
		free(buffer);
		return NULL;
	}

	h = realloc(buffer, strlen(buffer) + 1);

	return (h == NULL) ? buffer : h;
}
Exemple #4
0
WORD dos_label(BYTE drive, BYTE *plabel)
{
    DTA     dta;
    BYTE    path[8];

    gemdos(X_SETDTA,&dta);
    strcpy(path, " :\\*.*");
    path[0] = (drive + 'A') - 1;
    if (!gemdos(X_SFIRST,path,0x08))
    {
        strcpy(plabel,dta.d_fname);
        return TRUE;
    }
    else
        return FALSE;
}
Exemple #5
0
long gc(long target)
{
	long old_stack;
	t_cookie **ptr_tab_cookie=(t_cookie **)0x5a0;	
							/* pointeur vers le tableau des cookie	*/
	t_cookie *tab_cookie;

	/* pour lire l'adresse du tableau des cookies, il faut etre en mode	
		superviseur		*/
	if (gemdos(0x20,1L)==0L)	/* si on est en mode utilisateur	*/
	{		
		old_stack=gemdos(0x20,0L);	/* on passe en mode superviseur	*/
	}
	else
	{	
		old_stack=0;
	}
	tab_cookie=*ptr_tab_cookie;	/* on lit cette adresse			*/
	
	
	if (old_stack)				/* si on etait en utilisateur au debut	*/
	{
		gemdos(0x20,old_stack);	/*  on y retourne */
	}				
		
	if (tab_cookie==0L)		/* si le tos <1.6, on n'a pas de cookie jar	*/
		return(-1);				
		
	do		/* on boucle jusqu'a avoir trouve le cookie ou avoir atteint			*/
			/* le dernier element de la cookie jar									*/
	{
		if (tab_cookie	->ident	==target)	/* si le cookie est le cookie recherche	*/
		{
			return(tab_cookie	->valeur);	/* on renvoie sa valeur					*/
		}
		else
		{
			/* sinon, on passe au cookie suivant	*/
			tab_cookie++;
		}	
	}	
	while (tab_cookie->ident!=0);	/* la table des cookie est toujours	*/
						/* terminee par un cookie dont l'ident vaut	0	*/

	/* si on n'a pas trouve le cookie	, on renvoie -1 */
	return(-1);
}
Exemple #6
0
int x_datime(DOSTIME *time, int handle, int wflag)
{
#if USE_gemdos
	return xerror((int) gemdos(87, time, handle, wflag));
#else
	return xerror(Fdatime(time, handle, wflag));
#endif
}
Exemple #7
0
int x_fattrib(const char *file, int wflag, int attrib)
{
#if USE_gemdos
	return xerror((int) gemdos(67, file, wflag, attrib));
#else
	return xerror(Fattrib(file, wflag, attrib));
#endif
}
Exemple #8
0
int x_unlink(const char *file)
{
#if USE_gemdos
	return xerror((int) gemdos(65, file));
#else
	return xerror(Fdelete(file));
#endif
}
Exemple #9
0
int x_rename(const char *oldname, const char *newname)
{
#if USE_gemdos
	return xerror((int) gemdos(86, 0, oldname, newname));
#else
	return xerror(Frename(0, oldname, newname));
#endif
}
Exemple #10
0
long x_setdrv(int drive)
{
#if USE_gemdos
	return gemdos(14, drive);
#else
	return Dsetdrv(drive);
#endif
}
Exemple #11
0
int x_getdrv(void)
{
#if USE_gemdos
	return (int) gemdos(25);
#else
	return Dgetdrv();
#endif
}
Exemple #12
0
int x_dfree(DISKINFO *diskinfo, int drive)
{
#if USE_gemdos
	return xerror((int) gemdos(54, diskinfo, drive));
#else
	return xerror(Dfree(diskinfo, drive));
#endif
}
Exemple #13
0
int x_rmdir(const char *path)
{
#if USE_gemdos
	return xerror((int) gemdos(58, path));
#else
	return xerror(Ddelete(path));
#endif
}
Exemple #14
0
int x_mkdir(const char *path)
{
#if USE_gemdos
	return xerror((int) gemdos(57, path));
#else
	return xerror(Dcreate(path));
#endif
}
Exemple #15
0
int x_setpath(const char *path)
{
#if USE_gemdos
	return xerror((int) gemdos(59, path));
#else
	return xerror(Dsetpath(path));
#endif
}
Exemple #16
0
int x_close(int handle)
{
#if USE_gemdos
	return xerror((int) gemdos(62, handle));
#else
	return xerror(Fclose(handle));
#endif
}
Exemple #17
0
WORD dos_setdt(UWORD h, UWORD time, UWORD date)
{
    UWORD   buf[2];

    buf[0] = time;
    buf[1] = date;
    return gemdos(X_GSDTOF,buf,h,TRUE);
}
Exemple #18
0
WORD pgmld(WORD handle, BYTE *pname, LONG **ldaddr)
{
    LONG    length, ret;
    LONG    *temp;

    ret = gemdos(X_EXEC, 3, pname, "", NULL);
    if (ret < 0L)
        return -1;

    *ldaddr = (LONG *) ret;

    /* program length = code+data+bss lengths plus basepage length */
    temp = *ldaddr;
    length = temp[3] + temp[5] + temp[7] + 0x100;
    if (gemdos(X_SETBLOCK, 0, *ldaddr, length) < 0L)
        return -1;

    return 0;
}
Exemple #19
0
void p_s_top(void)
	{
	s_long=2;
	z_long=0;
	do
		{
		if(even(s_long))
			{
			print_at(s_long-1,72);
			printf(" %s ",z_char);
			}
		else
			{
			print_at(s_long,72);
			printf("%cp%s%cq",*chr(27),z_char,*chr(27));
			}
		pause( 10);
		if(gemdos(11) != 0)
			{
			z_long=gemdos(1);
			}
		if(z_long==0)
			{
			++s_long;
			z_long=d_iv(s_long,65);
			}
		else if(z_long==1)
			{
			--s_long;
			if(s_long==2)
				{
				z_long=0;
				}
			}
		pause( 10);
		if(bios(1,2) != 0)
			{
			z_long=inp(2);
			}
		}
	while(!(z_long>1));
	}
Exemple #20
0
long x_attr(int flag, const char *name, XATTR *xattr)
{
#if _MINT_
	if (mint)				/* HR 151102 */
	#if USE_gemdos
		return xerror((int) gemdos(0x12C, flag, name, xattr));
	#else
		return xerror(Fxattr(flag, name, xattr));
	#endif
	else
#endif
	{
Exemple #21
0
int x_create(const char *file, int attr)
{
	long result;				/* HR 101202 long */

#if USE_gemdos
	result = (int) gemdos(60, file, attr);
#else
	result = Fcreate(file, attr);
#endif

	return (result < 0) ? xerror(result) : result;
}
Exemple #22
0
long x_seek(long offset, int handle, int seekmode)
{
	long result;

#if USE_gemdos
	result = gemdos(66, offset, handle, seekmode);
#else
	result = Fseek(offset, handle, seekmode);
#endif

	return (result < 0) ? (long) xerror((int) result) : result;
}
Exemple #23
0
long x_write(int handle, long count, char *buf)
{
	long result;

#if USE_gemdos
	result = gemdos(64, handle, count, buf);
#else
	result = Fwrite(handle, count, buf);
#endif

	return (result < 0) ? (long) xerror((int) result) : result;
}
Exemple #24
0
void dos_space(WORD drv, LONG *ptotal, LONG *pavail)
{
    LONG    buf[4];
    LONG    mult;

    *ptotal = *pavail = 0L;

    if (gemdos(X_GETFREE,buf,drv) < 0L) /* 0=default, 1=A for gemdos */
        return;

    mult = buf[3] * buf[2];
    *ptotal = mult * buf[1];
    *pavail = mult * buf[0];
}
Exemple #25
0
int x_getlabel(int drive, char *label)
{
	DTA *olddta, dta;
	int error;
	char path[10];

#if USE_gemdos
	olddta = (DTA *) gemdos(47);
	gemdos(26, &dta);
#else
	olddta = Fgetdta();
	Fsetdta(&dta);
#endif

	strcpy(path, "A:\\*.*");
	path[0] += (char) drive;

#if USE_gemdos
	error = (int) gemdos(78, path, 0x3F);
#else
	error = Fsfirst(path, 0x3F);
#endif

	/* if ((error == 0) && (dta.d_attrib & 8)) DjV 004 300103 */
	if ((error == 0) && (dta.d_attrib & FA_VOLUME)) /* DjV 004 300103 same but more readable */
		strcpy(label, dta.d_fname);
	else
		*label = 0;

#if USE_gemdos
	gemdos(26, olddta);
#else
	Fsetdta(olddta);
#endif

	return ((error == -49) || (error == -33)) ? 0 : error;
}
Exemple #26
0
int x_open(const char *file, int mode)
{
	long result;			/* HR 151102 */

	if (!flock)
		mode &= O_RWMODE;

#if USE_gemdos
	result = gemdos(61, file, mode);
#else
	result = Fopen(file, mode);
#endif

	return (result < 0) ? xerror(result) : result;
}
Exemple #27
0
static int _fullname(char *buffer)
{
	char *name, *h, *d, *s;
	int error;

	if ((name = strdup(buffer)) == NULL)
		error = ENSMEM;
	else
	{
		d = buffer;

		if ((h = strchr(name, ':')) == NULL)
		{
			*d++ = (char) (x_getdrv() + 'A');
			*d++ = ':';
			h = name;
		}
		else
		{
			h++;
			s = name;
			while (s != h)
				*d++ = *s++;
		}

		if (*h == '\\')
		{
			strcpy(d, h);
			error = 0;
		}
		else
		{
#if USE_gemdos
			if ((error = xerror((int) gemdos(71, d, (int) (buffer[0] - 'A' + 1)))) == 0)
#else
			if ((error = xerror(Dgetpath(d, buffer[0] - 'A' + 1))) == 0)
#endif
				make_path(buffer, buffer, h);
		}
		free(name);
	}
	return error;
}
Exemple #28
0
WORD dos_shrink(void *maddr, LONG length)
{
    return gemdos(X_SETBLOCK,0,maddr,length);
}
Exemple #29
0
WORD dos_free(LONG maddr)
{
    return gemdos(X_MFREE,maddr);
}
Exemple #30
0
/*
 *  Returns the amount of memory available in bytes
 */
LONG dos_avail(void)
{
    return gemdos(X_MALLOC,-1L);
}