-
-
Save 413x1nkp/f0914877191466f3464bcda9dc333103 to your computer and use it in GitHub Desktop.
A forked qlock.c using linker embedding for the source code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**********************ld -r -b binary -o qlock.o qlock.c*********************/ | |
/*****************cc -w -include time.h -o out qlock.c qlock.o****************/ | |
extern char _binary_qlock_c_start[];x,y,d[8],i,dx;f[]={31599,19812,14479,31207,\ | |
23524,29411,29679,30866,31727,31719,1040};char*so,*si;p(ch){i=x/2/(3+1);dx=x/2\ | |
%(3+1);if(i<8&&(y-1)/2<5&&dx<3&&(f[d[i]]>>((5-(y-1)/2-1)*3+dx))&1)printf(/****/ | |
"\033[1;41;30m%c\033[0m",ch);else putchar(ch);if(ch=='\n'){y+=1;x=0;}else/****/ | |
x+=1;}gd(){time_t t=time(NULL);struct tm*tm=localtime(&t);d[0]=tm->tm_hour/10;\ | |
d[1]=tm->tm_hour%10;d[2]=10;d[3]=tm->tm_min/10;d[4]=tm->tm_min%10;d[5]=10;d[6]\ | |
=tm->tm_sec/10;d[7]=tm->tm_sec%10;}main(){for(gd();;printf("\n\033[%dA\033[%dD" | |
,y+1,x),sleep(1),gd())for(so=_binary_main_c_start,x=0,y=0;*so;so++)p(*so);}/*** | |
******************************************************************************/ |
my bad for not specifying. I already did the first step before trying to compile.
also, which gcc version are you using? mine only worked with the original code when I specified the
-std=c90
. also tried compiling your version with multiple C standards
My GCC specs:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/14.1.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.1.1 20240522 (GCC)
Not sure why You're having some issues, GCC should be able to automatically identify when and what STD version to use
EDIT: i'm an idiot. It should be main.c, not quine.c
I've used main.c as the filename locally, forgot to change the linker reference when i uploaded it to gist
so either rename quine.c to main.c OR change extern char _binary_main_c_start[];
to extern char _binary_quine_c_start[];
made a centered version:
/*ld -r -b binary -o q.o qlock.c && cc -w -include time.h qlock.c q.o -o q -std=c90*/
c[] = {40, 34, 44, 30}; /* bg_off fg_off bg_on fg_on */ l=9; /* left padding********/
extern char _binary_qlock_c_start[]; x, y, d[8], i, dx; f[] = {31599, 19812, 14479, \
31207, 23524, 29411, 29679, 30866, 31727, 31719, 1040}; char *s, *si; p(ch) { i = (x-
l) / 2 / (3 + 1); dx = (x - l) / 2 % 4; if (x > l-1 && i < 8 && (y-2) / 2 < 5 && dx <
3 && (f[d[i]] >> ((5 - (y - 2) / 2 - 1) *3+dx)) & 1) printf("\033[1;%d;%dm%c\033[0m",
c[2], c[3], ch); else printf("\33[%d;%dm%c", c[0], c[1], ch); if(ch == '\n'){ y += 1;
x = 0; printf("\33[0m"); } else x += 1; } gd() { time_t tm = time(NULL); struct tm *t
= localtime(&tm); d[0] = t->tm_hour / 10; d[1] = t->tm_hour % 10; d[2] = 10; d[3] = t
->tm_min /10; d[4] = t->tm_min % 10; d[5] = 10; d[6]=t->tm_sec / 10; d[7] = t->tm_sec
% 10; } main() { for (gd();; printf( "\n\033[%dA\033[%dD", y + 1, x), sleep(1), gd())
for (s = _binary_qlock_c_start, x = 0, y = 0; *s; s++) p(*s); } /********************
************************************************************************************/
made a centered version:
/*ld -r -b binary -o q.o qlock.c && cc -w -include time.h qlock.c q.o -o q -std=c90*/ c[] = {40, 34, 44, 30}; /* bg_off fg_off bg_on fg_on */ l=9; /* left padding********/ extern char _binary_qlock_c_start[]; x, y, d[8], i, dx; f[] = {31599, 19812, 14479, \ 31207, 23524, 29411, 29679, 30866, 31727, 31719, 1040}; char *s, *si; p(ch) { i = (x- l) / 2 / (3 + 1); dx = (x - l) / 2 % 4; if (x > l-1 && i < 8 && (y-2) / 2 < 5 && dx < 3 && (f[d[i]] >> ((5 - (y - 2) / 2 - 1) *3+dx)) & 1) printf("\033[1;%d;%dm%c\033[0m", c[2], c[3], ch); else printf("\33[%d;%dm%c", c[0], c[1], ch); if(ch == '\n'){ y += 1; x = 0; printf("\33[0m"); } else x += 1; } gd() { time_t tm = time(NULL); struct tm *t = localtime(&tm); d[0] = t->tm_hour / 10; d[1] = t->tm_hour % 10; d[2] = 10; d[3] = t ->tm_min /10; d[4] = t->tm_min % 10; d[5] = 10; d[6]=t->tm_sec / 10; d[7] = t->tm_sec % 10; } main() { for (gd();; printf( "\n\033[%dA\033[%dD", y + 1, x), sleep(1), gd()) for (s = _binary_qlock_c_start, x = 0, y = 0; *s; s++) p(*s); } /******************** ************************************************************************************/
Oooo, nice :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my bad for not specifying. I already did the first step before trying to compile.
also, which gcc version are you using? mine only worked with the original code when I specified the
-std=c90
. also tried compiling your version with multiple C standards