/*
** strtab.c for libelfsh
** 
** Started on  Sun Mar 10 03:24:23 2002 mayhem
** Last update Mon Apr  1 13:18:35 2002 mayhem
*/
#include "libelfsh.h"




/* Add a symbol name in strtab */
int		elfsh_insert_in_strtab(Elfsh32_Obj *file, char *name)
{
  Elfsh32_Sect	*sect;
  
  if (!name)
    ELFSH_SETERROR("libelfsh: Invalid parameter for elfsh_insert_in_strtab . \n", -1);

  sect = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_STRTAB, NULL, NULL, NULL);
  if (!sect)
    return (-1);
  
  return (elfsh_append_data_to_section(sect, name, strlen(name) + 1));
}





/* Add a section name in shstrtab */
int		elfsh_insert_in_shstrtab(Elfsh32_Obj *file, char *name)
{
  if (!name)
    ELFSH_SETERROR("libelfsh: Invalid name parameter \n", -1);  
  else if (!file->sh_strtab)
    ELFSH_SETERROR("libelfsh: Cannot find .shstrtab \n", -1);
  return (elfsh_append_data_to_section(file->sh_strtab, name, strlen(name) + 1));
}




