Fix prototypes and cleanup support functions a little bit.

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@401 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2002-08-03 01:59:21 +00:00
parent 0bd919fdd4
commit 00258e0fb0
5 changed files with 69 additions and 50 deletions

View File

@ -36,40 +36,47 @@ static BYTE *miscRcsId =
#include "globals.h"
#ifndef I86
VOID strcpy(REG BYTE * d, REG BYTE * s)
char *strcpy(REG BYTE * d, REG CONST BYTE * s)
{
char *tmp = d;
while ((*d++ = *s++) != '\0')
;
return tmp;
}
VOID fstrcpy(REG BYTE FAR * d, REG CONST BYTE FAR * s)
{
while (*s)
*d++ = *s++;
*d = '\0';
}
VOID fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s)
{
while (*s)
*d++ = *s++;
*d = '\0';
}
VOID fstrncpy(BYTE FAR * d, BYTE FAR * s, REG COUNT n)
VOID fstrncpy(BYTE FAR * d, BYTE CONST FAR * s, REG size_t n)
{
while (*s && n--)
*d++ = *s++;
*d = '\0';
}
VOID memcpy(REG VOID * d, REG VOID * s, REG COUNT n)
VOID * memcpy(REG VOID * d, REG CONST VOID * s, REG size_t n)
{
char *cd = d;
CONST char *cs = s;
while (n--)
*d++ = *s++;
*cd++ = *cs++;
return d;
}
VOID fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n)
VOID fmemcpy(REG VOID FAR * d, REG CONST VOID FAR * s, REG size_t n)
{
while (n--)
*((BYTE FAR *) d)++ = *((BYTE FAR *) s)++;
}
VOID fmemset(REG VOID FAR * s, REG int ch, REG COUNT n)
VOID fmemset(REG VOID FAR * s, REG int ch, REG size_t n)
{
while (n--)
*((BYTE FAR *) s)++ = ch;

View File

@ -586,7 +586,7 @@ COUNT DosSetCountry(UWORD cntry)
/*
* Called for DOS-66-01 get CP
*/
COUNT DosGetCodepage(UWORD FAR * actCP, UWORD FAR * sysCP)
COUNT DosGetCodepage(UWORD * actCP, UWORD * sysCP)
{
*sysCP = nlsInfo.sysCodePage;
*actCP = nlsInfo.actPkg->cp;

View File

@ -29,9 +29,8 @@
/****************************************************************/
#include "portab.h"
#include "globals.h"
#include "init-mod.h"
//#include "pcb.h"
#include <nls.h>
#ifdef VERSION_STRINGS
static BYTE *RcsId =
@ -49,9 +48,9 @@ STATIC int err(void)
}
#define readStruct(s) readStructure(&(s), sizeof(s), fd)
STATIC int readStructure(void *buf, int size, COUNT fd)
STATIC int readStructure(void *buf, unsigned size, COUNT fd)
{
if (DosRead(fd, buf, size) == size)
if (read(fd, buf, size) == size)
return 1;
return err();
@ -61,15 +60,15 @@ STATIC int readStructure(void *buf, int size, COUNT fd)
#define readFct(p,f) readFct_((p), (f), fd)
int readFct_(void *buf, struct csys_function *fct, COUNT fd)
{
if (DosLseek(fd, fct->csys_rpos, 0) >= 0)
if (lseek(fd, fct->csys_rpos, 0) >= 0)
return readStructure(buf, fct->csys_length, fd);
return err();
}
#define seek(n) rseek((LONG)(n), fd)
static rseek(LONG rpos, COUNT fd)
static int rseek(LONG rpos, COUNT fd)
{
if (DosLseek(fd, rpos, 1) >= 0)
if (lseek(fd, rpos, 1) >= 0)
return 1;
return err();
@ -80,20 +79,20 @@ COUNT csysOpen(void)
COUNT fd;
struct nlsCSys_fileHeader header;
if ((fd = DosOpen((BYTE FAR *) filename, 0)) < 0)
if ((fd = open(filename, 0)) < 0)
{
printf("Cannot open: \"%s\"\n", filename);
return 1;
}
if (DosRead(fd, &header, sizeof(header)) != sizeof(header);
if ((read(fd, &header, sizeof(header)) != sizeof(header))
||strcmp(header.csys_idstring, CSYS_FD_IDSTRING) != 0
|| DosLseek(fd, (LONG) sizeof(csys_completeFileHeader), 0)
!= (LONG) sizeof(csys_completeFileHeader))
|| lseek(fd, (LONG) sizeof(struct csys_completeFileHeader), 0)
!= (LONG) sizeof(struct csys_completeFileHeader))
{
printf("No valid COUNTRY.SYS: \"%s\"\n\nTry NLSFUNC /i %s\n", filename,
filename);
DosClose(fd);
close(fd);
return -1;
}
@ -115,9 +114,9 @@ STATIC int chkTable(int idx, int fctID, struct csys_function *fcts,
if (i == idx) /* already best place */
return 1;
/* Swap both places */
memcpy(&hfct, fct, sizeof(hfct));
memcpy(fct, &fcts[idx], sizeof(hfct));
memcpy(&fcts[idx], &hfct, sizeof(hfct));
fmemcpy(&hfct, fct, sizeof(hfct));
fmemcpy(fct, &fcts[idx], sizeof(hfct));
fmemcpy(&fcts[idx], &hfct, sizeof(hfct));
return 1;
}
@ -266,7 +265,7 @@ int csysLoadPackage(COUNT fd)
}
}
/* Search if the subfunction is already there */
for (j = 0; j < numFcts && fcts[j].csys_fctID != fct.csys_fctID;
for (j = 0; j < numFct && fcts[j].csys_fctID != fct.csys_fctID;
++j) ;
if (j != numFct)
{
@ -304,7 +303,7 @@ int csysLoadPackage(COUNT fd)
one additional byte is required by table 1, but which is
already within totalSize as the length of pseudo-table
0x23 has been counted. */
nls = KernelAlloc((data = sizeof(nlsPackage)
nls = KernelAlloc((data = sizeof(struct nlsPackage)
+ (numFct - 3) * sizeof(struct nlsPointer)) +
totalSize);
/* data := first byte not used by the control area of
@ -388,7 +387,7 @@ int csysLoadPackage(COUNT fd)
return 0;
}
INIT BOOL LoadCountryInfo(char *fnam)
BOOL LoadCountryInfo(char *fnam)
{
COUNT fd;
int rc;
@ -399,7 +398,7 @@ INIT BOOL LoadCountryInfo(char *fnam)
if ((fd = csysOpen()) >= 0)
{
rc = csysLoadPackage(fd);
DosClose(fd);
close(fd);
return rc;
}
}

View File

@ -34,18 +34,18 @@ static BYTE *stringsRcsId =
#endif
#ifndef I86
COUNT strlen(REG BYTE * s)
size_t strlen(REG CONST BYTE * s)
{
REG WORD cnt = 0;
REG size_t cnt = 0;
while (*s++ != 0)
++cnt;
return cnt;
}
COUNT fstrlen(REG BYTE FAR * s)
size_t fstrlen(REG CONST BYTE FAR * s)
{
REG WORD cnt = 0;
REG size_t cnt = 0;
while (*s++ != 0)
++cnt;
@ -59,15 +59,17 @@ VOID _fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s)
*d = 0;
}
VOID strncpy(REG BYTE * d, REG BYTE * s, COUNT l)
char *strncpy(register char *d, register const char *s, size_t l)
{
COUNT idx = 1;
size_t idx = 1;
char *tmp = d;
while (*s != 0 && idx++ <= l)
*d++ = *s++;
*d = 0;
return tmp;
}
COUNT strcmp(REG BYTE * d, REG BYTE * s)
int strcmp(REG CONST BYTE * d, REG CONST BYTE * s)
{
while (*s != '\0' && *d != '\0')
{
@ -91,9 +93,9 @@ COUNT fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s)
return *d - *s;
}
COUNT strncmp(REG BYTE * d, REG BYTE * s, COUNT l)
int strncmp(register const char *d, register const char *s, size_t l)
{
COUNT index = 1;
size_t index = 1;
while (*s != '\0' && *d != '\0' && index++ <= l)
{
if (*d == *s)
@ -125,14 +127,27 @@ VOID fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l)
*d = 0;
}
BYTE *strchr(BYTE * s, BYTE c)
char *strchr(const char * s, int c)
{
REG BYTE *p;
REG CONST BYTE *p;
p = s - 1;
do
{
if (*++p == c)
return p;
if (*++p == (char)c)
return (char *)p;
}
while (*p);
return 0;
}
void *memchr(const void * s, int c)
{
REG unsigned char *p;
p = (unsigned char *)s - 1;
do
{
if (*++p == (unsigned char)c)
return (void *)p;
}
while (*p);
return 0;

View File

@ -97,8 +97,7 @@ VOID fputbyte(VOID FAR * vp, UBYTE b)
VOID getdirent(UBYTE FAR * vp, struct dirent FAR * dp)
{
fmemcpy(dp->dir_name, &vp[DIR_NAME], FNAME_SIZE);
fmemcpy(dp->dir_ext, &vp[DIR_EXT], FEXT_SIZE);
fmemcpy(dp->dir_name, &vp[DIR_NAME], FNAME_SIZE + FEXT_SIZE);
dp->dir_attrib = fgetbyte(&vp[DIR_ATTRIB]);
dp->dir_time = fgetword(&vp[DIR_TIME]);
dp->dir_date = fgetword(&vp[DIR_DATE]);
@ -111,8 +110,7 @@ VOID putdirent(struct dirent FAR * dp, UBYTE FAR * vp)
REG COUNT i;
REG BYTE FAR *p;
fmemcpy(&vp[DIR_NAME], dp->dir_name, FNAME_SIZE);
fmemcpy(&vp[DIR_EXT], dp->dir_ext, FEXT_SIZE);
fmemcpy(&vp[DIR_NAME], dp->dir_name, FNAME_SIZE + FEXT_SIZE);
fputbyte(&vp[DIR_ATTRIB], dp->dir_attrib);
fputword(&vp[DIR_TIME], dp->dir_time);
fputword(&vp[DIR_DATE], dp->dir_date);