Linux Audio

Check our new training course

Loading...
Note: File does not exist in v4.6.
  1/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
  2/*
  3 * ctype function definitions for NOLIBC
  4 * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
  5 */
  6
  7#ifndef _NOLIBC_CTYPE_H
  8#define _NOLIBC_CTYPE_H
  9
 10#include "std.h"
 11
 12/*
 13 * As much as possible, please keep functions alphabetically sorted.
 14 */
 15
 16static __attribute__((unused))
 17int isascii(int c)
 18{
 19	/* 0x00..0x7f */
 20	return (unsigned int)c <= 0x7f;
 21}
 22
 23static __attribute__((unused))
 24int isblank(int c)
 25{
 26	return c == '\t' || c == ' ';
 27}
 28
 29static __attribute__((unused))
 30int iscntrl(int c)
 31{
 32	/* 0x00..0x1f, 0x7f */
 33	return (unsigned int)c < 0x20 || c == 0x7f;
 34}
 35
 36static __attribute__((unused))
 37int isdigit(int c)
 38{
 39	return (unsigned int)(c - '0') < 10;
 40}
 41
 42static __attribute__((unused))
 43int isgraph(int c)
 44{
 45	/* 0x21..0x7e */
 46	return (unsigned int)(c - 0x21) < 0x5e;
 47}
 48
 49static __attribute__((unused))
 50int islower(int c)
 51{
 52	return (unsigned int)(c - 'a') < 26;
 53}
 54
 55static __attribute__((unused))
 56int isprint(int c)
 57{
 58	/* 0x20..0x7e */
 59	return (unsigned int)(c - 0x20) < 0x5f;
 60}
 61
 62static __attribute__((unused))
 63int isspace(int c)
 64{
 65	/* \t is 0x9, \n is 0xA, \v is 0xB, \f is 0xC, \r is 0xD */
 66	return ((unsigned int)c == ' ') || (unsigned int)(c - 0x09) < 5;
 67}
 68
 69static __attribute__((unused))
 70int isupper(int c)
 71{
 72	return (unsigned int)(c - 'A') < 26;
 73}
 74
 75static __attribute__((unused))
 76int isxdigit(int c)
 77{
 78	return isdigit(c) || (unsigned int)(c - 'A') < 6 || (unsigned int)(c - 'a') < 6;
 79}
 80
 81static __attribute__((unused))
 82int isalpha(int c)
 83{
 84	return islower(c) || isupper(c);
 85}
 86
 87static __attribute__((unused))
 88int isalnum(int c)
 89{
 90	return isalpha(c) || isdigit(c);
 91}
 92
 93static __attribute__((unused))
 94int ispunct(int c)
 95{
 96	return isgraph(c) && !isalnum(c);
 97}
 98
 99/* make sure to include all global symbols */
100#include "nolibc.h"
101
102#endif /* _NOLIBC_CTYPE_H */