Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Coding style, the ultimate thread.

Name: Anonymous 2010-07-31 4:02

Language: C
Typedefs: foo_t
Functions: stuff_with_underscores()
Brackets: linux-style ('\n' before '{')

Language: C++
Typedefs for primtive types: foo_t
Class declarations: class FooBar ...
Functions: stuff_with_underscores()
Methods: stuff_with_underscores()
Brackets: linux-style ('\n' before '{')

Name: Anonymous 2010-07-31 13:55

anus.h:

#ifndef ANUS_H_
#define ANUS_H_
typedef struct Anus {
        int is_dilated;
        float relaxation_level;
        time_t time_inserted;
} Anus;

void anus_new(Anus *anus);
void anus_insert_buttplug(Anus *anus);
void anus_remove_buttplug(Anus *anus);
#endif


anus.c:

#include <time.h>
#include "anus.h"

// :TODO: If the buttplug is removed before the anus becomes dilated, the relaxation level should drop, taking into account the amount of time the buttplug was outside of the anus.

// The buttplug must remain inserted for 2 minutes for the anus to become dilated.
#define DILATION_TIME         120

void anus_new(Anus *anus) {
        anus->is_dilated = 0;
        anus->relaxation_level = 0.0f;
        anus->time_inserted = 0;
}


void anus_insert_buttplug(Anus *anus) {
        // :TODO: check to ensure that a buttplug has not already been inserted[i]![/i]
        anus->time_inserted = time(NULL);
}


void anus_remove_buttplug(Anus *anus) {
        time_t time_diff;
        if (anus->time_inserted) {
                time_diff = time(NULL) - anus->time_inserted;
                anus->relaxation_level += time_diff / DILATION_TIME;
                if (anus->relaxation_level >= 1.0) {
                        anus->is_dilated = 1;
                }
        } else {
                printf("There is no buttplug to remove!\n");
        }
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List