58 #if (HARDWARE != SIMULATION)
65 #include <sys/statvfs.h>
67 #include <sys/types.h>
69 #include <sys/sysinfo.h>
75 #define snprintf _snprintf
83 gMemoryInstance= _Instance;
95 #define DEBUG_C_MEMORY_LOG
96 #define DEBUG_C_MEMORY_FILE
100 #define DUBUG_TRACE_FILENAME
109 struct statvfs Status;
123 Used = (
DATA32)((((Status.f_blocks - Status.f_bavail) * Status.f_bsize) + (
KB - 1)) /
KB);
130 #ifdef DEBUG_C_MEMORY_LOW
142 RESULT Result = FAIL;
147 if (((Size + (
KB - 1)) /
KB) < (Free - RESERVED_MEMORY))
149 *ppMemory = malloc((
size_t)Size);
150 if (*ppMemory !=
NULL)
162 RESULT Result = FAIL;
164 *ppMemory = realloc(pOldMemory,(
size_t)Size);
165 if (*ppMemory !=
NULL)
176 RESULT Result = FAIL;
181 if ((PrgId < MAX_PROGRAMS) && (Size > 0) && (Size <= MAX_ARRAY_SIZE))
185 while ((TmpHandle < MAX_HANDLES) && (MemoryInstance.
pPoolList[PrgId][TmpHandle].
pPool !=
NULL))
189 if (TmpHandle < MAX_HANDLES)
197 *pHandle = TmpHandle;
200 printf(
" Malloc P=%1u H=%1u T=%1u S=%8lu A=%8p\r\n",(
unsigned int)PrgId,(
unsigned int)TmpHandle,(
unsigned int)Type,(
unsigned long)Size,MemoryInstance.
pPoolList[PrgId][TmpHandle].
pPool);
208 printf(
" Malloc error P=%1u S=%8lu\r\n",(
unsigned int)PrgId,(
unsigned long)Size);
221 if ((PrgId < MAX_PROGRAMS) && (Handle >= 0) && (Handle < MAX_HANDLES))
223 if ((Size > 0) && (Size <= MAX_ARRAY_SIZE))
233 printf(
"cMemoryReallocate out of memory\r\n");
240 printf(
" Reallocate P=%1u H=%1u S=%8lu A=%8p\r\n",(
unsigned int)PrgId,(
unsigned int)Handle,(
unsigned long)Size,MemoryInstance.
pPoolList[PrgId][Handle].
pPool);
244 printf(
" Reallocate error P=%1u H=%1u S=%8lu\r\n",(
unsigned int)PrgId,(
unsigned int)Handle,(
unsigned long)Size);
254 RESULT Result = FAIL;
258 if ((PrgId < MAX_PROGRAMS) && (Handle >= 0) && (Handle < MAX_HANDLES))
269 printf(
" Get pointer error P=%1u H=%1u\r\n",(
unsigned int)PrgId,(
unsigned int)Handle);
279 RESULT Result = FAIL;
284 *pMemory = (*(
DESCR*)pTmp).pArray;
297 if ((PrgId < MAX_PROGRAMS) && (Handle >= 0) && (Handle < MAX_HANDLES))
304 if (((*pFDescr).Access))
306 (*pFDescr).Access = 0;
307 close((*pFDescr).hFile);
312 printf(
" Close file %d\r\n",(*pFDescr).hFile);
321 printf(
" Free P=%1u H=%1u T=%1u S=%8lu A=%8p\r\n",(
unsigned int)PrgId,(
unsigned int)Handle,(
unsigned int)MemoryInstance.
pPoolList[PrgId][Handle].
Type,(
unsigned long)MemoryInstance.
pPoolList[PrgId][Handle].
Size,MemoryInstance.
pPoolList[PrgId][Handle].
pPool);
339 while ((TmpHandle < MAX_HANDLES) && (MemoryInstance.
pPoolList[PrgId][TmpHandle].
pPool != pMemory))
343 if (TmpHandle < MAX_HANDLES)
354 for (TmpHandle = 0;TmpHandle < MAX_HANDLES;TmpHandle++)
360 MemoryInstance.
PathList[PrgId][0] = 0;
368 for (TmpPrgId = 0;TmpPrgId < MAX_PROGRAMS;TmpPrgId++)
377 RESULT Result = FAIL;
382 char PrgNameBuf[vmFILENAMESIZE];
384 snprintf(PrgNameBuf,vmFILENAMESIZE,
"%s/%s%s",vmSETTINGS_DIR,vmLASTRUN_FILE_NAME,vmEXT_CONFIG);
385 File = open(PrgNameBuf,O_RDONLY);
386 if (File >= MIN_HANDLE)
388 if (read(File,MemoryInstance.
Cache,
sizeof(MemoryInstance.
Cache)) !=
sizeof(MemoryInstance.
Cache))
400 for (Tmp = 0;Tmp < CACHE_DEEPT;Tmp++)
402 MemoryInstance.
Cache[Tmp][0] = 0;
406 for (TmpPrgId = 0;TmpPrgId < MAX_PROGRAMS;TmpPrgId++)
408 for (TmpHandle = 0;TmpHandle < MAX_HANDLES;TmpHandle++)
428 RESULT Result = FAIL;
439 RESULT Result = FAIL;
450 RESULT Result = FAIL;
452 char PrgNameBuf[vmFILENAMESIZE];
454 snprintf(PrgNameBuf,vmFILENAMESIZE,
"%s/%s%s",vmSETTINGS_DIR,vmLASTRUN_FILE_NAME,vmEXT_CONFIG);
455 File = open(PrgNameBuf,O_CREAT | O_WRONLY | O_TRUNC,FILEPERMISSIONS);
456 if (File >= MIN_HANDLE)
458 write(File,MemoryInstance.
Cache,
sizeof(MemoryInstance.
Cache));
476 Size = Elements * (*(
DESCR*)pTmp).ElementSize +
sizeof(
DESCR);
480 (*(
DESCR*)pTmp).Elements = Elements;
484 printf(
" Resize P=%1u H=%1u T=%1u S=%8lu A=%8p\r\n",(
unsigned int)PrgId,(
unsigned int)TmpHandle,(
unsigned int)MemoryInstance.
pPoolList[PrgId][TmpHandle].
Type,(
unsigned long)MemoryInstance.
pPoolList[PrgId][TmpHandle].
Size,MemoryInstance.
pPoolList[PrgId][TmpHandle].
pPool);
489 pTmp = (*(
DESCR*)pTmp).pArray;
496 void FindName(
char *pSource,
char *pPath,
char *pName,
char *pExt)
501 while (pSource[Source])
505 while ((Source > 0) && (pSource[Source] !=
'/'))
509 if (pSource[Source] ==
'/')
513 for (Destination = 0;Destination <= Source;Destination++)
515 pPath[Destination] = pSource[Destination];
522 pPath[Destination] = 0;
525 while ((pSource[Source]) && (pSource[Source] !=
'.'))
529 pName[Destination] = pSource[Source];
536 pName[Destination] = 0;
541 while (pSource[Source])
543 pExt[Destination] = pSource[Source];
547 pExt[Destination] = 0;
554 RESULT Result = FAIL;
555 char Path[vmFILENAMESIZE];
556 char Name[vmFILENAMESIZE];
557 char Ext[vmFILENAMESIZE];
559 #ifndef DISABLE_FILENAME_CHECK
561 if (strlen(pFilename) < vmFILENAMESIZE)
566 if (strlen(Path) < vmPATHSIZE)
572 if (strlen(Name) < vmNAMESIZE)
578 if (strlen(Ext) < vmEXTSIZE)
591 if (strlen(pFilename) < vmFILENAMESIZE)
594 if (strlen(Path) < vmPATHSIZE)
600 if (strlen(Name) < vmNAMESIZE)
606 if (strlen(Ext) < vmEXTSIZE)
620 #ifdef DEBUG_TRACE_FILENAME
621 printf(
"Filename error in [%s]\r\n",pFilename);
635 RESULT Result = FAIL;
636 char Path[vmPATHSIZE];
637 char Name[vmNAMESIZE];
654 snprintf(Ext,vmEXTSIZE,
"%s",pDefaultExt);
658 snprintf(pName,vmFILENAMESIZE,
"%s%s%s",Path,Name,Ext);
660 #ifdef DEBUG_TRACE_FILENAME
661 printf(
"c_memory ConstructFilename: [%s]\r\n",pName);
675 while (pString[Pointer])
677 if (pString[Pointer] ==
'.')
693 printf(
"DEL_CACHE_FILE %s\r\n",(
char*)pFileName);
699 while ((Item < CACHE_DEEPT) && (Tmp == 0))
701 if (strcmp((
char*)MemoryInstance.
Cache[Item],(
char*)pFileName) == 0)
710 while (Item < (CACHE_DEEPT - 1))
712 strcpy((
char*)MemoryInstance.
Cache[Item],(
char*)MemoryInstance.
Cache[Item + 1]);
715 MemoryInstance.
Cache[Item][0] = 0;
726 pFirst = (
char*)(*(
const struct dirent **)ppFirst)->d_name;
727 pSecond = (
char*)(*(
const struct dirent **)ppSecond)->d_name;
732 if ((First >= 0) && (Second >= 0))
734 Result = strcmp(&pFirst[First],&pSecond[Second]);
737 Result = strcmp(pFirst,pSecond);
742 if ((First < 0) && (Second < 0))
744 Result = strcmp(pFirst,pSecond);
765 struct dirent **NameList;
770 Items = scandir(pFolderName,&NameList,0,(
int (*)(
const struct dirent **,
const struct dirent **))
cMemorySort);
772 Items = scandir(pFolderName,&NameList,0,(
int (*)(
const void *,
const void *))
cMemorySort);
778 if ((*NameList[Items]).d_name[0] !=
'.')
780 if (((*NameList[Items]).d_name[0] !=
'C') || ((*NameList[Items]).d_name[1] !=
'V') || ((*NameList[Items]).d_name[2] !=
'S'))
785 free(NameList[Items]);
808 Result = TYPE_GRAPHICS;
814 Result = TYPE_BYTECODE;
820 Result = TYPE_DATALOG;
826 Result = TYPE_PROGRAM;
845 Result = TYPE_FOLDER;
855 struct dirent **NameList;
861 pSubFolderName[0] = 0;
863 Items = scandir(pFolderName,&NameList,0,(
int (*)(
const struct dirent **,
const struct dirent **))
cMemorySort);
865 Items = scandir(pFolderName,&NameList,0,(
int (*)(
const void *,
const void *))
cMemorySort);
873 if ((*NameList[Tmp]).d_name[0] !=
'.')
875 if (((*NameList[Tmp]).d_name[0] !=
'C') || ((*NameList[Tmp]).d_name[1] !=
'V') || ((*NameList[Tmp]).d_name[2] !=
'S'))
881 while (((*NameList[Tmp]).d_name[Char]) && ((*NameList[Tmp]).d_name[Char] !=
'.'))
885 if ((*NameList[Tmp]).d_name[Char] ==
'.')
890 (*NameList[Tmp]).d_name[Char] = 0;
891 snprintf((
char*)pSubFolderName,(
int)MaxLength,
"%s",(*NameList[Tmp]).d_name);
895 snprintf((
char*)pSubFolderName,(
int)MaxLength,
"%s",(*NameList[Tmp]).d_name);
896 Filetype = TYPE_FOLDER;
918 if (strcmp(pFolderName,DEMO_FILE_NAME) == 0)
925 dir = opendir(pFolderName);
929 while((d = readdir(dir)))
932 printf(
"%s\r\n",d->d_name);
935 sprintf(buf,
"%s/%s", pFolderName, d->d_name);
953 struct dirent **NameList;
959 if (stat(pFolderName,&Status) == 0)
961 Size += (
DATA32)Status.st_size;
963 Items = scandir(pFolderName,&NameList,0,(
int (*)(
const struct dirent **,
const struct dirent **))
cMemorySort);
965 Items = scandir(pFolderName,&NameList,0,(
int (*)(
const void *,
const void *))
cMemorySort);
973 stat((*NameList[Items]).d_name,&Status);
974 Size += (
DATA32)Status.st_size;
975 free(NameList[Items]);
980 Size = (Size + (
KB - 1)) /
KB;
989 char Path[vmPATHSIZE];
990 char Name[vmNAMESIZE];
992 char Filename[vmFILENAMESIZE];
994 if ((Item > 0) && (Item <= CACHE_DEEPT))
996 if (MemoryInstance.
Cache[Item - 1])
998 snprintf(Filename,vmFILENAMESIZE,
"%s",MemoryInstance.
Cache[Item - 1]);
1002 snprintf((
char*)pFileName,MaxLength,
"%s",Filename);
1005 if (strlen(Name) >= MaxLength)
1007 Name[MaxLength - 1] = 0;
1008 Name[MaxLength - 2] = 0x7F;
1010 snprintf((
char*)pName,MaxLength,
"%s",Name);
1026 for (Tmp = 0;Tmp < CACHE_DEEPT;Tmp++)
1028 if (MemoryInstance.
Cache[Tmp][0])
1040 struct dirent **NameList;
1044 Items = scandir(pFolderName,&NameList,0,alphasort);
1049 if ((*NameList[Items]).d_name[0] !=
'.')
1051 if (((*NameList[Items]).d_name[0] !=
'C') || ((*NameList[Items]).d_name[1] !=
'V') || ((*NameList[Items]).d_name[2] !=
'S'))
1056 free(NameList[Items]);
1073 RESULT Result = FAIL;
1079 char PrgNamePath[SUBFOLDERNAME_SIZE];
1080 char PrgNameBuf[MAX_FILENAME_SIZE];
1089 snprintf(PrgNameBuf,MAX_FILENAME_SIZE,
"%s%s/icon%s",(
char*)pFolderName,PrgNamePath,
EXT_GRAPHICS);
1091 pFile = fopen (PrgNameBuf,
"rb");
1094 fseek (pFile , 0 , SEEK_END);
1095 ISize = ftell (pFile);
1101 if (ISize == fread(pImage,1,ISize,pFile))
1103 *pImagePointer = (
DATA32)pImage;
1117 if ((pName[0] ==
'.') || (pName[0] ==
'/') || (pName[0] ==
'~') || (pName[0] ==
'\"'))
1120 snprintf(pResult,Length,
"%s%s",pName,pExt);
1125 snprintf(pResult,Length,
"%s%s%s",(
char*)MemoryInstance.
PathList[PrgId],pName,pExt);
1128 printf(
"Filename = [%s]\r\n",pResult);
1133 static char Delimiter[][3] =
1138 [DEL_RETURN] =
"\r",
1141 [DEL_LINEFEED] =
"\n",
1142 [DEL_CRLF] =
"\r\n",
1165 while ((TmpHandle < MAX_HANDLES) && (*pHandle == -1))
1171 if ((*pFDescr).Access)
1173 if (strcmp(pFileName,(*pFDescr).Filename) == 0)
1175 *pHandle = TmpHandle;
1190 #ifdef DEBUG_C_MEMORY_FILE
1191 printf(
"Handle for file %5d %s\r\n",*pHandle,pFileName);
1201 RESULT Result = FAIL;
1204 char FilenameBuf[vmFILENAMESIZE];
1223 struct stat FileStatus;
1233 hFile = open(pFileName,O_CREAT | O_WRONLY | O_TRUNC,FILEPERMISSIONS);
1234 chmod(pFileName,FILEPERMISSIONS);
1235 #ifdef DEBUG_C_MEMORY_FILE
1236 printf(
"Open for write %5d %s\r\n",hFile,pFileName);
1243 hFile = open(pFileName,O_CREAT | O_WRONLY | O_APPEND,FILEPERMISSIONS);
1244 chmod(pFileName,FILEPERMISSIONS);
1245 #ifdef DEBUG_C_MEMORY_FILE
1246 printf(
"Open for append %5d %s\r\n",hFile,pFileName);
1253 hFile = open(pFileName,O_RDONLY);
1255 #ifdef DEBUG_C_MEMORY_FILE
1256 printf(
"Open for read %5d %s\r\n",hFile,pFileName);
1263 hFile = open(pFileName,O_CREAT | O_WRONLY | O_APPEND,FILEPERMISSIONS);
1264 chmod(pFileName,FILEPERMISSIONS);
1265 #ifdef DEBUG_C_MEMORY_FILE
1266 printf(
"Open for append %5d %s\r\n",hFile,pFileName);
1273 if (hFile >= MIN_HANDLE)
1277 (*pFDescr).hFile = hFile;
1278 (*pFDescr).Access = Access;
1279 snprintf((*pFDescr).Filename,MAX_FILENAME_SIZE,
"%s",pFileName);
1281 stat(pFileName,&FileStatus);
1282 *pSize = FileStatus.st_size;
1310 if (write((*pFDescr).hFile,pSource,Size) == Size)
1312 #ifdef DEBUG_C_MEMORY_FILE
1313 printf(
"Write to %-2d %5d %s [%d]\r\n",Handle,(*pFDescr).hFile,(*pFDescr).Filename,Size);
1317 if (Del != DEL_NONE)
1319 Size = strlen(Delimiter[Del]);
1320 if (write((*pFDescr).hFile,Delimiter[Del],Size) == Size)
1353 if ((*pFDescr).hFile > MIN_HANDLE)
1357 #ifdef DEBUG_C_MEMORY_FILE
1358 printf(
"Read from %-2d %5d %s [%d]\r\n",Handle,(*pFDescr).hFile,(*pFDescr).Filename,Size);
1362 if (Size > MIN_ARRAY_ELEMENTS)
1369 while ((No == 1) && (Size > 0))
1371 No = (
DATA8)read((*pFDescr).hFile,&Tmp,1);
1375 if (Del != DEL_NONE)
1377 if (Del != DEL_CRLF)
1379 if (Tmp == Delimiter[Del][0])
1386 if ((Tmp == Delimiter[Del][1]) && (Last == Delimiter[Del][0]))
1397 *pDestination = Tmp;
1425 #ifdef DEBUG_C_MEMORY_FILE
1432 printf(
"Close file %-2d %5d %s\r\n",Handle,(*pFDescr).hFile,(*pFDescr).Filename);
1437 printf(
"Close pool %-2d\r\n",Handle);
1459 if ((PrgId >= 0) && (PrgId < MAX_PROGRAMS))
1461 for (TmpHandle = 0;TmpHandle < MAX_HANDLES;TmpHandle++)
1470 snprintf(pName,MAX_FILENAME_SIZE,
"%s",(*pFDescr).Filename);
1471 TmpHandle = MAX_HANDLES;
1482 RESULT Result = FAIL;
1485 char FilenameBuf[MAX_FILENAME_SIZE];
1491 File = open(FilenameBuf,O_RDONLY);
1492 if (File >= MIN_HANDLE)
1494 read(File,pBmp,(
size_t)Size);
1506 RESULT Result = FAIL;
1508 struct mntent *mountEntry;
1510 pFile = setmntent(
"/proc/mounts",
"r");
1512 while ((mountEntry = getmntent(pFile)) !=
NULL)
1517 if(!strcmp(mountEntry->mnt_dir,
"/media/card"))
1526 if(!strcmp(mountEntry->mnt_dir,
"/media/usb"))
1572 [TYPE_BYTECODE] = 1,
1574 [TYPE_GRAPHICS] = 3,
1582 {
"",
"BrkProg_SAVE",
"BrkDL_SAVE",
"SD_Card",
"USB_Stick",
"TEST" },
1583 {
"Port View",
"Motor Control",
"IR Control",
"Brick Program",
"Brick Datalog" },
1584 {
"Volume",
"Sleep",
"Bluetooth",
"WiFi",
"Brick Info",
"Test",
"Performance",
"Debug" }
1597 char TmpEntry[FILENAME_SIZE];
1599 Sort = (*pMemory).Sort;
1601 Priority = Favourites;
1603 if ((Type != DT_DIR) && (Type != DT_LNK))
1608 while ((pName[Pointer]) && (pName[Pointer] !=
'.'))
1617 Priority = FILETYPES;
1619 Favourites = FILETYPES;
1630 if (strcmp(pName,
pFavourites[Sort][Pointer]) == 0)
1640 if (strcmp(pName,
pFavourites[Sort][Pointer]) == 0)
1647 snprintf((
char*)(*pMemory).Entry[(*pMemory).Entries],FILENAME_SIZE,
"%s",pName);
1648 (*pMemory).Priority[(*pMemory).Entries] = Priority;
1649 ((*pMemory).Entries)++;
1650 if (Priority < Favourites)
1652 for (Sort1 = 0;Sort1 < ((*pMemory).Entries - 1);Sort1++)
1654 for (Sort2 = 0;Sort2 < ((*pMemory).Entries - 1);Sort2++)
1656 if ((*pMemory).Priority[Sort2 + 1] < (*pMemory).Priority[Sort2])
1658 TmpPriority = (*pMemory).Priority[Sort2];
1659 strcpy(TmpEntry,(
char*)(*pMemory).Entry[Sort2]);
1660 (*pMemory).Priority[Sort2] = (*pMemory).Priority[Sort2 + 1];
1661 strcpy((
char*)(*pMemory).Entry[Sort2],(
char*)(*pMemory).Entry[Sort2 + 1]);
1662 (*pMemory).Priority[Sort2 + 1] = TmpPriority;
1663 strcpy((
char*)(*pMemory).Entry[Sort2 + 1],(
char*)TmpEntry);
1675 for (Pointer = 0;Pointer < (*pMemory).Entries;Pointer++)
1678 printf(
"[%s](%d)(%d) %s\r\n",(
char*)(*pMemory).Folder,(*pMemory).Sort,(*pMemory).Priority[Pointer],(
char*)(*pMemory).Entry[Pointer]);
1698 (*pMemory).pDir =
NULL;
1699 (*pMemory).Entries = 0;
1700 (*pMemory).Type = Type;
1701 snprintf((
char*)(*pMemory).Folder,MAX_FILENAME_SIZE,
"%s",(
char*)pFolderName);
1702 (*pMemory).pDir = opendir((
char*)(*pMemory).Folder);
1703 if ((*pMemory).pDir ==
NULL)
1709 if (strcmp((
char*)pFolderName,vmPRJS_DIR) == 0)
1715 if (strcmp((
char*)pFolderName,vmAPPS_DIR) == 0)
1721 if (strcmp((
char*)pFolderName,vmTOOLS_DIR) == 0)
1746 char Ext[vmEXTSIZE];
1747 struct dirent *pEntry;
1754 if ((*pMemory).pDir !=
NULL)
1756 pEntry = readdir((*pMemory).pDir);
1760 if ((*pMemory).Entries < DIR_DEEPT)
1762 if ((*pEntry).d_name[0] !=
'.')
1764 if (strcmp((*pEntry).d_name,
"CVS") != 0)
1766 if ((*pMemory).Type == TYPE_FOLDER)
1768 if (((*pEntry).d_type == DT_DIR) || ((*pEntry).d_type == DT_LNK))
1773 printf(
"[%s](%d) %s\r\n",(
char*)(*pMemory).Folder,(*pMemory).Sort,(*pEntry).d_name);
1779 if ((*pEntry).d_type == DT_REG)
1787 printf(
"[%s](%d) %s\r\n",(
char*)(*pMemory).Folder,(*pMemory).Sort,(*pEntry).d_name);
1801 closedir((*pMemory).pDir);
1802 (*pMemory).pDir =
NULL;
1806 *pItems = ((*pMemory).Entries);
1817 RESULT Result = FAIL;
1819 char Name[vmNAMESIZE];
1820 char Ext[vmEXTSIZE];
1829 if ((Item > 0) && (Item <= (*pMemory).Entries))
1837 if (strlen(Name) >= Length)
1839 Name[Length - 1] = 0;
1840 Name[Length - 2] = 0x7F;
1843 snprintf((
char*)pName,(
int)Length,
"%s",Name);
1844 *pPriority = (*pMemory).Priority[Item - 1];
1871 RESULT Result = FAIL;
1873 char Filename[MAX_FILENAME_SIZE];
1876 struct stat FileStatus;
1885 if ((Item > 0) && (Item <= (*pMemory).Entries))
1888 snprintf(Filename,MAX_FILENAME_SIZE,
"%s/%s/%s%s",(
char*)(*pMemory).Folder,(
char*)(*pMemory).Entry[Item - 1],ICON_FILE_NAME,
EXT_GRAPHICS);
1890 hFile = open(Filename,O_RDONLY);
1892 if (hFile >= MIN_HANDLE)
1895 stat(Filename,&FileStatus);
1896 ISize = FileStatus.st_size;
1902 if ((
DATA32)read(hFile,pImage,ISize) == ISize)
1904 *pImagePointer = (
DATA32)pImage;
1923 RESULT Result = FAIL;
1925 char Filename[MAX_FILENAME_SIZE];
1928 char Termination[2] =
"\t";
1931 for (Tmp = 0;Tmp < Length;Tmp++)
1940 if ((Item > 0) && (Item <= (*pMemory).Entries) && Length)
1944 snprintf(Filename,MAX_FILENAME_SIZE,
"%s/%s%s",vmSETTINGS_DIR,(
char*)(*pMemory).Entry[Item - 1],
EXT_TEXT);
1945 hFile = open(Filename,O_RDONLY);
1946 if (hFile >= MIN_HANDLE)
1950 while ((No == 1) && (Length > 1))
1952 No = read(hFile,&Tmp,1);
1953 if ((Tmp == Termination[0]) || (Tmp ==
'\r') || (Tmp ==
'\n'))
1984 RESULT Result = FAIL;
1986 char Filename[MAX_FILENAME_SIZE];
1990 Length = (
DATA8)strlen((
char*)pText);
1996 if ((Item > 0) && (Item <= (*pMemory).Entries) && Length)
1999 snprintf(Filename,MAX_FILENAME_SIZE,
"%s/%s/%s%s",(
char*)(*pMemory).Folder,(
char*)(*pMemory).Entry[Item - 1],TEXT_FILE_NAME,
EXT_TEXT);
2001 pFile = fopen (Filename,
"wb");
2004 fwrite(pText,1,Length,pFile);
2025 RESULT Result = FAIL;
2027 char Folder[vmPATHSIZE];
2028 char Name[vmNAMESIZE];
2029 char Ext[vmEXTSIZE];
2037 if ((Item > 0) && (Item <= (*pMemory).Entries))
2043 snprintf((
char*)pName,(
int)Length,
"%s%s/%s",(
char*)(*pMemory).Folder,Folder,Name);
2074 if ((*pMemory).pDir !=
NULL)
2076 closedir((*pMemory).pDir);
2317 char FilenameBuf[vmFILENAMESIZE];
2318 char PathBuf[vmPATHSIZE];
2319 char NameBuf[vmNAMESIZE];
2320 char ExtBuf[vmEXTSIZE];
2322 char SourceBuf[vmFILENAMESIZE];
2323 char DestinationBuf[vmFILENAMESIZE];
2326 DATA8 *pDestination;
2328 char PrgNamePath[SUBFOLDERNAME_SIZE];
2329 char PrgNameBuf[MAX_FILENAME_SIZE];
2330 char DestinationName[MAX_FILENAME_SIZE];
2339 char Buffer[LOGBUFFER_SIZE];
2344 struct stat FileStatus;
2381 #ifdef DEBUG_TRACE_FILENAME
2382 printf(
"c_memory cMemoryFile: OPEN_APPEND [%s]\r\n",FilenameBuf);
2398 #ifdef DEBUG_TRACE_FILENAME
2399 printf(
"c_memory cMemoryFile: OPEN_READ [%s]\r\n",FilenameBuf);
2416 #ifdef DEBUG_TRACE_FILENAME
2417 printf(
"c_memory cMemoryFile: OPEN_WRITE [%s]\r\n",FilenameBuf);
2464 snprintf(Buffer,LOGBUFFER_SIZE,
"%*.*f",Figures,Decimals,DataF);
2476 pDestination = (
DATA8*)Buffer;
2479 sscanf(Buffer,
"%f",&DataF);
2519 if (
ConstructFilename(TmpPrgId,(
char*)pFileName,FilenameBuf,vmEXT_DATALOG) == OK)
2522 #ifdef DEBUG_TRACE_FILENAME
2523 printf(
"c_memory cMemoryFile: OPEN_LOG [%s]\r\n",FilenameBuf);
2525 Bytes =
snprintf(Buffer,LOGBUFFER_SIZE,
"Sync data\t%d\t%d\t%d\t%d\t%d\r\n%s",STime,STick,NTick,SIIM,DIM,pSData);
2529 if ((SIIM < MIN_LIVE_UPDATE_TIME) || (FilenameBuf[0] == 0))
2538 Elements = LOGBUFFER_SIZE;
2540 ElementSize =
sizeof(
DATA8);
2541 ISize = Elements * ElementSize +
sizeof(
DESCR);
2545 (*(
DESCR*)pTmp).Type = DATA_8;
2546 (*(
DESCR*)pTmp).ElementSize = (
DATA8)ElementSize;
2547 (*(
DESCR*)pTmp).Elements = Elements;
2548 (*(
DESCR*)pTmp).UsedElements = 0;
2550 #ifdef DEBUG_C_MEMORY_LOG
2553 printf(
"LOG_OPEN %d into ram file %s\r\n",TmpHandle,FilenameBuf);
2554 printf(
" header %d into ram file %d bytes\r\n",TmpHandle,Bytes);
2558 printf(
"LOG_OPEN %d into ram\r\n",TmpHandle);
2559 printf(
" header %d into ram %d bytes\r\n",TmpHandle,Bytes);
2562 pDescr = (
DESCR*)pTmp;
2565 UsedElements = (*pDescr).UsedElements;
2570 pDestination[UsedElements] = Buffer[Elements];
2575 (*pDescr).UsedElements = UsedElements;
2590 #ifdef DEBUG_C_MEMORY_LOG
2591 printf(
"LOG_OPEN %d into file %s\r\n",TmpHandle,(
char*)pFileName);
2592 printf(
" header %d file %d bytes\r\n",TmpHandle,Bytes);
2614 DataF = (
DATAF)Time;
2617 memcpy((
void*)&Buffer[Bytes],(
void*)&DataF,
sizeof(
DATAF));
2618 Bytes +=
sizeof(
DATAF);
2620 for (Item = 0;Item < Items;Item++)
2622 memcpy((
void*)&Buffer[Bytes],(
void*)&pValue[Item],
sizeof(
DATAF));
2623 Bytes +=
sizeof(
DATAF);
2628 for (Item = 0;Item < Items;Item++)
2631 if (Item != (Items - 1))
2633 Bytes +=
snprintf(&Buffer[Bytes],LOGBUFFER_SIZE - Bytes,
"%.1f\t",pValue[Item]);
2637 Bytes +=
snprintf(&Buffer[Bytes],LOGBUFFER_SIZE - Bytes,
"%.1f\r\n",pValue[Item]);
2647 pDescr = (
DESCR*)pTmp;
2650 Elements = (*pDescr).Elements;
2652 if (UsedElements > Elements)
2654 Elements += LOGBUFFER_SIZE;
2655 #ifdef DEBUG_C_MEMORY_LOG
2656 printf(
"LOG_WRITE %d resizing ram to %d\r\n",TmpHandle,Elements);
2659 #ifdef DEBUG_C_MEMORY_LOG
2660 printf(
"Free memory %u KB\r\n",FreeRam);
2662 if (FreeRam > RESERVED_MEMORY)
2679 pDescr = (
DESCR*)pTmp;
2682 UsedElements = (*pDescr).UsedElements;
2684 #ifdef DEBUG_C_MEMORY_LOG
2685 printf(
"LOG_WRITE %d ram %d bytes\r\n",TmpHandle,Bytes);
2687 memcpy((
void*)&pDestination[UsedElements],Buffer,(
size_t)Bytes);
2688 (*pDescr).UsedElements = UsedElements + (
DATA32)Bytes;
2704 #ifdef DEBUG_C_MEMORY_LOG
2705 printf(
"LOG_WRITE %d file %d bytes\r\n",TmpHandle,Bytes);
2719 if (
ConstructFilename(TmpPrgId,(
char*)pFileName,FilenameBuf,vmEXT_DATALOG) == OK)
2722 #ifdef DEBUG_TRACE_FILENAME
2723 printf(
"c_memory cMemoryFile: CLOSE_LOG [%s]\r\n",FilenameBuf);
2733 pDescr = (
DESCR*)pTmp;
2738 UsedElements = (*pDescr).UsedElements;
2767 #ifdef DEBUG_C_MEMORY_LOG
2768 printf(
"LOG_WRITE %d ram %d log end signature\r\n",TmpHandle,Bytes);
2770 memcpy((
void*)&pSource[UsedElements],Buffer,(
size_t)Bytes);
2771 UsedElements += (
DATA32)Bytes;
2774 if (UsedElements > ((FreeRam - RESERVED_MEMORY) *
KB))
2776 UsedElements = (FreeRam - RESERVED_MEMORY) * KB;
2779 #ifdef DEBUG_C_MEMORY_LOG
2780 printf(
"LOG_CLOSE %d ram and save %d bytes to %s\r\n",TmpHandle,UsedElements,(
char*)pFileName);
2826 #ifdef DEBUG_C_MEMORY_LOG
2827 printf(
"LOG_WRITE %d file %d 0xFF\r\n",TmpHandle,Bytes);
2833 #ifdef DEBUG_C_MEMORY_LOG
2834 printf(
"LOG_CLOSE %d file\r\n",TmpHandle);
2852 Data32 = (
DATA32)strlen(DestinationName);
2854 if (Data32 > MIN_ARRAY_ELEMENTS)
2858 Lng = (
DATA8)Data32;
2860 if (pFileName !=
NULL)
2862 snprintf((
char*)pFileName,(
int)Lng,
"%s",DestinationName);
2878 #ifdef DEBUG_TRACE_FILENAME
2879 printf(
"c_memory cMemoryFile: GET_HANDLE [%s]\r\n",FilenameBuf);
2895 #ifdef DEBUG_TRACE_FILENAME
2896 printf(
"c_memory cMemoryFile: REMOVE [%s]\r\n",FilenameBuf);
2908 snprintf(PathBuf,vmPATHSIZE,
"%s",pDestination);
2910 Data32 = (
DATA32)strlen(PathBuf);
2913 if (PathBuf[Data32 - 1] ==
'/')
2915 PathBuf[Data32 - 1] = 0;
2920 if (stat((
char*)PathBuf,&FileStatus) == 0)
2923 #ifdef DEBUG_TRACE_FILENAME
2924 printf(
"c_memory cMemoryFile: MAKE_FOLDER [%s] already present\r\n",PathBuf);
2929 mkdir((
char*)PathBuf,DIRPERMISSIONS);
2930 chmod((
char*)PathBuf,DIRPERMISSIONS);
2933 #ifdef DEBUG_TRACE_FILENAME
2934 printf(
"c_memory cMemoryFile: MAKE_FOLDER [%s]\r\n",PathBuf);
2937 if (stat((
char*)PathBuf,&FileStatus) == 0)
2958 snprintf(Buffer,LOGBUFFER_SIZE,
"cp -r \"%s\" \"%s\"",SourceBuf,DestinationBuf);
2959 #ifdef DEBUG_TRACE_FILENAME
2960 printf(
"c_memory cMemoryFile: MOVE [%s]\r\n",Buffer);
2963 if (stat(DestinationBuf,&FileStatus) == 0)
2967 #ifdef DEBUG_TRACE_FILENAME
2968 printf(
" c_memory cMemoryFile: remove [%s]\r\n",DestinationBuf);
2996 if (PathBuf[0] == 0)
2999 snprintf(PathBuf,vmPATHSIZE,
"%s/",DEFAULT_FOLDER);
3015 snprintf(FilenameBuf,vmFILENAMESIZE,
"%s%s%s",PathBuf,NameBuf,ExtBuf);
3017 #ifdef DEBUG_TRACE_FILENAME
3018 printf(
"c_memory cMemoryFile: LOAD_IMAGE [%s]\r\n",FilenameBuf);
3020 hFile = open(FilenameBuf,O_RDONLY);
3022 if (hFile >= MIN_HANDLE)
3024 stat(FilenameBuf,&FileStatus);
3025 ISize = FileStatus.st_size;
3030 if (ISize == read(hFile,pImage,ISize))
3032 ImagePointer = (
DATA32)pImage;
3065 ImagePointer = (
DATA32)pImage;
3083 case GET_SUBFOLDER_NAME :
3096 case DEL_SUBFOLDER :
3102 snprintf(PrgNameBuf,MAX_FILENAME_SIZE,
"%s%s",(
char*)pFolderName,PrgNamePath);
3104 printf(
"Trying to delete %s\r\n",PrgNameBuf);
3112 case SET_LOG_SYNC_TIME :
3121 case GET_LOG_SYNC_TIME :
3140 while ((Items > 0) && (Item == 0))
3145 printf(
"%s %s\r\n",(
char*)pFileName,PrgNamePath);
3147 if (strcmp((
char*)pFileName,PrgNamePath) == 0)
3151 printf(
"Found %i\r\n",Item);
3161 case GET_CACHE_FILES :
3164 for (Tmp = 0;Tmp < CACHE_DEEPT;Tmp++)
3166 if (MemoryInstance.
Cache[Tmp][0])
3173 printf(
"GET_CACHE_FILES %d\r\n",Items);
3179 case PUT_CACHE_FILE :
3184 printf(
"PUT_CACHE_FILE %s\r\n",(
char*)pFileName);
3193 while ((Item < CACHE_DEEPT) && (Tmp == 0))
3195 if (strcmp((
char*)MemoryInstance.
Cache[Item],(
char*)pFileName) == 0)
3204 while (Item < (CACHE_DEEPT - 1))
3206 strcpy((
char*)MemoryInstance.
Cache[Item],(
char*)MemoryInstance.
Cache[Item + 1]);
3209 MemoryInstance.
Cache[Item][0] = 0;
3211 for (Item = (CACHE_DEEPT - 1);Item > 0;Item--)
3213 strcpy((
char*)MemoryInstance.
Cache[Item],(
char*)MemoryInstance.
Cache[Item - 1]);
3215 strcpy((
char*)MemoryInstance.
Cache[Item],(
char*)pFileName);
3220 case DEL_CACHE_FILE :
3230 case GET_CACHE_FILE :
3237 if ((Item > 0) && (Item <= CACHE_DEEPT))
3239 if (MemoryInstance.
Cache[Item - 1])
3241 snprintf((
char*)pDestination,Lng,
"%s",MemoryInstance.
Cache[Item - 1]);
3433 if (Elements < MIN_ARRAY_ELEMENTS)
3435 Elements = MIN_ARRAY_ELEMENTS;
3438 ElementSize =
sizeof(
DATA8);
3439 ISize = Elements * ElementSize +
sizeof(
DESCR);
3443 (*(
DESCR*)pTmp).Type = DATA_8;
3444 (*(
DESCR*)pTmp).ElementSize = (
DATA8)ElementSize;
3445 (*(
DESCR*)pTmp).Elements = Elements;
3461 ElementSize =
sizeof(
DATA16);
3462 ISize = Elements * ElementSize +
sizeof(
DESCR);
3466 (*(
DESCR*)pTmp).Type = DATA_16;
3467 (*(
DESCR*)pTmp).ElementSize = (
DATA8)ElementSize;
3468 (*(
DESCR*)pTmp).Elements = Elements;
3484 ElementSize =
sizeof(
DATA32);
3485 ISize = Elements * ElementSize +
sizeof(
DESCR);
3489 (*(
DESCR*)pTmp).Type = DATA_32;
3490 (*(
DESCR*)pTmp).ElementSize = (
DATA8)ElementSize;
3491 (*(
DESCR*)pTmp).Elements = Elements;
3507 ElementSize =
sizeof(
DATAF);
3508 ISize = Elements * ElementSize +
sizeof(
DESCR);
3512 (*(
DESCR*)pTmp).Type = DATA_F;
3513 (*(
DESCR*)pTmp).ElementSize = (
DATA8)ElementSize;
3514 (*(
DESCR*)pTmp).Elements = Elements;
3535 Elements = (*(
DESCR*)pTmp).Elements;
3574 pArray = (*(
DESCR*)pTmp).pArray;
3575 Elements = (*(
DESCR*)pTmp).Elements;
3577 switch ((*(
DESCR*)pTmp).Type)
3582 pData8 = (
DATA8*)pArray;
3584 while (Index < Elements)
3586 pData8[Index] = Data8;
3596 pData16 = (
DATA16*)pArray;
3598 while (Index < Elements)
3600 pData16[Index] = Data16;
3610 pData32 = (
DATA32*)pArray;
3612 while (Index < Elements)
3614 pData32[Index] = Data32;
3624 pDataF = (
DATAF*)pArray;
3626 while (Index < Elements)
3628 pDataF[Index] =
DataF;
3650 if ((*(
DESCR*)pSource).Type == (*(
DESCR*)pDest).Type)
3652 Elements = (*(
DESCR*)pSource).Elements;
3663 ISize = Elements * (*(
DESCR*)pSource).ElementSize;
3664 memcpy((*(
DESCR*)pDest).pArray,(*(
DESCR*)pSource).pArray,ISize);
3687 if ((Index >= 0) && ((Index + Elements) <= (*(
DESCR*)pTmp).Elements))
3689 pArray = (*(
DESCR*)pTmp).pArray;
3690 pData8 = (
DATA8*)pArray;
3714 if ((Index >= 0) && ((Index + Elements) <= (*(
DESCR*)pTmp).Elements))
3716 pArray = (*(
DESCR*)pTmp).pArray;
3717 pData16 = (
DATA16*)pArray;
3741 if ((Index >= 0) && ((Index + Elements) <= (*(
DESCR*)pTmp).Elements))
3743 pArray = (*(
DESCR*)pTmp).pArray;
3744 pData32 = (
DATA32*)pArray;
3768 if ((Index >= 0) && ((Index + Elements) <= (*(
DESCR*)pTmp).Elements))
3770 pArray = (*(
DESCR*)pTmp).pArray;
3771 pDataF = (
DATAF*)pArray;
3795 if (PrgId == (
PRGID)CURRENT_SLOT)
3809 if ((Index >= 0) && (pDData8 !=
NULL))
3811 pArray = (*(
DESCR*)pTmp).pArray;
3813 pData8 = (
DATA8*)pArray;
3816 while ((Data32 < Bytes) && (Index < ISize))
3818 pDData8[Data32] = pData8[Index];
3822 while (Data32 < Bytes)
3824 pDData8[Data32] = 0;
3833 case WRITE_CONTENT :
3844 printf(
"ARRAY WRITE_CONTENT CP=%d PP=%d\r\n",TmpPrgId,PrgId);
3847 if (PrgId == (
PRGID)CURRENT_SLOT)
3854 ElementSize = (
DATA32)(*(
DESCR*)pTmp).ElementSize;
3857 Elements = (Index + Bytes + (ElementSize - 1)) / ElementSize;
3858 ISize = Elements * ElementSize;
3863 if ((Index >= 0) && (pDData8 !=
NULL))
3865 pData8 = (
DATA8*)pTmp;
3868 while ((Data32 < Bytes) && (Index < ISize))
3870 pData8[Index] = pDData8[Data32];
3890 if (PrgId == (
PRGID)CURRENT_SLOT)
3958 pDescr = (
DESCR*)pTmp;
3961 Elements = Index + 1;
3964 if (Elements > (*pDescr).Elements)
3975 pDescr = (
DESCR*)pTmp;
3976 pArray = (*pDescr).
pArray;
3978 printf(
" Write P=%1u H=%1u I=%8lu A=%8p\r\n",(
unsigned int)TmpPrgId,(
unsigned int)TmpHandle,(
unsigned long)Index,pArray);
3980 switch ((*pDescr).Type)
3984 pData8 = (
DATA8*)pArray;
3985 pData8[Index] = *(
DATA8*)pValue;
3992 pData16 = (
DATA16*)pArray;
3993 pData16[Index] = *(
DATA16*)pValue;
4000 pData32 = (
DATA32*)pArray;
4001 pData32[Index] = *(
DATA32*)pValue;
4008 pDataF = (
DATAF*)pArray;
4009 pDataF[Index] = *(
DATAF*)pValue;
4022 printf(
" WR ERR P=%1u H=%1u I=%8lu\r\n",(
unsigned int)TmpPrgId,(
unsigned int)TmpHandle,(
unsigned long)Index);
4066 if ((Index >= 0) && (Index < (*(
DESCR*)pTmp).Elements))
4068 pArray = (*(
DESCR*)pTmp).pArray;
4070 printf(
" Read P=%1u H=%1u I=%8lu A=%8p\r\n",(
unsigned int)TmpPrgId,(
unsigned int)TmpHandle,(
unsigned long)Index,pArray);
4072 switch ((*(
DESCR*)pTmp).Type)
4076 pData8 = (
DATA8*)pArray;
4084 pData16 = (
DATA16*)pArray;
4092 pData32 = (
DATA32*)pArray;
4100 pDataF = (
DATAF*)pArray;
4156 pDescr = (
DESCR*)pTmp;
4158 Elements = Index + 1;
4161 if (Elements > (*pDescr).Elements)
4172 pDescr = (
DESCR*)pTmp;
4173 pArray = (*pDescr).
pArray;
4175 printf(
" Append P=%1u H=%1u I=%8lu A=%8p",(
unsigned int)TmpPrgId,(
unsigned int)TmpHandle,(
unsigned long)Index,pArray);
4177 switch ((*pDescr).Type)
4182 printf(
" V=%d",(
int)*(
DATA8*)pValue);
4184 pData8 = (
DATA8*)pArray;
4185 pData8[Index] = *(
DATA8*)pValue;
4193 printf(
" V=%d",(
int)*(
DATA16*)pValue);
4195 pData16 = (
DATA16*)pArray;
4196 pData16[Index] = *(
DATA16*)pValue;
4204 printf(
" V=%d",(
int)*(
DATA32*)pValue);
4206 pData32 = (
DATA32*)pArray;
4207 pData32[Index] = *(
DATA32*)pValue;
4215 printf(
" V=%f",*(
DATAF*)pValue);
4217 pDataF = (
DATAF*)pArray;
4218 pDataF[Index] = *(
DATAF*)pValue;
4233 printf(
" WR ERR P=%1u H=%1u I=%8lu\r\n",(
unsigned int)TmpPrgId,(
unsigned int)TmpHandle,(
unsigned long)Index);
4352 struct stat FileStatus;
4353 char Filename[MAX_FILENAME_SIZE];
4354 char Folder[MAX_FILENAME_SIZE];
4355 char Name[MAX_FILENAME_SIZE];
4356 char Ext[MAX_FILENAME_SIZE];
4357 char Buffer[2 * MAX_FILENAME_SIZE + 32];
4380 cMemoryFilename(TmpPrgId,(
char*)pFilename,
"",MAX_FILENAME_SIZE,Filename);
4383 if (stat(Filename,&FileStatus) == 0)
4387 #ifdef DEBUG_TRACE_FILENAME
4388 printf(
"c_memory cMemoryFileName: EXIST [%s] = %d\r\n",Filename,Tmp);
4397 cMemoryFilename(TmpPrgId,(
char*)pFilename,
"",MAX_FILENAME_SIZE,Filename);
4419 FindName((
char*)pFilename,Folder,Name,Ext);
4425 Lng = strlen(Folder) + 1;
4426 if (Lng > MIN_ARRAY_ELEMENTS)
4430 Length = (
DATA8)Lng;
4432 snprintf((
char*)pFolder,(
int)Length,
"%s",Folder);
4438 Lng = strlen(Name) + 1;
4439 if (Lng > MIN_ARRAY_ELEMENTS)
4443 Length = (
DATA8)Lng;
4445 snprintf((
char*)pName,(
int)Length,
"%s",Name);
4451 Lng = strlen(Ext) + 1;
4452 if (Lng > MIN_ARRAY_ELEMENTS)
4456 Length = (
DATA8)Lng;
4458 snprintf((
char*)pExt,(
int)Length,
"%s",Ext);
4473 snprintf(Filename,MAX_FILENAME_SIZE,
"%s/%s%s",pFolder,pName,pExt);
4478 Lng = strlen(Filename) + 1;
4479 if (Lng > MIN_ARRAY_ELEMENTS)
4483 Length = (
DATA8)Lng;
4485 snprintf((
char*)pFilename,(
int)Length,
"%s",Filename);
4507 FindName((
char*)pName,Folder,Name,Ext);
4509 snprintf(Buffer,2 * MAX_FILENAME_SIZE + 32,
"tar -cz -f %s%s%s -C %s %s%s &> /dev/null",Folder,Name,vmEXT_ARCHIVE,Folder,Name,Ext);
4520 FindName((
char*)pName,Folder,Name,Ext);
4522 snprintf(Buffer,2 * MAX_FILENAME_SIZE + 32,
"tar -xz -f %s%s%s -C %s &> /dev/null",Folder,Name,vmEXT_ARCHIVE,Folder);
4528 case GET_FOLDERNAME :
4535 Lng = strlen(Filename);
4540 if (Filename[Lng - 1] ==
'/')
4551 if (Lng > MIN_ARRAY_ELEMENTS)
4555 Length = (
DATA8)Lng;
4557 if (pFilename !=
NULL)
4559 snprintf((
char*)pFilename,(
int)Length,
"%s",Filename);
DATA8 PathList[MAX_PROGRAMS][vmPATHSIZE]
DATA8 LogErrorNumberExists(ERR Error)
DATA8 cMemoryFindFiles(char *pFolderName)
void SetDispatchStatus(DSPSTAT DspStat)
Set object (dispatch) status.
void PrimParAdvance(void)
Skip next encoded parameter from byte code stream.
DSPSTAT cMemoryGetFileHandle(PRGID PrgId, char *pFileName, HANDLER *pHandle, DATA8 *pOpenForWrite)
RESULT cMemoryAlloc(PRGID PrgId, DATA8 Type, GBINDEX Size, void **pMemory, HANDLER *pHandle)
RESULT cMemoryGetImage(DATA8 *pFileName, DATA16 Size, UBYTE *pBmp)
void cMemoryFile(void)
opFILE byte code
DATA8 NoOfFavourites[SORT_TYPES]
RESULT cMemoryGetIcon(DATA8 *pFolderName, DATA8 Item, DATA32 *pImagePointer)
SWORD DATA16
VM Type for 2 byte signed value.
void LogErrorNumber(ERR Err)
DSPSTAT cMemoryWriteFile(PRGID PrgId, HANDLER Handle, DATA32 Size, DATA8 Del, DATA8 *pSource)
void cMemoryArrayWrite(void)
opARRAY_WRITE byte code
DATA32 cMemoryFindSize(char *pFolderName, DATA32 *pFiles)
SLONG DATA32
VM Type for 4 byte signed value.
RESULT cMemoryGetMediaName(char *pChar, char *pName)
DATA8 Name[FILENAME_SIZE]
RESULT cMemoryArraryPointer(PRGID PrgId, HANDLER Handle, void **pMemory)
void cMemoryCloseFolder(PRGID PrgId, HANDLER *pHandle)
RESULT ConstructFilename(PRGID PrgId, char *pFilename, char *pName, char *pDefaultExt)
void SetObjectIp(IP Ip)
Set current instruction pointer.
#define EXT_PROGRAM
Rudolf program byte code file.
DATA8 cMemoryFindType(char *pExt)
DATA8 Cache[CACHE_DEEPT+1][vmFILENAMESIZE]
char * pFavourites[SORT_TYPES][8]
void FindName(char *pSource, char *pPath, char *pName, char *pExt)
void cMemoryFileName(void)
opFILENAME byte code
DATA16 HANDLER
Memory list index.
void * PrimParPointer(void)
Get next encoded parameter from byte code stream.
void cMemoryDeleteSubFolders(char *pFolderName)
#define EXT_BYTECODE
Rudolf byte code file.
IP GetObjectIp(void)
Get current instruction pointer.
DATA8 cMemoryGetCacheName(DATA8 Item, DATA8 MaxLength, char *pFileName, char *pName)
void cMemoryArray(void)
opARRAY byte code
void cMemoryUsage(void)
opMEMORY_USAGE byte code
RESULT cMemoryCheckFilename(char *pFilename, char *pPath, char *pName, char *pExt)
void cMemorySortList(FOLDER *pMemory)
RESULT cMemoryMalloc(void **ppMemory, DATA32 Size)
DSPSTAT cMemoryFreeHandle(PRGID PrgId, HANDLER Handle)
void setMemoryInstance(MEMORY_GLOBALS *_Instance)
POOL pPoolList[MAX_PROGRAMS][MAX_HANDLES]
#define UPDATE_MEMORY
Update memory size [mS].
OBJSTAT ProgramStatus(PRGID PrgId)
Get program status.
IMGDATA * IP
Instruction pointer type.
RESULT cMemoryRealloc(void *pOldMemory, void **ppMemory, DATA32 Size)
RESULT cMemoryOpen(PRGID PrgId, GBINDEX Size, void **pMemory)
unsigned int ULONG
Basic Type used to symbolise 32 bit unsigned values.
RESULT cMemoryGetPointer(PRGID PrgId, HANDLER Handle, void **pMemory)
void cMemoryArrayRead(void)
opARRAY_READ byte code
ULONG GBINDEX
GlobalBytes index type.
DATA8 cMemoryGetSubFolderName(DATA8 Item, DATA8 MaxLength, char *pFolderName, char *pSubFolderName)
DSPSTAT cMemoryOpenFile(PRGID PrgId, DATA8 Access, char *pFileName, HANDLER *pHandle, DATA32 *pSize)
void cMemoryArrayAppend(void)
opARRAY_APPEND byte code
DSPSTAT cMemoryCloseFile(PRGID PrgId, HANDLER Handle)
void cMemoryFreeProgram(PRGID PrgId)
RESULT cMemoryClose(PRGID PrgId)
DATA8 cMemoryFindSubFolders(char *pFolderName)
RESULT cMemorySetItemText(PRGID PrgId, HANDLER Handle, DATA16 Item, DATA8 *pText)
void * cMemoryResize(PRGID PrgId, HANDLER TmpHandle, DATA32 Elements)
MEMORY_GLOBALS * gMemoryInstance
RESULT cMemoryCheckOpenWrite(char *pFileName)
RESULT cMemoryGetItemName(PRGID PrgId, HANDLER Handle, DATA16 Item, DATA8 Length, DATA8 *pName, DATA8 *pType, DATA8 *pPriority)
void cMemoryGetUsage(DATA32 *pTotal, DATA32 *pFree, DATA8 Force)
void cMemoryFindLogName(PRGID PrgId, char *pName)
RESULT cMemoryGetItemText(PRGID PrgId, HANDLER Handle, DATA16 Item, DATA8 Length, DATA8 *pText)
int FindDot(char *pString)
int cMemorySort(void *ppFirst, void *ppSecond)
RESULT ValidateString(DATA8 *pString, DATA8 Set)
void cMemoryFreePool(PRGID PrgId, void *pMemory)
unsigned char UBYTE
Basic Type used to symbolise 8 bit unsigned values.
PRG Program[MAX_PROGRAMS]
Program[0] is the UI byte codes running.
#define EXT_TEXT
Rudolf text file.
DATA8 cMemoryGetCacheFiles(void)
#define EXT_SOUND
Rudolf sound file.
RESULT cMemoryGetItemIcon(PRGID PrgId, HANDLER Handle, DATA16 Item, HANDLER *pHandle, DATA32 *pImagePointer)
FLOAT DATAF
VM Type for 4 byte floating point value.
#define EXT_DATALOG
Rudolf datalog file.
void * cMemoryReallocate(PRGID PrgId, HANDLER Handle, GBINDEX Size)
void cMemorySortEntry(FOLDER *pMemory, UBYTE Type, char *pName)
void cMemoryFreeAll(void)
PRGID CurrentProgramId(void)
Get current program id.
void cMemoryFilename(PRGID PrgId, char *pName, char *pExt, DATA8 Length, char *pResult)
RESULT cMemoryGetItem(PRGID PrgId, HANDLER Handle, DATA16 Item, DATA8 Length, DATA8 *pName, DATA8 *pType)
void * VmMemoryResize(HANDLER Handle, DATA32 Elements)
UWORD PRGID
Program id type.
RESULT cMemoryOpenFolder(PRGID PrgId, DATA8 Type, DATA8 *pFolderName, HANDLER *pHandle)
void cMemoryGetResourcePath(PRGID PrgId, char *pString, DATA8 MaxLength)
SBYTE DATA8
VM Type for 1 byte signed value.
DATA8 FavouriteExts[FILETYPES]
RESULT cMemoryGetFolderItems(PRGID PrgId, HANDLER Handle, DATA16 *pItems)
#define EXT_GRAPHICS
Rudolf graphics file.
MEMORY_GLOBALS * getMemoryInstance()
Object is stopped or not triggered yet.
void Error(void)
opOUTPUT_READY byte code
Break because of waiting for completion.
Dispatcher running (looping)
void cMemoryDeleteCacheFile(char *pFileName)
DSPSTAT cMemoryReadFile(PRGID PrgId, HANDLER Handle, DATA32 Size, DATA8 Del, DATA8 *pDestination)