/**
 * @file interface.h
 *
 * @brief Service Placement interface (header).
 *
 * Copyright 2007-2008, Freie Universitaet Berlin. All rights reserved.
 * Please refer to the COPYING file for detailed licensing information.
 *
 * @author Georg Wittenburg
 *
 * $Id: interface.h 2685 2008-06-25 16:38:56Z wittenbu $
 */

#ifndef INTERFACE_H
#define INTERFACE_H

#include <stdarg.h>

#include "types.h"

// Interface functions to be called by underlying system.
void C_init();
void C_start();
void C_stop();
void C_finalize();
void C_recv(const packet_header_t* header, const void* payload);
void C_execute_callback();
bool C_command(int argc, const char*const* argv);

// Wrappers around functions provided by the underlying system.
void C_vprintf(const char *format, va_list ap);
double C_random(double max);
C_time_t C_time();
void C_send(const packet_header_t* header, const void* payload);
void C_activate_callback(C_time_t time);

// Functions provided by the underlying system.

/**
 * @brief Platform specific low-level output function.
 *
 * @param format Format string.
 * @param ap Variable length argument structure.
 */
void __C_vprintf(const char *format, va_list ap);

/**
 * @brief Platform specific low-level random function.
 *
 * @param max Maximal value.
 * @return Random value between 0 and max.
 */
double __C_random(double max);

/**
 * @brief Platform specific low-level time function.
 *
 * @return Current time.
 */
C_time_t __C_time();

/**
 * @brief Platform specific low-level send function.
 *
 * @param header Header of packet to send.
 * @param payload Payload of packet to send.
 */
void __C_send(const packet_header_t* header, const void* payload);

/**
 * @brief Platform specific low-level callback activation function.
 *
 * @param time Time at which the next callback needs to be activated.
 */
void __C_activate_callback(C_time_t time);

#endif	// INTERFACE_H
