//================================================================================
// CLists header
//
// List of:
//  - C-functions
//  - C-structure typedefs
//  - C-#defines
//
// Plus:
//  - Macro function lister
//  - Assembly label lister
//  - HTML documentation generator
//
//
// Plugin for BEd
//
// AUTHOR:  Gabor Nagy & Attila Vass
// DATE:    2025-Feb-26 18:35:18
//
// BEd Copyright (C) 2014-2026 by Gabor Nagy & Attila Vass. All rights reserved.
//================================================================================
#ifndef _CLists_h
#define _CLists_h

#include <stdio.h>
#include <string.h>


#ifndef _ELists_h
#include <ELists.h>
#endif

#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))
extern "C" {
#endif


// Function types
//
enum
{
	ELngC_FUNCTION = 1,
	ELngC_MACRO,
	ELngC_TYPEDEF,
	ELngC_STRUCT
};


enum
{
	ELngDOC,
	ELngHTML_FUNCTION_DOC,
	ELngFUNCTION_PROTOTYPES
};


typedef struct
{
	int    Line;
	int    MessageType;
	char*  Message;
} ELngStatus;


typedef struct
{
	char*  Name;
	char*  TypeStr;
} ELngArgument;
EListA_t(ELngArgument);

// Function, struct, macro etc. record
//
typedef struct
{
	char*  Name;
	int    NameStart, NameLength, FunctionEnd;
	int    Type;         // ELng_C_FUNCTION or ELng_C_MACRO
	EListA_s(, ELngArgument, Arguments);
	int    IndexInDisplayedList;
} ELngEntry;
EListA_t(ELngEntry);

// Listed function record
//
typedef struct
{
	ELngEntry*  Original;
} ELngListedEntry;


// Displayable function record
//
typedef struct
{
	char*       Name;
	int         Type;    // ELng_C_FUNCTION or ELng_C_MACRO
	ELngEntry*  Original;
} ELngDispEntry;



extern char*  ELng_HTMLHeader;
extern char*  ELng_HTMLEnd;


extern void    ELng_StatusInit(ELngStatus* PStatus);
extern void    ELng_StatusClear(ELngStatus* PStatus);

extern void    ELng_ListClear(ELngEntry* PEntries, const EIndex PNumOfEntries);
extern void    ELng_DispListClear(ELngDispEntry* PEntries, const EIndex PNumOfEntries);
extern EIndex  ELng_GetFunctions(const char* PText, ELngEntry** PEntriesP, EIndex* PNumOfAllocatedEntriesP, ELngStatus* PStatus);
extern EIndex  ELng_GetLabels(const char* PText, ELngEntry** PEntriesP, EIndex* PNumOfAllocatedEntriesP, ELngStatus* PStatus);
extern EIndex  ELng_Document(const char* PText, const unsigned int PTextLength, const ELngEntry* PEntries, const EIndex PNumOfEntries, FILE* POutFile, const int PFormat, const EBool PAddArgTypes);
extern void    ELng_Init(void);
extern void    ELng_Free(void);

#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))
}	// Close scope of 'extern "C"' declaration
#endif

#endif // _CLists_h
