Skip to content

Commit

Permalink
Cleaned up and fixed bf2c.fet
Browse files Browse the repository at this point in the history
  • Loading branch information
Property404 committed Aug 20, 2017
1 parent 76f745b commit faba1be
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 12 deletions.
3 changes: 0 additions & 3 deletions docs/c_reference/core.md
Expand Up @@ -17,7 +17,6 @@
`public void `[`read_file_to_chain`](#chain_8h_1a008ca35b36cfa01cebd59a6dddd79671)`(`[`Chain`](#struct_chain)` * chain,`[`Chain`](#struct_chain)` filename)` | Set chain contents to file's contents
`public int `[`compare_chains`](#chain_8h_1aebea70af9ccbc3d25da67b8f836dba3d)`(`[`Chain`](#struct_chain)` a,`[`Chain`](#struct_chain)` b)` | Compare chains
`public `[`Fraction`](#struct_fraction)` `[`chain_to_fraction`](#chain_8h_1ae351d3cf295fd95456e64cb1bb9216da)`(`[`Chain`](#struct_chain)` chain)` | Convert chain to fraction
`public FILE * `[`open_file_as_stream`](#chain_8h_1a4bea31562c5e8ea9a9dbaece1203119f)`(`[`Chain`](#struct_chain)` filename,const char * mode)` |
`public void `[`runtime_error`](#error_8h_1aa4581c050961a458136ec8bdd556d5b5)`(const char * msg,...)` | Show error message and exit
`public `[`Fraction`](#struct_fraction)` `[`construct_fraction`](#fraction_8h_1affd36cedc3799420c2d6ddfbdbd81ddf)`(FractionInt num,FractionInt den)` | Construct [Fraction](#struct_fraction)
`public `[`Fraction`](#struct_fraction)` `[`random_fraction`](#fraction_8h_1aff0108be8808ee831aaac374030930b4)`()` | Get random fraction
Expand Down Expand Up @@ -197,8 +196,6 @@ Parse chain to convert to a fraction value. Return 0/1 if chain is invalid.
#### Returns
The fraction value of the chain

#### `public FILE * `[`open_file_as_stream`](#chain_8h_1a4bea31562c5e8ea9a9dbaece1203119f)`(`[`Chain`](#struct_chain)` filename,const char * mode)`

#### `public void `[`runtime_error`](#error_8h_1aa4581c050961a458136ec8bdd556d5b5)`(const char * msg,...)`

Show error message and exit
Expand Down
11 changes: 10 additions & 1 deletion docs/c_reference/obedience.md
Expand Up @@ -4,7 +4,7 @@
--------------------------------|---------------------------------------------
`public void `[`write_chain_to_file`](#fileio_8h_1a897accbfb97acae9ff091b3dc13921c2)`(Chain chain,Chain filename)` | Set file contents to chain's contents
`public void `[`read_file_to_chain`](#fileio_8h_1a008ca35b36cfa01cebd59a6dddd79671)`(Chain * chain,Chain filename)` | Set chain contents to file's contents
`public FILE * `[`open_file_as_stream`](#fileio_8h_1a4bea31562c5e8ea9a9dbaece1203119f)`(Chain filename,const char * mode)` |
`public FILE * `[`open_file_as_stream`](#fileio_8h_1a4bea31562c5e8ea9a9dbaece1203119f)`(Chain filename,const char * mode)` | Open file as a stream

## Members

Expand Down Expand Up @@ -32,4 +32,13 @@ Open a file and read its contents to the chain's, replacing any previous values(

#### `public FILE * `[`open_file_as_stream`](#fileio_8h_1a4bea31562c5e8ea9a9dbaece1203119f)`(Chain filename,const char * mode)`

Open file as a stream

Use a filename encoded in a chain to return a stream pointing to a file of that name, with a particular mode.

#### Parameters
* `filename` A chain holding the filename of the file we're opening

* `mode` The fopen mode

Generated by [Moxygen](https://sourcey.com/moxygen)
5 changes: 3 additions & 2 deletions examples/bf2c.fet
Expand Up @@ -29,8 +29,9 @@ Bind Thomas to Saint Andrew's Cross
lick Carrie's toes
make Charlie moan

(I have a fetish for obedience)
Lick Trisha's gums two times
have Earl fist Faith
have Earl demand obedience of Faith
if Carrie is submissive to Trisha
make Dungeon Master moan "No input file\nUsage: "
make Dungeon Master moan Earl's name
Expand All @@ -39,7 +40,7 @@ if Carrie is submissive to Trisha

( Now we have to get the source code of the file)
( Sonya - the source code)
have Faith fist Sonya
have Faith demand obedience of Sonya

make slave scream "#include <stdio.h>\nint main(){char array[3000]={0};\nchar* pointer = array;"
lick Ada's feet forty three times
Expand Down
2 changes: 0 additions & 2 deletions fetishes/core/include/chain.h
Expand Up @@ -171,8 +171,6 @@ int compare_chains(Chain a, Chain b);
*/
Fraction chain_to_fraction(Chain chain);

// Experimental
FILE* open_file_as_stream(Chain filename, const char* mode);
#ifdef __cplusplus
}
#endif
Expand Down
1 change: 0 additions & 1 deletion fetishes/core/source/chain.c
Expand Up @@ -3,7 +3,6 @@
#include "core/include/fraction_math.h"
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <tgmath.h>
#include <unistd.h>
Expand Down
2 changes: 1 addition & 1 deletion fetishes/core/tests/chain.cpp
Expand Up @@ -2,7 +2,7 @@
#include "core/include/chain.h"
#include "FileUtil.h"
#include <cstring>
TEST_CASE("Chain Test", "[chain]"){
TEST_CASE("Chain Test", "[chain][core]"){
const char*const sample_text = "A human has fallen from\n\t the surface world\n";
const char*const sample_text2 = "Mama's scary; Mama hates\t\nyou\n";
const char*const sample_text3 = "Welcome home, dear friends, how long we've all been waiting\n";
Expand Down
10 changes: 9 additions & 1 deletion fetishes/obedience/include/fileio.h
Expand Up @@ -29,7 +29,15 @@ void write_chain_to_file(Chain chain, Chain filename);
*/
void read_file_to_chain(Chain * chain, Chain filename);

// Experimental
/**
* Open file as a stream
*
* Use a filename encoded in a chain to return a stream pointing to a file of
* that name, with a particular mode.
*
* @param filename A chain holding the filename of the file we're opening
* @param mode The fopen mode
*/
FILE* open_file_as_stream(Chain filename, const char* mode);
#ifdef __cplusplus
}
Expand Down
1 change: 0 additions & 1 deletion fetishes/obedience/source/fileio.c
Expand Up @@ -3,7 +3,6 @@
#include "obedience/include/fileio.h"
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

void write_chain_to_file(Chain chain, Chain filename_as_chain)
{
Expand Down

0 comments on commit faba1be

Please sign in to comment.