/*
** notes.c for elfsh
** 
** Started on  Fri Nov  2 15:20:58 2001 mayhem
** Last update Sun Mar 10 01:08:30 2002 mayhem
*/
#include "elfsh.h"




/* Display the note section */
int			display_notes(Elfsh32_Obj *file, argv_t *args)
{
  Elfsh32_Sect		*sect;
  Elfsh32_Note_ent	*e;
  regex_t		*tmp;
  int			index;
  int			range;
  char			buff[256];
  
  puts("\n[SHT_NOTES]");

  tmp = (REGX_IS_USED(args->notes_use_regx) ? &args->notes_regx : 
	 REGX_IS_USED(args->gl_use_regx)    ? &args->gl_regx    : NULL);

  for (range = 0; (sect = elfsh_get_notes(file, range, NULL)); range++)
    {

      printf(" {Section %s} \n", elfsh_get_section_name(file, sect->shdr));      
      
      for (index = 0, e = sect->altdata; e; e = e->next, index++)
	{
	  snprintf(buff, sizeof(buff), "\t\t\t [%02u] \t ENTRY(%s)", index, e->note);
	  if (!tmp || (tmp && e->note && !regexec(tmp, buff, 0, 0, 0)))
	    puts(buff);
	}

      puts("");
    }

  return (0);
}








