]>
git.proxmox.com Git - grub2.git/blob - include/grub/misc.h
1 /* misc.h - prototypes for misc functions */
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2002,2003,2005 Free Software Foundation, Inc.
6 * GRUB is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef GRUB_MISC_HEADER
22 #define GRUB_MISC_HEADER 1
25 #include <grub/types.h>
26 #include <grub/symbol.h>
29 #define grub_dprintf(condition, fmt, args...) grub_real_dprintf(__FILE__, __LINE__, condition, fmt, ## args);
30 /* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */
31 #define grub_memcpy(d,s,n) grub_memmove ((d), (s), (n))
33 void *EXPORT_FUNC(grub_memmove
) (void *dest
, const void *src
, grub_size_t n
);
34 char *EXPORT_FUNC(grub_strcpy
) (char *dest
, const char *src
);
35 char *EXPORT_FUNC(grub_strncpy
) (char *dest
, const char *src
, int c
);
36 char *EXPORT_FUNC(grub_stpcpy
) (char *dest
, const char *src
);
37 char *EXPORT_FUNC(grub_strcat
) (char *dest
, const char *src
);
38 char *EXPORT_FUNC(grub_strncat
) (char *dest
, const char *src
, int c
);
40 /* Prototypes for aliases. */
41 void *EXPORT_FUNC(memmove
) (void *dest
, const void *src
, grub_size_t n
);
42 void *EXPORT_FUNC(memcpy
) (void *dest
, const void *src
, grub_size_t n
);
44 int EXPORT_FUNC(grub_memcmp
) (const void *s1
, const void *s2
, grub_size_t n
);
45 int EXPORT_FUNC(grub_strcmp
) (const char *s1
, const char *s2
);
46 int EXPORT_FUNC(grub_strncmp
) (const char *s1
, const char *s2
, grub_size_t n
);
47 int EXPORT_FUNC(grub_strncasecmp
) (const char *s1
, const char *s2
, int c
);
48 char *EXPORT_FUNC(grub_strchr
) (const char *s
, int c
);
49 char *EXPORT_FUNC(grub_strrchr
) (const char *s
, int c
);
50 int EXPORT_FUNC(grub_strword
) (const char *s
, const char *w
);
51 int EXPORT_FUNC(grub_iswordseparator
) (int c
);
52 int EXPORT_FUNC(grub_isspace
) (int c
);
53 int EXPORT_FUNC(grub_isprint
) (int c
);
54 int EXPORT_FUNC(grub_isalpha
) (int c
);
55 int EXPORT_FUNC(grub_isgraph
) (int c
);
56 int EXPORT_FUNC(grub_isdigit
) (int c
);
57 int EXPORT_FUNC(grub_tolower
) (int c
);
58 unsigned long EXPORT_FUNC(grub_strtoul
) (const char *str
, char **end
, int base
);
59 char *EXPORT_FUNC(grub_strdup
) (const char *s
);
60 char *EXPORT_FUNC(grub_strndup
) (const char *s
, grub_size_t n
);
61 void *EXPORT_FUNC(grub_memset
) (void *s
, int c
, grub_size_t n
);
62 grub_size_t
EXPORT_FUNC(grub_strlen
) (const char *s
);
63 int EXPORT_FUNC(grub_printf
) (const char *fmt
, ...) __attribute__ ((format (printf
, 1, 2)));
64 void EXPORT_FUNC(grub_real_dprintf
) (const char *file
,
66 const char *condition
,
67 const char *fmt
, ...) __attribute__ ((format (printf
, 4, 5)));
68 int EXPORT_FUNC(grub_vprintf
) (const char *fmt
, va_list args
);
69 int EXPORT_FUNC(grub_sprintf
) (char *str
, const char *fmt
, ...) __attribute__ ((format (printf
, 2, 3)));
70 int EXPORT_FUNC(grub_vsprintf
) (char *str
, const char *fmt
, va_list args
);
71 void EXPORT_FUNC(grub_exit
) (void) __attribute__ ((noreturn
));
72 void EXPORT_FUNC(grub_abort
) (void) __attribute__ ((noreturn
));
73 grub_uint8_t
*EXPORT_FUNC(grub_utf16_to_utf8
) (grub_uint8_t
*dest
,
76 grub_ssize_t
EXPORT_FUNC(grub_utf8_to_ucs4
) (grub_uint32_t
*dest
,
77 const grub_uint8_t
*src
,
80 /* Inline functions. */
81 static inline unsigned int
85 return (unsigned int) (-x
);
87 return (unsigned int) x
;
90 #endif /* ! GRUB_MISC_HEADER */