1/* 2 * Copyright (c) 2007, 2008, 2009, ETH Zurich. 3 * All rights reserved. 4 * 5 * This file is distributed under the terms in the attached LICENSE file. 6 * If you do not find this file, copies can be found by writing to: 7 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 8 */ 9 10#ifndef SKB_H_ 11#define SKB_H_ 12 13#include <stdint.h> /* for int32_t */ 14#include <sys/cdefs.h> /* for __BEGIN_DECLS, __END_DECLS */ 15 16__BEGIN_DECLS 17 18errval_t skb_client_connect(void); 19errval_t skb_evaluate(char *query, char **result, char **str_error, int32_t *int_error); 20errval_t skb_add_fact(char *fmt, ...) __attribute__((format(printf, 1, 2))); 21errval_t skb_set_memory_affinity(void); 22 23#define ELEMENT_NAME_BUF_SIZE 80 24 25struct list_parser_status { 26 char *s; 27 char *conv_ptr; 28 size_t len; 29 char element_name[ELEMENT_NAME_BUF_SIZE]; 30 int expected_conversions; 31 int element_len; 32}; 33 34int skb_read_error_code(void); 35char *skb_get_output(void); 36char *skb_get_error_output(void); 37char *skb_get_last_goal(void); 38errval_t skb_execute(char *goal); 39errval_t skb_execute_query(char *fmt, ...) __attribute__((format(printf, 1, 2))); 40errval_t skb_read_output_at(char *output, char *fmt, ...) __attribute__((format(scanf, 2, 3))); 41errval_t skb_vread_output_at(char *output, char *fmt, va_list va_l); 42errval_t skb_read_output(char *fmt, ...) __attribute__((format(scanf, 1, 2))); 43void skb_read_list_init_offset(struct list_parser_status *status, char *s, 44 int offset); 45void skb_read_list_init(struct list_parser_status *status); 46bool skb_read_list(struct list_parser_status *status, char *fmt, ...) 47 __attribute__((format(scanf, 2, 3))); 48 49__END_DECLS 50 51/** 52 * \brief Prints out a string, errval and SKB stdout/stderr 53 */ 54#define DEBUG_SKB_ERR(err, msg...) do { \ 55 debug_err(__FILE__, __func__, __LINE__, err, msg); \ 56 debug_printf("skb goal:%s\n", skb_get_last_goal()); \ 57 debug_printf("skb errcode:%d\n", skb_read_error_code()); \ 58 debug_printf("skb stdout:%s\n", skb_get_output()); \ 59 debug_printf("skb stderr:%s\n", skb_get_error_output()); \ 60} while (0) 61 62#define USER_PANIC_SKB_ERR(err, msg...) do { \ 63 debug_err(__FILE__, __func__, __LINE__, err, msg); \ 64 debug_printf("skb goal:%s\n", skb_get_last_goal()); \ 65 debug_printf("skb errcode:%d\n", skb_read_error_code()); \ 66 debug_printf("skb stdout:%s\n", skb_get_output()); \ 67 debug_printf("skb stderr:%s\n", skb_get_error_output()); \ 68 abort(); \ 69} while (0) 70 71#endif // SKB_H_ 72