Home | History | Annotate | Download | only in libebl
      1 /* Return note type name.
      2    Copyright (C) 2002 Red Hat, Inc.
      3    Written by Ulrich Drepper <drepper (at) redhat.com>, 2002.
      4 
      5    This program is Open Source software; you can redistribute it and/or
      6    modify it under the terms of the Open Software License version 1.0 as
      7    published by the Open Source Initiative.
      8 
      9    You should have received a copy of the Open Software License along
     10    with this program; if not, you may obtain a copy of the Open Software
     11    License version 1.0 from http://www.opensource.org/licenses/osl.php or
     12    by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
     13    3001 King Ranch Road, Ukiah, CA 95482.   */
     14 
     15 #ifdef HAVE_CONFIG_H
     16 # include <config.h>
     17 #endif
     18 
     19 #include <inttypes.h>
     20 #include <stdio.h>
     21 #include <libeblP.h>
     22 
     23 
     24 const char *
     25 ebl_object_note_type_name (ebl, type, buf, len)
     26      Ebl *ebl;
     27      uint32_t type;
     28      char *buf;
     29      size_t len;
     30 {
     31   const char *res = ebl->object_note_type_name (type, buf, len);
     32 
     33   if (res == NULL)
     34     {
     35       static const char *knowntypes[] =
     36 	{
     37 #define KNOWNSTYPE(name) [NT_##name] = #name
     38 	  KNOWNSTYPE (VERSION),
     39 	};
     40 
     41       /* Handle standard names.  */
     42       if (type < sizeof (knowntypes) / sizeof (knowntypes[0])
     43 	  && knowntypes[type] != NULL)
     44 	res = knowntypes[type];
     45       else
     46 	{
     47 	  snprintf (buf, len, "%s: %" PRIu32, gettext ("<unknown>"), type);
     48 
     49 	  res = buf;
     50 	}
     51     }
     52 
     53   return res;
     54 }
     55