Blame elf/stringtable.h

Packit Service 50cddb
/* String tables for ld.so.cache construction.
Packit Service 50cddb
   Copyright (C) 2020 Free Software Foundation, Inc.
Packit Service 50cddb
   This file is part of the GNU C Library.
Packit Service 50cddb
Packit Service 50cddb
   This program is free software; you can redistribute it and/or modify
Packit Service 50cddb
   it under the terms of the GNU General Public License as published
Packit Service 50cddb
   by the Free Software Foundation; version 2 of the License, or
Packit Service 50cddb
   (at your option) any later version.
Packit Service 50cddb
Packit Service 50cddb
   This program is distributed in the hope that it will be useful,
Packit Service 50cddb
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 50cddb
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 50cddb
   GNU General Public License for more details.
Packit Service 50cddb
Packit Service 50cddb
   You should have received a copy of the GNU General Public License
Packit Service 50cddb
   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
Packit Service 50cddb
Packit Service 50cddb
#ifndef _STRINGTABLE_H
Packit Service 50cddb
#define _STRINGTABLE_H
Packit Service 50cddb
Packit Service 50cddb
#include <stddef.h>
Packit Service 50cddb
#include <stdint.h>
Packit Service 50cddb
Packit Service 50cddb
/* An entry in the string table.  Only the length and string fields are
Packit Service 50cddb
   expected to be used outside the string table code.  */
Packit Service 50cddb
struct stringtable_entry
Packit Service 50cddb
{
Packit Service 50cddb
  struct stringtable_entry *next; /* For collision resolution.  */
Packit Service 50cddb
  uint32_t length;                /* Length of then string.  */
Packit Service 50cddb
  uint32_t offset;                /* From start of finalized table.  */
Packit Service 50cddb
  char string[];                  /* Null-terminated string.  */
Packit Service 50cddb
};
Packit Service 50cddb
Packit Service 50cddb
/* A string table.  Zero-initialization produces a valid atable.  */
Packit Service 50cddb
struct stringtable
Packit Service 50cddb
{
Packit Service 50cddb
  struct stringtable_entry **entries;  /* Array of hash table buckets.  */
Packit Service 50cddb
  uint32_t count;                 /* Number of elements in the table.  */
Packit Service 50cddb
  uint32_t allocated;             /* Length of the entries array.  */
Packit Service 50cddb
};
Packit Service 50cddb
Packit Service 50cddb
/* Adds STRING to TABLE.  May return the address of an existing entry.  */
Packit Service 50cddb
struct stringtable_entry *stringtable_add (struct stringtable *table,
Packit Service 50cddb
                                           const char *string);
Packit Service 50cddb
Packit Service 50cddb
/* Result of stringtable_finalize.  SIZE bytes at STRINGS should be
Packit Service 50cddb
   written to the file.  */
Packit Service 50cddb
struct stringtable_finalized
Packit Service 50cddb
{
Packit Service 50cddb
  char *strings;
Packit Service 50cddb
  size_t size;
Packit Service 50cddb
};
Packit Service 50cddb
Packit Service 50cddb
/* Assigns offsets to string table entries and computes the serialized
Packit Service 50cddb
   form of the string table.  */
Packit Service 50cddb
void stringtable_finalize (struct stringtable *table,
Packit Service 50cddb
                           struct stringtable_finalized *result);
Packit Service 50cddb
Packit Service 50cddb
/* Deallocate the string table (but not the TABLE pointer itself).
Packit Service 50cddb
   (The table can be re-used for adding more strings without
Packit Service 50cddb
   initialization.)  */
Packit Service 50cddb
void stringtable_free (struct stringtable *table);
Packit Service 50cddb
Packit Service 50cddb
#endif /* _STRINGTABLE_H */