File tree Expand file tree Collapse file tree 3 files changed +12
-14
lines changed Expand file tree Collapse file tree 3 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -142,10 +142,7 @@ void HPM_map_atcommands(void) {
142
142
unsigned int i ;
143
143
144
144
for (i = 0 ; i < atcommand_list_items ; i ++ ) {
145
- if ( !atcommand -> add (atcommand_list [i ].name ,atcommand_list [i ].func ) ) {
146
- ShowDebug ("HPM_map_atcommands: duplicate command '%s', skipping...\n" , atcommand_list [i ].name );
147
- continue ;
148
- }
145
+ atcommand -> add (atcommand_list [i ].name ,atcommand_list [i ].func ,true);
149
146
}
150
147
}
151
148
Original file line number Diff line number Diff line change @@ -9564,7 +9564,7 @@ void atcommand_basecommands(void) {
9564
9564
int i ;
9565
9565
9566
9566
for ( i = 0 ; i < ARRAYLENGTH (atcommand_base ); i ++ ) {
9567
- if (!atcommand -> add (atcommand_base [i ].command ,atcommand_base [i ].func )) { // Should not happen if atcommand_base[] array is OK
9567
+ if (!atcommand -> add (atcommand_base [i ].command ,atcommand_base [i ].func ,false )) { // Should not happen if atcommand_base[] array is OK
9568
9568
ShowDebug ("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n" , atcommand_base [i ].command );
9569
9569
continue ;
9570
9570
}
@@ -9576,21 +9576,22 @@ void atcommand_basecommands(void) {
9576
9576
return ;
9577
9577
}
9578
9578
9579
- bool atcommand_add (char * name ,AtCommandFunc func ) {
9579
+ bool atcommand_add (char * name ,AtCommandFunc func , bool replace ) {
9580
9580
AtCommandInfo * cmd ;
9581
9581
9582
- if (atcommand -> exists (name )) //caller will handle/display on false
9583
- return false;
9584
-
9585
- CREATE (cmd , AtCommandInfo , 1 );
9582
+ if ( (cmd = atcommand -> exists (name )) ) { //caller will handle/display on false
9583
+ if ( !replace )
9584
+ return false;
9585
+ } else {
9586
+ CREATE (cmd , AtCommandInfo , 1 );
9587
+ strdb_put (atcommand -> db , name , cmd );
9588
+ }
9586
9589
9587
9590
safestrncpy (cmd -> command , name , sizeof (cmd -> command ));
9588
9591
cmd -> func = func ;
9589
9592
cmd -> help = NULL ;
9590
9593
cmd -> log = true;
9591
-
9592
- strdb_put (atcommand -> db , cmd -> command , cmd );
9593
-
9594
+
9594
9595
return true;
9595
9596
}
9596
9597
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ struct atcommand_interface {
110
110
int (* cmd_db_clear_sub ) (DBKey key , DBData * data , va_list args );
111
111
void (* doload ) (void );
112
112
void (* base_commands ) (void );
113
- bool (* add ) (char * name , AtCommandFunc func );
113
+ bool (* add ) (char * name , AtCommandFunc func , bool replace );
114
114
};
115
115
116
116
struct atcommand_interface * atcommand ;
You can’t perform that action at this time.
0 commit comments