Skip to content

Commit

Permalink
Change metadata -> hit_desc
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Dec 10, 2024
1 parent 48ea240 commit 36ac49d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion librz/core/cmd/cmd_search.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static RzCmdStatus cmd_core_handle_search_hits(RzCore *core, RzCmdStateOutput *s
}

// only output & add flag when cmd.hit is not set.
const char *meta = hit->metadata ? hit->metadata : "match";
const char *meta = hit->hit_desc ? hit->hit_desc : "match";
char *flag = rz_str_newf("%s.%s.%" PFMTSZu, search_prefix, meta, counter);
rz_flag_set(core->flags, flag, hit->address, hit->size);
cmd_search_output_to_state(state, hit, flag);
Expand Down
2 changes: 1 addition & 1 deletion librz/include/rz_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ typedef struct rz_search_opt_t RzSearchOpt;
typedef struct rz_search_collection_t RzSearchCollection;

typedef struct rz_search_hit_t {
char *metadata; ///< Metadata for extra details (can be NULL)
char *hit_desc; ///< Hit description (can be NULL)
ut64 address; ///< Address the matched data
size_t size; ///< Size of the matched data (can be 0)
} RzSearchHit;
Expand Down
4 changes: 2 additions & 2 deletions librz/main/rz-find.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ static void rz_find_output_hit(RzFindOptions *ro, RzSearchHit *hit, RzCore *core
pj_o(ro->pj);
pj_kn(ro->pj, "address", hit->address);
pj_kn(ro->pj, "size", hit->size);
pj_ks(ro->pj, "type", hit->metadata);
pj_ks(ro->pj, "type", hit->hit_desc);
pj_end(ro->pj);
break;
case RZ_FIND_OUTPUT_STANDARD:
printf("0x%" PFMT64x " %" PFMTSZu " %s\n", hit->address, hit->size, hit->metadata);
printf("0x%" PFMT64x " %" PFMTSZu " %s\n", hit->address, hit->size, hit->hit_desc);
break;
case RZ_FIND_OUTPUT_HEXDUMP:
rz_find_output_hit_as_hexdump(ro, hit, core);
Expand Down
8 changes: 4 additions & 4 deletions librz/search/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,18 @@ RZ_API RZ_OWN RzList /*<RzSearchHit *>*/ *rz_search_run(RZ_NONNULL RzSearchOpt *
/**
* \brief Allocate and initialize a new RzSearchHit
*
* \param[in] metadata The metadata linked to the hit (can be NULL)
* \param[in] hit_desc The hit description linked to the hit (can be NULL)
* \param[in] address The address where the hit happened
* \param[in] size The size of the hit data (can be 0)
*
* \return On success returns a valid pointer, otherwise NULL
*/
RZ_IPI RZ_OWN RzSearchHit *rz_search_hit_new(const char *metadata, ut64 address, size_t size) {
RZ_IPI RZ_OWN RzSearchHit *rz_search_hit_new(const char *hit_desc, ut64 address, size_t size) {
RzSearchHit *hit = RZ_NEW0(RzSearchHit);
if (!hit) {
return NULL;
}
hit->metadata = rz_str_dup(metadata);
hit->hit_desc = rz_str_dup(hit_desc);
hit->address = address;
hit->size = size;
return hit;
Expand All @@ -172,6 +172,6 @@ RZ_API void rz_search_hit_free(RZ_NULLABLE RzSearchHit *hit) {
if (!hit) {
return;
}
free(hit->metadata);
free(hit->hit_desc);
free(hit);
}

0 comments on commit 36ac49d

Please sign in to comment.