Skip to content

Commit d2eaadb

Browse files
committed
Kinda removed the libc dependency from libTabCon
I said "kinda" because the SHA1 library still uses it
1 parent d3d0602 commit d2eaadb

3 files changed

Lines changed: 18 additions & 19 deletions

File tree

src/libTabCon/tabCon.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@
2222
SOFTWARE.
2323
*/
2424

25-
#include <stdio.h>
26-
#include <string.h>
27-
2825
#include "sha1/sha1.h"
2926
#include "tabCon.h"
3027

3128
void tabCon_generate(
3229
tabCon_t *tabCon,
33-
const char *string
30+
const char *string,
31+
const int length
3432
) {
3533
unsigned char x, y, i;
3634

@@ -41,7 +39,7 @@ void tabCon_generate(
4139
SHA1Update(
4240
&context,
4341
(const unsigned char *)string,
44-
strlen(string)
42+
length
4543
);
4644
SHA1Final(tabCon->hash, &context);
4745

@@ -67,12 +65,4 @@ void tabCon_generate(
6765
tabCon->color[i - TABCON_PIXELS] = tabCon->hash[i];
6866
}
6967
return;
70-
}
71-
72-
void tabCon_printHash(const tabCon_t tabCon) {
73-
unsigned char i;
74-
for (i = 0; i < TABCON_LENGTH_HASH; i++) {
75-
printf("%02x", tabCon.hash[i]);
76-
}
77-
return;
7868
}

src/libTabCon/tabCon.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ typedef struct {
4040

4141
void tabCon_generate(
4242
tabCon_t *tabCon,
43-
const char *string
43+
const char *string,
44+
const int length
4445
);
4546

46-
void tabCon_printHash(const tabCon_t tabCon);
47-
4847
#endif

src/main.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ static inline char loadArgs(int argc, char *argv[]) {
127127
}
128128

129129
int main(int argc, char *argv[]) {
130+
unsigned char i;
131+
130132
printf(PROGRAM_NAME " v" PROGRAM_VERSION "\n");
131-
printf("Created by StevenSYS\n");
133+
printf("Created by StevenSYS - 2025\n");
132134

133135
printf("- Loading arguments\n");
134136

@@ -144,11 +146,19 @@ int main(int argc, char *argv[]) {
144146

145147
printf("- Generating TabCon\n");
146148

147-
tabCon_generate(&tabCon, hashString);
149+
tabCon_generate(
150+
&tabCon,
151+
hashString,
152+
strlen(hashString)
153+
);
148154

149155
printf("- Generated TabCon\n");
150156
printf("- Hash: \"");
151-
tabCon_printHash(tabCon);
157+
158+
for (i = 0; i < TABCON_LENGTH_HASH; i++) {
159+
printf("%02x", tabCon.hash[i]);
160+
}
161+
152162
printf("\"\n");
153163

154164
printf("- Making PPM file\n");

0 commit comments

Comments
 (0)