mirror of
https://github.com/fosslinux/live-bootstrap.git
synced 2026-03-11 22:05:23 +01:00
Add mes and mescc-tools-extra
mescc-tools-extra contains two important tools: - cp - chmod mes first builds itself from a mes 0.21 seed as used by guix, and then builds a mes 0.22 and then mes 0.22 using that created mes 0.22. It does /not/ use bootstrap.sh as we don't have a proper shell at this point, it has been manually adapted for kaem.
This commit is contained in:
parent
2706e07556
commit
649d7b68dc
1029 changed files with 120985 additions and 18 deletions
27
sysa/mescc-tools-extra/functions/file_print.c
Normal file
27
sysa/mescc-tools-extra/functions/file_print.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* Copyright (C) 2016 Jeremiah Orians
|
||||
* This file is part of mescc-tools.
|
||||
*
|
||||
* mescc-tools is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mescc-tools is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with mescc-tools. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include<stdio.h>
|
||||
// void fputc(char s, FILE* f);
|
||||
|
||||
void file_print(char* s, FILE* f)
|
||||
{
|
||||
while(0 != s[0])
|
||||
{
|
||||
fputc(s[0], f);
|
||||
s = s + 1;
|
||||
}
|
||||
}
|
||||
32
sysa/mescc-tools-extra/functions/in_set.c
Normal file
32
sysa/mescc-tools-extra/functions/in_set.c
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* Copyright (C) 2016 Jeremiah Orians
|
||||
* Copyright (C) 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* This file is part of mescc-tools.
|
||||
*
|
||||
* mescc-tools is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mescc-tools is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with mescc-tools. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define FALSE 0
|
||||
// CONSTANT FALSE 0
|
||||
#define TRUE 1
|
||||
// CONSTANT TRUE 1
|
||||
|
||||
int in_set(int c, char* s)
|
||||
{
|
||||
while(0 != s[0])
|
||||
{
|
||||
if(c == s[0]) return TRUE;
|
||||
s = s + 1;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
35
sysa/mescc-tools-extra/functions/match.c
Normal file
35
sysa/mescc-tools-extra/functions/match.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* Copyright (C) 2016 Jeremiah Orians
|
||||
* This file is part of mescc-tools.
|
||||
*
|
||||
* mescc-tools is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mescc-tools is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with mescc-tools. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define FALSE 0
|
||||
// CONSTANT FALSE 0
|
||||
#define TRUE 1
|
||||
// CONSTANT TRUE 1
|
||||
|
||||
int match(char* a, char* b)
|
||||
{
|
||||
int i = -1;
|
||||
do
|
||||
{
|
||||
i = i + 1;
|
||||
if(a[i] != b[i])
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
} while((0 != a[i]) && (0 !=b[i]));
|
||||
return TRUE;
|
||||
}
|
||||
170
sysa/mescc-tools-extra/functions/numerate_number.c
Normal file
170
sysa/mescc-tools-extra/functions/numerate_number.c
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
/* Copyright (C) 2016 Jeremiah Orians
|
||||
* This file is part of mescc-tools.
|
||||
*
|
||||
* mescc-tools is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mescc-tools is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with mescc-tools. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include<stdlib.h>
|
||||
// void* calloc(int count, int size);
|
||||
#define TRUE 1
|
||||
//CONSTANT TRUE 1
|
||||
#define FALSE 0
|
||||
//CONSTANT FALSE 0
|
||||
int in_set(int c, char* s);
|
||||
//CONSTANT NULL 0
|
||||
|
||||
char* numerate_number(int a)
|
||||
{
|
||||
char* result = calloc(16, sizeof(char));
|
||||
if(NULL == result) return NULL;
|
||||
|
||||
int i = 0;
|
||||
|
||||
/* Deal with Zero case */
|
||||
if(0 == a)
|
||||
{
|
||||
result[0] = '0';
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Deal with negatives */
|
||||
if(0 > a)
|
||||
{
|
||||
result[0] = '-';
|
||||
i = 1;
|
||||
a = a * -1;
|
||||
}
|
||||
|
||||
/* Using the largest 10^n number possible in 32bits */
|
||||
int divisor = 0x3B9ACA00;
|
||||
/* Skip leading Zeros */
|
||||
while(0 == (a / divisor)) divisor = divisor / 10;
|
||||
|
||||
/* Now simply collect numbers until divisor is gone */
|
||||
while(0 < divisor)
|
||||
{
|
||||
result[i] = ((a / divisor) + 48);
|
||||
a = a % divisor;
|
||||
divisor = divisor / 10;
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int char2hex(int c)
|
||||
{
|
||||
if (c >= '0' && c <= '9') return (c - 48);
|
||||
else if (c >= 'a' && c <= 'f') return (c - 87);
|
||||
else if (c >= 'A' && c <= 'F') return (c - 55);
|
||||
else return -1;
|
||||
}
|
||||
|
||||
int hex2char(int c)
|
||||
{
|
||||
if((c >= 0) && (c <= 9)) return (c + 48);
|
||||
else if((c >= 10) && (c <= 15)) return (c + 55);
|
||||
else return -1;
|
||||
}
|
||||
|
||||
int char2dec(int c)
|
||||
{
|
||||
if (c >= '0' && c <= '9') return (c - 48);
|
||||
else return -1;
|
||||
}
|
||||
|
||||
int dec2char(int c)
|
||||
{
|
||||
if((c >= 0) && (c <= 9)) return (c + 48);
|
||||
else return -1;
|
||||
}
|
||||
|
||||
int index_number(char* s, char c)
|
||||
{
|
||||
int i = 0;
|
||||
while(s[i] != c)
|
||||
{
|
||||
i = i + 1;
|
||||
if(0 == s[i]) return -1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
int toupper(int c)
|
||||
{
|
||||
if(in_set(c, "abcdefghijklmnopqrstuvwxyz")) return (c & 0xDF);
|
||||
return c;
|
||||
}
|
||||
|
||||
int set_reader(char* set, int mult, char* input)
|
||||
{
|
||||
int n = 0;
|
||||
int i = 0;
|
||||
int hold;
|
||||
int negative_p = FALSE;
|
||||
|
||||
if(input[0] == '-')
|
||||
{
|
||||
negative_p = TRUE;
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
while(in_set(input[i], set))
|
||||
{
|
||||
n = n * mult;
|
||||
hold = index_number(set, toupper(input[i]));
|
||||
|
||||
/* Input managed to change between in_set and index_number */
|
||||
if(-1 == hold) return 0;
|
||||
n = n + hold;
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
/* loop exited before NULL and thus invalid input */
|
||||
if(0 != input[i]) return 0;
|
||||
|
||||
if(negative_p)
|
||||
{
|
||||
n = 0 - n;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
int numerate_string(char *a)
|
||||
{
|
||||
/* If NULL string */
|
||||
if(0 == a[0]) return 0;
|
||||
|
||||
/* Deal with binary*/
|
||||
else if ('0' == a[0] && 'b' == a[1])
|
||||
{
|
||||
return set_reader("01", 2, a+2);
|
||||
}
|
||||
/* Deal with hex */
|
||||
else if ('0' == a[0] && 'x' == a[1])
|
||||
{
|
||||
return set_reader("0123456789ABCDEFabcdef", 16, a+2);
|
||||
}
|
||||
/* Deal with octal */
|
||||
else if('0' == a[0])
|
||||
{
|
||||
return set_reader("01234567", 8, a+1);
|
||||
}
|
||||
/* Deal with decimal */
|
||||
else
|
||||
{
|
||||
return set_reader("0123456789", 10, a);
|
||||
}
|
||||
}
|
||||
31
sysa/mescc-tools-extra/functions/require.c
Normal file
31
sysa/mescc-tools-extra/functions/require.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* Copyright (C) 2016 Jeremiah Orians
|
||||
* Copyright (C) 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* This file is part of mescc-tools.
|
||||
*
|
||||
* mescc-tools is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mescc-tools is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with mescc-tools. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
void file_print(char* s, FILE* f);
|
||||
|
||||
void require(int bool, char* error)
|
||||
{
|
||||
if(!bool)
|
||||
{
|
||||
file_print(error, stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
70
sysa/mescc-tools-extra/functions/string.c
Normal file
70
sysa/mescc-tools-extra/functions/string.c
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/* Copyright (C) 2016 Jeremiah Orians
|
||||
* This file is part of mescc-tools.
|
||||
*
|
||||
* mescc-tools is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mescc-tools is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with mescc-tools. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
#define MAX_STRING 4096
|
||||
//CONSTANT MAX_STRING 4096
|
||||
// void* calloc(int count, int size);
|
||||
void file_print(char* s, FILE* f);
|
||||
|
||||
char* copy_string(char* target, char* source)
|
||||
{
|
||||
while(0 != source[0])
|
||||
{
|
||||
target[0] = source[0];
|
||||
target = target + 1;
|
||||
source = source + 1;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
char* postpend_char(char* s, char a)
|
||||
{
|
||||
char* ret = calloc(MAX_STRING, sizeof(char));
|
||||
if(NULL == ret) return NULL;
|
||||
|
||||
char* hold = copy_string(ret, s);
|
||||
hold[0] = a;
|
||||
return ret;
|
||||
}
|
||||
|
||||
char* prepend_char(char a, char* s)
|
||||
{
|
||||
char* ret = calloc(MAX_STRING, sizeof(char));
|
||||
if(NULL == ret) return NULL;
|
||||
|
||||
ret[0] = a;
|
||||
copy_string((ret+1), s);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char* prepend_string(char* add, char* base)
|
||||
{
|
||||
char* ret = calloc(MAX_STRING, sizeof(char));
|
||||
if(NULL == ret) return NULL;
|
||||
|
||||
copy_string(copy_string(ret, add), base);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int string_length(char* a)
|
||||
{
|
||||
int i = 0;
|
||||
while(0 != a[i]) i = i + 1;
|
||||
return i;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue