@@ -810,7 +810,8 @@ void parse_history_line(const char *buf, char *command, char *gisdbase,
810810
811811 */
812812void 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 )
814815{
815816
816817 JSON_Value * info_value = json_value_init_object ();
@@ -819,6 +820,7 @@ void add_record_to_json(char *command, char *user, char *date,
819820 }
820821 JSON_Object * info_object = json_object (info_value );
821822
823+ json_object_set_number (info_object , "history_number" , history_number );
822824 json_object_set_string (info_object , "command" , command );
823825 json_object_set_string (info_object , "mapset_path" , mapset_path );
824826 json_object_set_string (info_object , "user" , user );
@@ -834,6 +836,8 @@ void add_record_to_json(char *command, char *user, char *date,
834836 */
835837void print_history (struct Map_info * Map , enum OutputFormat format )
836838{
839+ int history_number = 0 ;
840+
837841 char buf [STR_LEN ] = {0 };
838842 char command [STR_LEN ] = {0 }, gisdbase [STR_LEN ] = {0 };
839843 char location [STR_LEN ] = {0 }, mapset [STR_LEN ] = {0 };
@@ -872,8 +876,11 @@ void print_history(struct Map_info *Map, enum OutputFormat format)
872876 date , mapset_path );
873877 if (command [0 ] != '\0' && mapset_path [0 ] != '\0' &&
874878 user [0 ] != '\0' && date [0 ] != '\0' ) {
879+ // Increment history counter
880+ history_number ++ ;
881+
875882 add_record_to_json (command , user , date , mapset_path ,
876- record_array );
883+ record_array , history_number );
877884 }
878885 break ;
879886 }
0 commit comments