Voxia OS v0.0.1
Hobby Project Operating System Targeting x86-64
Loading...
Searching...
No Matches
oct2bin.h
Go to the documentation of this file.
1#ifndef __LIBK__OCT2BIN_H__
2#define __LIBK__OCT2BIN_H__
3
4#include <type.h>
5
6__attribute__((noinline)) static uint64_t
7oct2bin(unsigned char* str, size_t len) {
8 uint64_t value = 0;
9
10 for (size_t i = 0; i < len; i++) {
11 unsigned char c = (unsigned char) str[i];
12
13 if (c == '\0' || c == ' ')
14 break;
15
16 if (c < '0' || c > '7')
17 break;
18
19 value = (value << 3) | (uint64_t) (c - '0');
20 }
21
22 return value;
23}
24
25#endif // __LIBK__OCT2BIN_H__
typedef __attribute__
Definition msi.c:47
size_t len
Definition oct2bin.h:7
return value
Definition oct2bin.h:22
kstring str(const char *str)
unsigned long uint64_t
Definition type.h:25