Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

corec: remove more dead code #180

Merged
merged 39 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e24ef67
corec: remove unused urlpart
robUx4 Dec 29, 2024
e99aa96
corec: remove unused dataheap
robUx4 Dec 29, 2024
51cebd5
corec: remove unused strtab API's
robUx4 Dec 29, 2024
ca43de5
corec: remove some unused file API's
robUx4 Dec 29, 2024
ed1e6fa
corec: fix UNICODE logs
robUx4 Dec 29, 2024
5c20243
corec: don't include streams.h from files.h
robUx4 Dec 29, 2024
d7ad810
corec: don't include charconvert from parser
robUx4 Dec 29, 2024
63285ce
corec: make parser/buffer.h a private header
robUx4 Dec 29, 2024
d4a0adf
corec: don't include unused date.h from file.h
robUx4 Dec 29, 2024
2de8d20
corec: remove unused TUNIT_HOTKEY type
robUx4 Dec 29, 2024
8d2b510
corec: include corec parts as external pathes
robUx4 Dec 29, 2024
1e30257
corec: only include strtypes.h when needed
robUx4 Dec 29, 2024
3271f4e
corec: remove unused parser text functions
robUx4 Dec 29, 2024
95d032b
corec: move unused function from buffer.c in parser2.c
robUx4 Dec 29, 2024
a39b354
corec: remove unused nodelookup.c
robUx4 Dec 29, 2024
4958bdd
parser: remove unused flag
robUx4 Dec 29, 2024
0ca2646
corec: don't mention private functions in public parser.h
robUx4 Dec 29, 2024
3fab415
corec: remove parser struct
robUx4 Dec 29, 2024
5c6c7ad
corec: make "strtab.h" private
robUx4 Dec 29, 2024
0c9f358
corec: include less headers
robUx4 Dec 29, 2024
a899329
corec: don't share the memstream structure
robUx4 Dec 29, 2024
8f66ce5
corec: remove private/unused stream functions
robUx4 Dec 29, 2024
fde4413
corec: remove mentions of CoreLua
robUx4 Dec 29, 2024
9f7cedf
corec: don't include memheap.h when not needed
robUx4 Dec 29, 2024
07645d4
mkclean: use larger integer size to read the TimestampScale
robUx4 Dec 29, 2024
589ec99
fixup! corec: include less headers
robUx4 Dec 29, 2024
751215e
corec: remove unused string functions
robUx4 Dec 29, 2024
a1c95e0
fixup! corec: include less headers
robUx4 Dec 29, 2024
0308475
corec: remove unused GetIsDst()
robUx4 Dec 29, 2024
2fb7339
corec: remove dead code
robUx4 Dec 29, 2024
6227e7f
corec: remove unused type/string conversions
robUx4 Dec 29, 2024
13e0bd9
corec: remove some unused expression parser functions
robUx4 Dec 29, 2024
1050e12
corec: remove enum variables
robUx4 Dec 29, 2024
b5589c0
corec: include <corec/str/str.h> when necessary
robUx4 Dec 29, 2024
6fd3d5d
corec: include <corec/memheap.h> when necessary
robUx4 Dec 29, 2024
1393b9e
corec: only include necessary (array) header in node
robUx4 Dec 29, 2024
8956e50
corec: remove unused ScaleRound()
robUx4 Dec 29, 2024
3221f2d
corec: move EqFrac() where it's used
robUx4 Dec 29, 2024
9500199
corec: remove empty nodetools.h
robUx4 Dec 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion corec/corec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ set(corec_node_PUBLIC_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/node/node.h
${CMAKE_CURRENT_SOURCE_DIR}/node/nodebase.h
${CMAKE_CURRENT_SOURCE_DIR}/node/nodetree.h
${CMAKE_CURRENT_SOURCE_DIR}/node/nodetools.h
)
add_library("corec_node" ${corec_node_SOURCES} ${corec_node_PUBLIC_HEADERS} ${corec_base_PUBLIC_HEADERS})
target_include_directories("corec_node" PUBLIC ".")
Expand Down
1 change: 1 addition & 0 deletions corec/corec/array/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
****************************************************************************/

#include "array.h"
#include <corec/memheap.h>

typedef struct datahead
{
Expand Down
5 changes: 3 additions & 2 deletions corec/corec/array/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
#ifndef __ARRAY_H
#define __ARRAY_H

#include "corec/corec.h"
#include "corec/memheap.h"
#include <corec/corec.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -47,6 +46,8 @@ extern "C" {

#define Data_Var(type,name,len) struct { size_t n; type p[len]; } __##name; type* name = (__##name.n = sizeof(__##name.p),__##name.p)

typedef struct cc_memheap cc_memheap;

typedef struct array
{
// these are private members, use ARRAY macros to access them
Expand Down
11 changes: 0 additions & 11 deletions corec/corec/helpers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,13 @@ target_include_directories("corec_file" PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT

# Parser API
set(corec_parser_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/parser/buffer.c
${CMAKE_CURRENT_SOURCE_DIR}/parser/dataheap.c
${CMAKE_CURRENT_SOURCE_DIR}/parser/hotkey.c
${CMAKE_CURRENT_SOURCE_DIR}/parser/nodelookup.c
${CMAKE_CURRENT_SOURCE_DIR}/parser/parser2.c
${CMAKE_CURRENT_SOURCE_DIR}/parser/strtab.c
${CMAKE_CURRENT_SOURCE_DIR}/parser/strtypes.c
${CMAKE_CURRENT_SOURCE_DIR}/parser/urlpart.c
)
set(corec_parser_PUBLIC_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/parser/buffer.h
${CMAKE_CURRENT_SOURCE_DIR}/parser/dataheap.h
${CMAKE_CURRENT_SOURCE_DIR}/parser/hotkey.h
${CMAKE_CURRENT_SOURCE_DIR}/parser/nodelookup.h
${CMAKE_CURRENT_SOURCE_DIR}/parser/parser.h
${CMAKE_CURRENT_SOURCE_DIR}/parser/strtab.h
${CMAKE_CURRENT_SOURCE_DIR}/parser/strtypes.h
${CMAKE_CURRENT_SOURCE_DIR}/parser/urlpart.h
PARENT_SCOPE
)
add_library("corec_parser" ${corec_parser_SOURCES} ${corec_parser_PUBLIC_HEADERS})
Expand Down
2 changes: 1 addition & 1 deletion corec/corec/helpers/charconvert/charconvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#ifndef __CHARCONVERT_H
#define __CHARCONVERT_H

#include "corec/corec.h"
#include <corec/corec.h>

#ifdef __cplusplus
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion corec/corec/helpers/charconvert/charconvert_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
****************************************************************************/

#include "charconvert.h"
#include "corec/str/str.h"
#include <corec/str/str.h>

#if defined(TARGET_LINUX)

Expand Down
2 changes: 1 addition & 1 deletion corec/corec/helpers/charconvert/charconvert_osx.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
****************************************************************************/

#include "charconvert.h"
#include "corec/str/str.h"
#include <corec/str/str.h>

#if defined(TARGET_OSX)

Expand Down
2 changes: 1 addition & 1 deletion corec/corec/helpers/charconvert/charconvert_utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
****************************************************************************/

#include "charconvert.h"
#include "corec/str/str.h"
#include <corec/str/str.h>

static const uint16_t codepage_1250[128] = {
0x20ac,0x0081,0x201a,0x0083,0x201e,0x2026,0x2020,0x2021,0x0088,0x2030,0x0160,0x2039,0x015a,0x0164,0x017d,0x0179,
Expand Down
2 changes: 1 addition & 1 deletion corec/corec/helpers/charconvert/charconvert_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
****************************************************************************/

#include "charconvert.h"
#include "corec/str/str.h"
#include <corec/str/str.h>

#if defined(TARGET_WIN)

Expand Down
3 changes: 1 addition & 2 deletions corec/corec/helpers/date/date.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#ifndef __DATE_H
#define __DATE_H

#include "corec/corec.h"
#include <corec/corec.h>

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -65,7 +65,6 @@ typedef struct datepack_t
DATE_DLL datetime_t GetTimeDate(void); // UTC in s (reference is 1st January 2001 00:00:00.000 UTC, use a helper to get the localized string value)
DATE_DLL datetime_t TimePackToRel(const datepack_t *tp, bool_t FromLocal);
DATE_DLL bool_t GetDatePacked(datetime_t t, datepack_t *tp, bool_t ToLocal);
DATE_DLL bool_t GetIsDst(datetime_t t); // may not be correct on all platforms

#ifdef __cplusplus
}
Expand Down
14 changes: 0 additions & 14 deletions corec/corec/helpers/date/date_libc.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,3 @@ bool_t GetDatePacked(datetime_t t, datepack_t *tp, bool_t Local)

return 0;
}

bool_t GetIsDst(datetime_t t)
{
time_t ot;
struct tm *date;

if (t == INVALID_DATETIME_T)
return 0;

ot = t + DATETIME_OFFSET;
date = localtime(&ot);

return date->tm_isdst;
}
2 changes: 2 additions & 0 deletions corec/corec/helpers/date/date_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ static FILETIME fTimeCache[MAX_CACHED_YEAR - MIN_CACHED_YEAR + 2][2];
#define TIME_ZONE_ID_INVALID ((DWORD)0xFFFFFFFF)
#endif

static bool_t GetIsDst(datetime_t t); // may not be correct on all platforms

systick_t GetTimeTick(void)
{
return GetTickCount();
Expand Down
1 change: 1 addition & 0 deletions corec/corec/helpers/file/bufstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
****************************************************************************/

#include "file.h"
#include "streams.h"

#define BUFSTREAM_SIZE 4096

Expand Down
36 changes: 1 addition & 35 deletions corec/corec/helpers/file/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
#ifndef __FILE_H
#define __FILE_H

#include "corec/node/node.h"
#include "corec/helpers/date/date.h"
#include <corec/node/node.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -50,22 +49,14 @@ extern "C" {

FILE_DLL void CoreC_FileInit(nodemodule* Module);

FILE_DLL bool_t FileExists(nodecontext*, const tchar_t*);
FILE_DLL bool_t FileMove(nodecontext*, const tchar_t* In,const tchar_t* Out);
FILE_DLL datetime_t FileDateTime(nodecontext*, const tchar_t*);
FILE_DLL bool_t PathIsFolder(nodecontext*, const tchar_t*);
FILE_DLL bool_t FolderCreate(nodecontext*, const tchar_t*);
// \param Force erase even if the file is read-only
// \param Safe put in the OS trash rather than a permanent erase
FILE_DLL bool_t FileErase(nodecontext*, const tchar_t*, bool_t Force, bool_t Safe);
FILE_DLL bool_t FolderErase(nodecontext*, const tchar_t*, bool_t Force, bool_t Safe);
FILE_DLL void FindFiles(nodecontext*,const tchar_t* Path, const tchar_t* Mask,void(*Process)(const tchar_t*,void*),void* Param);
FILE_DLL int64_t GetPathFreeSpace(nodecontext*,const tchar_t* Path);

FILE_DLL void RemovePathDelimiter(tchar_t* Path);
FILE_DLL void AddPathDelimiter(tchar_t* Path,size_t PathLen);
FILE_DLL const tchar_t* GetProtocol(const tchar_t* URL, tchar_t *_Protocol, int ProtoLen, bool_t* HasHost);
FILE_DLL fourcc_t GetProtocolKind(anynode*, tchar_t *_Protocol);
FILE_DLL void SplitPath(const tchar_t* Path, tchar_t* Dir, int DirLen, tchar_t* Name, int NameLen, tchar_t* Ext, int ExtLen);
FILE_DLL void SplitURL(const tchar_t* URL, tchar_t* Mime, int MimeLen, tchar_t* Host, int HostLen, int* Port, tchar_t* Path, int PathLen);
FILE_DLL bool_t SplitAddr(const tchar_t* URL, tchar_t* Peer, int PeerLen, tchar_t* Local, int LocalLen);
Expand All @@ -76,31 +67,6 @@ FILE_DLL void AbsPathNormalize(tchar_t* Abs, size_t AbsLen);
FILE_DLL void ReduceLocalPath(tchar_t* Abs, size_t AbsLen);
FILE_DLL void RelPath(tchar_t* Rel, int RelLen, const tchar_t* Path, const tchar_t* Base);
FILE_DLL bool_t UpperPath(tchar_t* Path, tchar_t* Last, size_t LastLen);
FILE_DLL void StreamLoginInfo(node* p, tchar_t* URL, bool_t Proxy); //URL updated

FILE_DLL tchar_t* FirstSepar(const tchar_t *Path);
FILE_DLL void SplitURLLogin(const tchar_t *URL, tchar_t *UserName, size_t UserNameLen, tchar_t *Password, size_t PasswordLen, tchar_t *URL2, size_t URL2Len);
FILE_DLL void SplitShare(const tchar_t *Path, tchar_t *Share, size_t ShareLen, tchar_t *Path2, size_t Path2Len);
FILE_DLL tchar_t *MergeURL(tchar_t *URL, size_t URLLen, const tchar_t *Proto, const tchar_t *Host, int Port, const tchar_t *Path);
FILE_DLL tchar_t *GetIP(tchar_t *sIP, size_t IPLen, long IP);
FILE_DLL void SplitURLParams(const tchar_t* URL, tchar_t* URL2, int URL2Len, tchar_t* Params, int ParamsLen);
FILE_DLL tchar_t *AddCacheURL(tchar_t* Out, size_t Len, const tchar_t *In);
FILE_DLL bool_t CheckRemoveCacheURL(const tchar_t** URL);
FILE_DLL bool_t RemoveURLParam(tchar_t* URL, const tchar_t* Param);

static INLINE size_t FileBlockSize(filepos_t Start,filepos_t End)
{
End -= Start;
if (End<0 || End>INT_MAX)
return 0;
return (size_t)End;
}

#include "corec/helpers/file/streams.h"

FILE_DLL stream *FileTemp(anynode*);
FILE_DLL bool_t FileTempName(anynode*,tchar_t *Out, size_t OutLen);
FILE_DLL err_t FileStat(nodecontext* p, const tchar_t* Path, streamdir* Item);

#ifdef __cplusplus
}
Expand Down
102 changes: 2 additions & 100 deletions corec/corec/helpers/file/file_libc.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
****************************************************************************/

#include "file.h"
#include "streams.h"
#include <corec/str/str.h>

#ifdef CONFIG_FILEPOS_64
#define __USE_FILE_OFFSET64
Expand Down Expand Up @@ -279,12 +281,6 @@ META_DATA(TYPE_FILEPOS,STREAM_LENGTH,filestream,Length)
META_PARAM(STRING,NODE_PROTOCOL,T("file"))
META_END(STREAM_CLASS)

bool_t FileExists(nodecontext *p,const tchar_t* Path)
{
struct stat file_stats;
return stat(Path, &file_stats) == 0;
}

bool_t FileErase(nodecontext *p,const tchar_t* Path, bool_t Force, bool_t Safe)
{
if (Force)
Expand All @@ -302,23 +298,6 @@ bool_t FileErase(nodecontext *p,const tchar_t* Path, bool_t Force, bool_t Safe)
return unlink(Path) == 0;
}

bool_t FolderErase(nodecontext *p,const tchar_t* Path, bool_t Force, bool_t Safe)
{
if (Force)
{
struct stat file_stats;
if (stat(Path, &file_stats) == 0)
{
if ((file_stats.st_mode & S_IWUSR)==0)
{
file_stats.st_mode |= S_IWUSR;
chmod(Path,file_stats.st_mode);
}
}
}
return rmdir(Path) == 0;
}

bool_t PathIsFolder(nodecontext *p,const tchar_t* Path)
{
struct stat file_stats;
Expand All @@ -328,80 +307,3 @@ bool_t PathIsFolder(nodecontext *p,const tchar_t* Path)
}
return 0;
}

datetime_t FileDateTime(nodecontext *p,const tchar_t* Path)
{
datetime_t Date = INVALID_DATETIME_T;
struct stat file_stats;
if (stat(Path, &file_stats) == 0)
Date = LinuxToDateTime(file_stats.st_mtime);
return Date;
}

bool_t FileMove(nodecontext *p,const tchar_t* In,const tchar_t* Out)
{
return rename(In,Out) == 0;
}

bool_t FolderCreate(nodecontext *p,const tchar_t* Path)
{
return mkdir(Path,_RW_ACCESS_DIR) == 0;
}

void FindFiles(nodecontext *p,const tchar_t* Path, const tchar_t* Mask,void(*Process)(const tchar_t*,void*),void* Param)
{
DIR* Directory;
struct dirent* DirectoryInfo;
tchar_t TPathToFile[MAXPATH];

Directory = opendir(Path);
if (Directory)
{
while ( (DirectoryInfo = readdir(Directory)) != NULL )
{
char* FileExtension = 0;
FileExtension = strrchr(DirectoryInfo->d_name, '.');
if(FileExtension)
{
if (strcmp(Mask, FileExtension ) == 0 )
{
tcscpy_s(TPathToFile, TSIZEOF(TPathToFile), Path);
tcscat_s(TPathToFile, TSIZEOF(TPathToFile), DirectoryInfo->d_name);
Process(TPathToFile, Param);
}
}
}

closedir(Directory);
}

}

stream *FileTemp(anynode *Any)
{
#ifndef TODO
assert(NULL); // not supported yet
#endif
return NULL;
}

bool_t FileTempName(anynode *Any,tchar_t *Out, size_t OutLen)
{
#ifndef TODO
assert(NULL); // not supported yet
#endif
return 0;
}

int64_t GetPathFreeSpace(nodecontext* UNUSED_PARAM(p), const tchar_t* Path)
{
#ifndef TODO
// need to an include (see at includes)
struct statfs st;
if (statfs(Path, &st) < 0)
return -1;
return (int64_t)st.f_bsize * (int64_t)st.f_bavail;
#else
return -1;
#endif
}
Loading
Loading