Pythonify main()

This commit is contained in:
Samuel Sloniker 2021-08-18 13:44:50 -07:00
parent c907d10c6a
commit 8f500085dc
2 changed files with 9 additions and 13 deletions

13
worm.c
View File

@ -87,7 +87,6 @@ char outbuf[BUFSIZ];
void crash(void) __attribute__((__noreturn__)); void crash(void) __attribute__((__noreturn__));
void display(const struct body *, char); void display(const struct body *, char);
int main(int, char **);
int run_size(int); int run_size(int);
int run_worm(); int run_worm();
void leave(int) __attribute__((__noreturn__)); void leave(int) __attribute__((__noreturn__));
@ -99,18 +98,6 @@ int rnd(int);
void setup(void); void setup(void);
void wake(int); void wake(int);
int main(int argc, char **argv) {
if (argc == 2)
run_size(atoi(argv[1]));
if ((start_len <= 0) || (start_len > ((LINES-3) * (COLS-2)) / 3))
run_size(LENGTH);
int retval = run_worm();
return retval;
}
int run_size(int sl) { int run_size(int sl) {
start_len = sl; start_len = sl;
run_worm(); run_worm();

9
worm.py Normal file
View File

@ -0,0 +1,9 @@
import ctypes
import sys
worm = ctypes.cdll.LoadLibrary('./libworm.so')
if len(sys.argv) == 2:
worm.run_size(int(sys.argv[1]))
else:
worm.run_size(10)