mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-10-01 12:23:22 +08:00
tune for 64 bits
This commit is contained in:
+15
-7
@@ -102,34 +102,42 @@ int MGUI_WriteLE64 (MG_RWops *dst, Uint64 value)
|
||||
int MGUI_WriteBE64 (MG_RWops *dst, Uint64 value)
|
||||
{
|
||||
value = ArchSwapBE64(value);
|
||||
return(MGUI_RWwrite(dst, &value, (sizeof value), 1));
|
||||
return (MGUI_RWwrite(dst, &value, (sizeof value), 1));
|
||||
}
|
||||
|
||||
Uint16 MGUI_ReadLE16FP (FILE *src)
|
||||
{
|
||||
Uint16 value;
|
||||
size_t size;
|
||||
|
||||
fread (&value, (sizeof value), 1, src);
|
||||
return(ArchSwapLE16(value));
|
||||
size = fread (&value, (sizeof value), 1, src);
|
||||
if (size < sizeof (value))
|
||||
return -1;
|
||||
|
||||
return (ArchSwapLE16(value));
|
||||
}
|
||||
|
||||
Uint32 MGUI_ReadLE32FP (FILE *src)
|
||||
{
|
||||
Uint32 value;
|
||||
size_t size;
|
||||
|
||||
fread(&value, (sizeof value), 1, src);
|
||||
return(ArchSwapLE32(value));
|
||||
size = fread(&value, (sizeof value), 1, src);
|
||||
if (size < sizeof (value))
|
||||
return -1;
|
||||
|
||||
return (ArchSwapLE32(value));
|
||||
}
|
||||
|
||||
int MGUI_WriteLE16FP (FILE *dst, Uint16 value)
|
||||
{
|
||||
value = ArchSwapLE16(value);
|
||||
return(fwrite (&value, (sizeof value), 1, dst));
|
||||
return (fwrite (&value, (sizeof value), 1, dst));
|
||||
}
|
||||
|
||||
int MGUI_WriteLE32FP (FILE *dst, Uint32 value)
|
||||
{
|
||||
value = ArchSwapLE32(value);
|
||||
return(fwrite (&value, (sizeof value), 1, dst));
|
||||
return (fwrite (&value, (sizeof value), 1, dst));
|
||||
}
|
||||
|
||||
|
||||
+61
-58
@@ -54,46 +54,46 @@ void __mg_rewind (FILE *fp);
|
||||
|
||||
int my_fputs (const char *s, FILE *stream)
|
||||
{
|
||||
int len = strlen (s);
|
||||
int ret = 0;
|
||||
|
||||
ret = fwrite (s, 1, len, stream);
|
||||
if (ret != len)
|
||||
return EOF;
|
||||
else
|
||||
return ret;
|
||||
int len = strlen (s);
|
||||
int ret = 0;
|
||||
|
||||
ret = fwrite (s, 1, len, stream);
|
||||
if (ret != len)
|
||||
return EOF;
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
char * my_fgets (char *s, int size, FILE *stream)
|
||||
{
|
||||
int c;
|
||||
int count = 0;
|
||||
int c;
|
||||
int count = 0;
|
||||
|
||||
while (!feof (stream)) {
|
||||
if (fread (&c, 1, 1, stream) != 1) {
|
||||
if (count == 0)
|
||||
return NULL;
|
||||
else {
|
||||
s[count] = '\0';
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
if (c == EOF || (char)c == '\r' ||(char)c == '\n') {
|
||||
s [count++] = (char)c;
|
||||
s [count++] = '\0';
|
||||
return s;
|
||||
}
|
||||
else
|
||||
s[count++] = (char)c;
|
||||
}
|
||||
if (!count)
|
||||
return NULL;
|
||||
else
|
||||
{
|
||||
s[count] = '\0';
|
||||
return s;
|
||||
}
|
||||
while (!feof (stream)) {
|
||||
if (fread (&c, 1, 1, stream) != 1) {
|
||||
if (count == 0)
|
||||
return NULL;
|
||||
else {
|
||||
s[count] = '\0';
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
if (c == EOF || (char)c == '\r' ||(char)c == '\n') {
|
||||
s [count++] = (char)c;
|
||||
s [count++] = '\0';
|
||||
return s;
|
||||
}
|
||||
else
|
||||
s[count++] = (char)c;
|
||||
}
|
||||
if (!count)
|
||||
return NULL;
|
||||
else
|
||||
{
|
||||
s[count] = '\0';
|
||||
return s;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
///////////////////////////////
|
||||
@@ -127,7 +127,10 @@ static BOOL LookForEtcFile (void)
|
||||
}
|
||||
|
||||
|
||||
getcwd (etcfile, MAX_PATH);
|
||||
if (getcwd (etcfile, MAX_PATH) == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
strcat (etcfile, "/");
|
||||
strcat (etcfile, ETCFILENAME);
|
||||
if (GetValueFromEtcFile (etcfile, "system", "gal_engine", buff, 8)
|
||||
@@ -151,41 +154,41 @@ static BOOL LookForEtcFile (void)
|
||||
}
|
||||
}
|
||||
|
||||
strcpy (etcfile, "/usr/local/etc/" ETCFILENAME);
|
||||
if (GetValueFromEtcFile (etcfile, "system", "gal_engine", buff, 8)
|
||||
== ETC_OK) {
|
||||
strcpy (ETCFILEPATH, etcfile);
|
||||
return TRUE;
|
||||
}
|
||||
strcpy (etcfile, "/usr/local/etc/" ETCFILENAME);
|
||||
if (GetValueFromEtcFile (etcfile, "system", "gal_engine", buff, 8)
|
||||
== ETC_OK) {
|
||||
strcpy (ETCFILEPATH, etcfile);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
strcpy (etcfile, "/etc/" ETCFILENAME);
|
||||
if (GetValueFromEtcFile (etcfile, "system", "gal_engine", buff, 8)
|
||||
== ETC_OK) {
|
||||
strcpy (ETCFILEPATH, etcfile);
|
||||
return TRUE;
|
||||
}
|
||||
strcpy (etcfile, "/etc/" ETCFILENAME);
|
||||
if (GetValueFromEtcFile (etcfile, "system", "gal_engine", buff, 8)
|
||||
== ETC_OK) {
|
||||
strcpy (ETCFILEPATH, etcfile);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
|
||||
#elif defined(WIN32)
|
||||
sprintf(etcfile, "c:\\windows\\%s", ETCFILENAME);
|
||||
sprintf(etcfile, "c:\\windows\\%s", ETCFILENAME);
|
||||
if (GetValueFromEtcFile (etcfile, "system", "gal_engine", buff, 8)
|
||||
== ETC_OK) {
|
||||
strcpy (ETCFILEPATH, etcfile);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
sprintf(etcfile, "c:\\%s", ETCFILENAME);
|
||||
sprintf(etcfile, "c:\\%s", ETCFILENAME);
|
||||
if (GetValueFromEtcFile (etcfile, "system", "gal_engine", buff, 8)
|
||||
== ETC_OK) {
|
||||
strcpy (ETCFILEPATH, etcfile);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
#elif defined(__THREADX__)
|
||||
char etcpath[MAX_PATH]= "/flash/fhas2-cfg/";
|
||||
strcpy (etcfile, etcpath);
|
||||
strcat (etcfile, ETCFILENAME);
|
||||
char etcpath[MAX_PATH]= "/flash/fhas2-cfg/";
|
||||
strcpy (etcfile, etcpath);
|
||||
strcat (etcfile, ETCFILENAME);
|
||||
#endif
|
||||
|
||||
if (GetValueFromEtcFile (etcfile, "system", "gal_engine", buff, 8)
|
||||
@@ -207,7 +210,7 @@ BOOL mg_InitMgEtc (void)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (hMgEtc)
|
||||
if (hMgEtc)
|
||||
return TRUE;
|
||||
|
||||
if ( !(hMgEtc = LoadEtcFile (ETCFILEPATH)) )
|
||||
@@ -1070,7 +1073,7 @@ GHANDLE GUIAPI FindSectionInEtc (GHANDLE hEtc,
|
||||
/* not found */
|
||||
if (bCreateNew) {
|
||||
if (petc->sect_nr_alloc <= 0)
|
||||
return ETC_READONLYOBJ;
|
||||
return (GHANDLE) ETC_READONLYOBJ;
|
||||
|
||||
if (empty_section >= 0) {
|
||||
psect = petc->sections + empty_section;
|
||||
@@ -1314,7 +1317,7 @@ void mswin_ping(void);
|
||||
void GUIAPI Ping(void)
|
||||
{
|
||||
#ifdef WIN32
|
||||
mswin_ping();
|
||||
mswin_ping();
|
||||
#else
|
||||
putchar ('\a');
|
||||
fflush (stdout);
|
||||
|
||||
+4
-4
@@ -277,8 +277,8 @@ MG_RWops *MGUI_RWFromMem(void *mem, int size)
|
||||
rwops->eof = mem_eof;
|
||||
rwops->hidden.mem.base = (Uint8 *)mem;
|
||||
rwops->hidden.mem.here = rwops->hidden.mem.base;
|
||||
if ((0xFFFFFFFF - (Uint32)mem) < size)
|
||||
rwops->hidden.mem.stop = (void*)0xFFFFFFFF;
|
||||
if ((UINT_PTR_MAX - (UINT_PTR)mem) < size)
|
||||
rwops->hidden.mem.stop = (void*)UINT_PTR_MAX;
|
||||
else
|
||||
rwops->hidden.mem.stop = rwops->hidden.mem.base+size;
|
||||
|
||||
@@ -299,8 +299,8 @@ void MGUI_InitMemRW (MG_RWops* area, void *mem, int size)
|
||||
area->eof = mem_eof;
|
||||
area->hidden.mem.base = (Uint8 *)mem;
|
||||
area->hidden.mem.here = area->hidden.mem.base;
|
||||
if ((0xFFFFFFFF - (Uint32)mem) < size)
|
||||
area->hidden.mem.stop = (void*)0xFFFFFFFF;
|
||||
if ((UINT_PTR_MAX - (UINT_PTR)mem) < size)
|
||||
area->hidden.mem.stop = (void*)UINT_PTR_MAX;
|
||||
else
|
||||
area->hidden.mem.stop = area->hidden.mem.base+size;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user