mirror of
https://github.com/pissnet/pissircd.git
synced 2025-08-08 19:25:25 +01:00
For ./unrealircd module parse-c-file use real line counts within the C file instead of within the special block
This commit is contained in:
parent
2fa0edf599
commit
cdea885b32
3 changed files with 16 additions and 8 deletions
|
@ -99,6 +99,7 @@ extern void module_loadall(void);
|
|||
extern long set_usermode(char *umode);
|
||||
extern char *get_usermode_string_raw(long umodes);
|
||||
extern ConfigFile *config_parse(char *filename, char *confdata);
|
||||
extern ConfigFile *config_parse_with_offset(char *filename, char *confdata, unsigned int line_offset);
|
||||
extern void config_error(FORMAT_STRING(const char *format), ...) __attribute__((format(printf,1,2)));
|
||||
extern void config_warn(FORMAT_STRING(const char *format), ...) __attribute__((format(printf,1,2)));
|
||||
extern void config_error_missing(const char *filename, int line, const char *entry);
|
||||
|
|
|
@ -196,6 +196,7 @@ long config_checkval(char *value, unsigned short flags);
|
|||
|
||||
ConfigFile *config_load(char *filename, char *displayname);
|
||||
void config_free(ConfigFile *cfptr);
|
||||
ConfigFile *config_parse_with_offset(char *filename, char *confdata, unsigned int line_offset);
|
||||
ConfigFile *config_parse(char *filename, char *confdata);
|
||||
ConfigEntry *config_find_entry(ConfigEntry *ce, char *name);
|
||||
|
||||
|
@ -886,14 +887,18 @@ char *unreal_add_quotes(char *str)
|
|||
return qbuf;
|
||||
}
|
||||
|
||||
ConfigFile *config_parse(char *filename, char *confdata){
|
||||
return config_parse_with_offset(filename, confdata, 0);
|
||||
}
|
||||
|
||||
/* This is the internal parser, made by Chris Behrens & Fred Jacobs <2005.
|
||||
* Enhanced (or mutilated) by Bram Matthys over the years (2015-2019).
|
||||
*/
|
||||
ConfigFile *config_parse(char *filename, char *confdata)
|
||||
ConfigFile *config_parse_with_offset(char *filename, char *confdata, unsigned int line_offset)
|
||||
{
|
||||
char *ptr;
|
||||
char *start;
|
||||
int linenumber = 1;
|
||||
int linenumber = 1+line_offset;
|
||||
int errors = 0;
|
||||
int n;
|
||||
ConfigEntry *curce;
|
||||
|
|
|
@ -429,12 +429,12 @@ int mm_module_file_config(ManagedModule *m, ConfigEntry *ce)
|
|||
|
||||
#undef CheckNull
|
||||
|
||||
int mm_parse_module_file(ManagedModule *m, char *buf)
|
||||
int mm_parse_module_file(ManagedModule *m, char *buf, unsigned int line_offset)
|
||||
{
|
||||
ConfigFile *cf;
|
||||
ConfigEntry *ce;
|
||||
|
||||
cf = config_parse(m->name, buf);
|
||||
cf = config_parse_with_offset(m->name, buf, line_offset);
|
||||
if (!cf)
|
||||
return 0; /* eg: parse errors */
|
||||
|
||||
|
@ -462,7 +462,7 @@ ManagedModule *mm_parse_module_c_file(char *modulename, char *fname)
|
|||
ParseModuleHeaderStage parse_module_header = PMH_STAGE_LOOKING;
|
||||
ParseModuleConfigStage parse_module_config = PMC_STAGE_LOOKING;
|
||||
char *moduleconfig = NULL;
|
||||
int linenr = 0;
|
||||
int linenr = 0, module_config_start_line = 0;
|
||||
char module_header_name[128];
|
||||
char module_header_version[64];
|
||||
char module_header_description[256];
|
||||
|
@ -526,8 +526,10 @@ ManagedModule *mm_parse_module_c_file(char *modulename, char *fname)
|
|||
switch (parse_module_config)
|
||||
{
|
||||
case PMC_STAGE_LOOKING:
|
||||
if (strstr(buf, "<<<MODULE MANAGER START>>>"))
|
||||
if (strstr(buf, "<<<MODULE MANAGER START>>>")){
|
||||
module_config_start_line = linenr;
|
||||
parse_module_config = PMC_STAGE_STARTED;
|
||||
}
|
||||
break;
|
||||
case PMC_STAGE_STARTED:
|
||||
if (!strstr(buf, "<<<MODULE MANAGER END>>>"))
|
||||
|
@ -577,12 +579,12 @@ ManagedModule *mm_parse_module_c_file(char *modulename, char *fname)
|
|||
safe_strdup(m->description, module_header_description);
|
||||
safe_strdup(m->author, module_header_author);
|
||||
|
||||
if (!mm_parse_module_file(m, moduleconfig))
|
||||
if (!mm_parse_module_file(m, moduleconfig, module_config_start_line))
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unable to parse module manager data in the %s module.\n"
|
||||
"-- configuration block within %s --\n"
|
||||
"%s\n"
|
||||
"-- end of configiguration within %s --\n"
|
||||
"-- end of configuration within %s --\n"
|
||||
"You are suggested to contact the module author and paste the above to him/her\n",
|
||||
m->name,
|
||||
m->name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue