Skip to content

Conversation

Promisecharles
Copy link

Make sure these boxes are checked accordingly before submitting your Pull Request -- thank you.

Contribution style:

Our Contribution agreements:

Changes (if applicable):

Link to ticket: https://redmine.openinfosecfoundation.org/issues/6572

Describe changes:

  • Align columns for RunMode Type, Custom Mode, and Description
  • Remove extra horizontal lines for clarity
  • Ensure multi-mode types only show first column once
  • Improve readability of runmodes output

Provide values to any of the below to override the defaults.

  • To use a Suricata-Verify or Suricata-Update pull request,
    link to the pull request in the respective _BRANCH variable.
  • Leave unused overrides blank or remove.

SV_REPO=
SV_BRANCH=
SU_REPO=
SU_BRANCH=

- Align columns for RunMode Type, Custom Mode, and Description
- Remove redundant horizontal separators for cleaner output
- Show RunMode Type only once per multi-mode group
- Improve readability and consistency of --list-runmodes table

Signed-off-by: Promise Charles <[email protected]>
Copy link

NOTE: This PR may contain new authors.

Copy link
Member

@inashivb inashivb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please:

  • add tests if possible as asked on the previous rev.
  • make sure the code compiles locally before sending a PR.
  • fix commit message to follow proper guidelines. A recent example: 0af7793

Comment on lines -255 to +312
* \brief Lists all registered runmodes.
* \brief Lists all registered runmodes (optimized table output).
*/
void RunModeListRunmodes(void)
{
printf("------------------------------------- Runmodes -------------------"
"-----------------------\n");

printf("| %-17s | %-17s | %-10s \n",
"RunMode Type", "Custom Mode ", "Description");
printf("|-----------------------------------------------------------------"
"-----------------------\n");
int i = RUNMODE_UNKNOWN + 1;
int j = 0;
for ( ; i < RUNMODE_USER_MAX; i++) {
int mode_displayed = 0;
for (j = 0; j < runmodes[i].cnt; j++) {
if (mode_displayed == 1) {
printf("| ----------------------------------------------"
"-----------------------\n");
RunMode *runmode = &runmodes[i].runmodes[j];
printf("| %-17s | %-17s | %-27s \n",
"",
runmode->name,
runmode->description);
} else {
RunMode *runmode = &runmodes[i].runmodes[j];
printf("| %-17s | %-17s | %-27s \n",
RunModeTranslateModeToName(runmode->runmode),
runmode->name,
runmode->description);
}
if (mode_displayed == 0)
mode_displayed = 1;
int type_width = 12;
int mode_width = 10;
const int desc_width = 60;

/* Dynamically calculate max column widths */
for (int i = RUNMODE_UNKNOWN + 1; i < RUNMODE_USER_MAX; i++) {
for (int j = 0; j < runmodes[i].cnt; j++) {
RunMode *r = &runmodes[i].runmodes[j];
int tlen = strlen(RunModeTranslateModeToName(r->runmode));
int mlen = strlen(r->name);
if (tlen > type_width)
type_width = tlen;
if (mlen > mode_width)
mode_width = mlen;
}
if (mode_displayed == 1) {
printf("|-----------------------------------------------------------------"
"-----------------------\n");
}

/* Print header */
printf("\n%-*s\n", type_width + mode_width + desc_width + 10,
"--------------------------- Runmodes ---------------------------");
printf("| %-*s | %-*s | %-*s |\n",
type_width, "RunMode Type",
mode_width, "Custom Mode",
desc_width, "Description");

/* Separator function */
auto void PrintSeparator(void) {
printf("|-%.*s-|-%.*s-|-%.*s-|\n",
type_width + 2, "----------------------------------------",
mode_width + 2, "----------------------------------------",
desc_width + 2, "------------------------------------------------------------");
};
PrintSeparator();

/* Print runmodes */
for (int i = RUNMODE_UNKNOWN + 1; i < RUNMODE_USER_MAX; i++) {
int printed = 0;
for (int j = 0; j < runmodes[i].cnt; j++) {
RunMode *r = &runmodes[i].runmodes[j];
const char *type_name = RunModeTranslateModeToName(r->runmode);

printf("| %-*s | %-*s | %-*s |\n",
printed ? 0 : type_width,
printed ? "" : type_name,
mode_width, r->name,
desc_width, r->description);
printed = 1;
}
if (printed)
PrintSeparator();
}
}

printf("\n");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any proposed modification must first go in Discord/Redmine. So, let's stick to what's required by the ticket you're working on for now and remove these changes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any proposed modification must first go in Discord/Redmine. So, let's stick to what's required by the ticket you're working on for now and remove these changes.

Ok. will do that.

SCInstance *suri = &suricata;
switch (suri->run_mode) {
case RUNMODE_UNKNOWN:
printf("\n[!] No capture/runmode specified.\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Victor's review comments from the previous PR must be addressed.

@victorjulien victorjulien added the outreachy Contributions made by Outreachy applicants label Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

outreachy Contributions made by Outreachy applicants

Development

Successfully merging this pull request may close these issues.

3 participants