@@ -810,7 +810,8 @@ void parse_history_line(const char *buf, char *command, char *gisdbase,
810
810
811
811
*/
812
812
void add_record_to_json (char * command , char * user , char * date ,
813
- char * mapset_path , JSON_Array * record_array )
813
+ char * mapset_path , JSON_Array * record_array ,
814
+ int history_number )
814
815
{
815
816
816
817
JSON_Value * info_value = json_value_init_object ();
@@ -819,6 +820,7 @@ void add_record_to_json(char *command, char *user, char *date,
819
820
}
820
821
JSON_Object * info_object = json_object (info_value );
821
822
823
+ json_object_set_number (info_object , "history_number" , history_number );
822
824
json_object_set_string (info_object , "command" , command );
823
825
json_object_set_string (info_object , "mapset_path" , mapset_path );
824
826
json_object_set_string (info_object , "user" , user );
@@ -834,6 +836,8 @@ void add_record_to_json(char *command, char *user, char *date,
834
836
*/
835
837
void print_history (struct Map_info * Map , enum OutputFormat format )
836
838
{
839
+ int history_number = 0 ;
840
+
837
841
char buf [STR_LEN ] = {0 };
838
842
char command [STR_LEN ] = {0 }, gisdbase [STR_LEN ] = {0 };
839
843
char location [STR_LEN ] = {0 }, mapset [STR_LEN ] = {0 };
@@ -872,8 +876,11 @@ void print_history(struct Map_info *Map, enum OutputFormat format)
872
876
date , mapset_path );
873
877
if (command [0 ] != '\0' && mapset_path [0 ] != '\0' &&
874
878
user [0 ] != '\0' && date [0 ] != '\0' ) {
879
+ // Increment history counter
880
+ history_number ++ ;
881
+
875
882
add_record_to_json (command , user , date , mapset_path ,
876
- record_array );
883
+ record_array , history_number );
877
884
}
878
885
break ;
879
886
}
0 commit comments