Adaugă codul complet al proiectului underchat-ircd
This commit is contained in:
1 parent
caba5224bf
commit
5fdc1cc27c
462 files changed
+164488
No files matched your search
@@ -0,0 +1,6 @@
|
||||
all:
|
||||
gcc -Wall -Werror sid2num.c -o sid2num
|
||||
gcc -Wall -Werror num2sid.c -o num2sid
|
||||
|
||||
clean:
|
||||
rm -f *.core sid2num num2sid
|
||||
@@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
char b64map[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789[]";
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int num = 0;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
printf("Syntax: %s <numeric>\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
num = atoi(argv[1]);
|
||||
|
||||
if ((num < 0) || (num > 4095)) {
|
||||
printf("Numeric must be between 0 and 4095\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("SID: %c%c\n", b64map[(int)(num >> 6)], b64map[(num & 0x3F)]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int b64map[] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 62, -1, 63, -1, -1,
|
||||
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 2)
|
||||
{
|
||||
printf("Syntax: %s <sid>\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((strlen(argv[1]) < 2) || (b64map[(int)argv[1][0]] < 0) || (b64map[(int)argv[1][1]] < 0))
|
||||
{
|
||||
printf("SID must be a 2 characters from A-Z, a-z, 0-9, [ or ]\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Numeric is: %d\n", ((b64map[(int)argv[1][0]] << 6) + b64map[(int)argv[1][1]]));
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user