kernel: adjust formatting
This commit is contained in:
@@ -18,77 +18,76 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
static unsigned int random_seed = 53455346;
|
||||
|
||||
int isupper(int c) { return (c >= 65 && c <= 90); }
|
||||
|
||||
int islower(int c) { return (c >= 97 && c <= 122); }
|
||||
|
||||
int toupper(int c) {
|
||||
if (!islower(c)) {
|
||||
return c;
|
||||
}
|
||||
|
||||
return c - 32;
|
||||
int isupper(int c)
|
||||
{
|
||||
return (c >= 65 && c <= 90);
|
||||
}
|
||||
|
||||
int tolower(int c) {
|
||||
if (!isupper(c)) {
|
||||
return c;
|
||||
}
|
||||
|
||||
return c + 32;
|
||||
int islower(int c)
|
||||
{
|
||||
return (c >= 97 && c <= 122);
|
||||
}
|
||||
|
||||
int isdigit(int c) { return (c >= 48 && c <= 57); }
|
||||
int toupper(int c)
|
||||
{
|
||||
if (!islower(c)) {
|
||||
return c;
|
||||
}
|
||||
|
||||
int isalpha(int c) { return (c >= 65 && c <= 90) || (c >= 97 && c <= 122); }
|
||||
|
||||
int isalnum(int c) { return isalpha(c) | isdigit(c); }
|
||||
|
||||
int iscntrl(int c) { return (c <= 31) || (c == 127); }
|
||||
|
||||
int isprint(int c) { return (c >= 32 && c <= 126) || (c >= 128 && c <= 254); }
|
||||
|
||||
int isgraph(int c) { return isprint(c) && c != 32; }
|
||||
|
||||
int ispunct(int c) { return isgraph(c) && !isalnum(c); }
|
||||
|
||||
int isspace(int c) {
|
||||
return (c == ' ') || (c == '\t') || (c == '\n') || (c == '\v') ||
|
||||
(c == '\f') || (c == '\r');
|
||||
return c - 32;
|
||||
}
|
||||
|
||||
int isxdigit(int c) {
|
||||
return isdigit(c) || (c >= 65 && c <= 70) || (c >= 97 && c <= 102);
|
||||
int tolower(int c)
|
||||
{
|
||||
if (!isupper(c)) {
|
||||
return c;
|
||||
}
|
||||
|
||||
return c + 32;
|
||||
}
|
||||
|
||||
bool fill_random(unsigned char *buffer, unsigned int size) {
|
||||
if (!buffer || !size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
uint32_t next = random_seed;
|
||||
uint32_t result;
|
||||
|
||||
next *= 1103515245;
|
||||
next += 12345;
|
||||
result = (uint32_t)(next / 65536) % 2048;
|
||||
|
||||
next *= 1103515245;
|
||||
next += 12345;
|
||||
result <<= 10;
|
||||
result ^= (uint32_t)(next / 65536) % 1024;
|
||||
|
||||
next *= 1103515245;
|
||||
next += 12345;
|
||||
result <<= 10;
|
||||
result ^= (uint32_t)(next / 65536) % 1024;
|
||||
random_seed = next;
|
||||
|
||||
buffer[i] = (uint8_t)(result % 256);
|
||||
}
|
||||
|
||||
return true;
|
||||
int isdigit(int c)
|
||||
{
|
||||
return (c >= 48 && c <= 57);
|
||||
}
|
||||
|
||||
int isalpha(int c)
|
||||
{
|
||||
return (c >= 65 && c <= 90) || (c >= 97 && c <= 122);
|
||||
}
|
||||
|
||||
int isalnum(int c)
|
||||
{
|
||||
return isalpha(c) | isdigit(c);
|
||||
}
|
||||
|
||||
int iscntrl(int c)
|
||||
{
|
||||
return (c <= 31) || (c == 127);
|
||||
}
|
||||
|
||||
int isprint(int c)
|
||||
{
|
||||
return (c >= 32 && c <= 126) || (c >= 128 && c <= 254);
|
||||
}
|
||||
|
||||
int isgraph(int c)
|
||||
{
|
||||
return isprint(c) && c != 32;
|
||||
}
|
||||
|
||||
int ispunct(int c)
|
||||
{
|
||||
return isgraph(c) && !isalnum(c);
|
||||
}
|
||||
|
||||
int isspace(int c)
|
||||
{
|
||||
return (c == ' ') || (c == '\t') || (c == '\n') || (c == '\v')
|
||||
|| (c == '\f') || (c == '\r');
|
||||
}
|
||||
|
||||
int isxdigit(int c)
|
||||
{
|
||||
return isdigit(c) || (c >= 65 && c <= 70) || (c >= 97 && c <= 102);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user