Relipmoc
From C
Contents |
relipmoc
About relipmoc
relipmoc is an IRC bot written by bone. It attempts to compile and run a code snippet and provide the output.
Usage
It is invoked with its nick followed by a , or : character:
<user> relipmoc, int x = 2; int y = 2; printf("%d + %d = %d", x, y, x + y); <relipmoc> user, 2 + 2 = 4
<user> relipmoc: int main(void) { printf("Hello, world!"); return 0; } <relipmoc> user, Hello, world!
As you can see, an implicit main is provided if you do not provide one. Other functions can be supplied but, due to there being no way to provide a newline, additional preprocessor directives cannot. If you supply something that invokes one or more warnings or errors, the first diagnostic will be given instead of the output:
<user> relipmoc: int x; printf("%d\n", x); <relipmoc> user, warning: 'x' is used uninitialized in this function >>> printf("%d\n", x);
Details
Compiled with a mingw32 environment,
gcc -O2 -Wall -std=c99 -pedantic
By default, the following headers are included:
#include <assert.h> #include <ctype.h> #include <errno.h> #include <float.h> #include <limits.h> #include <math.h> #include <stdarg.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <complex.h> #include <inttypes.h> #include <wchar.h> #include <wctype.h> #include <stdbool.h> #include <signal.h>
The code is wrapped in int main(void) { /* code */ return 0;} unless a main function is detected in the input.
If any warnings are output, it prints the first warning instead of running the program.
Options
- [win32] adds windows.h to the list of includes
- [gnu89] adds io.h, fcntl.h, sys/stat.h, process.h to the list of includes.
- [basic] force the main() wrapper
- [full] no main() wrapper
- [nowarn] ignore warnings
Multiple options are separated by a bar e.g. [win32|gnu89]
-std=c99 -pedantic are omitted from the command line if win32 or gnu89 are specified.
Security
Certain system calls are disallowed and some resource limits, including running time, are in place.
./out is provided as a writable directory.
Please do not attempt to test/play with the bot in ##c, use #relipmoc instead. The bot can also be reached by private msg.