1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ 2 /* 3 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana 4 * University Research and Technology 5 * Corporation. All rights reserved. 6 * Copyright (c) 2004-2005 The University of Tennessee and The University 7 * of Tennessee Research Foundation. All rights 8 * reserved. 9 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 10 * University of Stuttgart. All rights reserved. 11 * Copyright (c) 2004-2005 The Regents of the University of California. 12 * All rights reserved. 13 * Copyright (c) 2018 Triad National Security, LLC. All rights 14 * reserved. 15 * $COPYRIGHT$ 16 * 17 * Additional copyrights may follow 18 * 19 * $HEADER$ 20 */ 21 22 /** @file */ 23 24 #ifndef OPAL_UTIL_KEYVAL_PARSE_H 25 #define OPAL_UTIL_KEYVAL_PARSE_H 26 27 #include "opal_config.h" 28 29 BEGIN_C_DECLS 30 31 extern int opal_util_keyval_parse_lineno; 32 33 /** 34 * Callback triggered for each key = value pair 35 * 36 * Callback triggered from opal_util_keyval_parse for each key = value 37 * pair. Both key and value will be pointers into static buffers. 38 * The buffers must not be free()ed and contents may be overwritten 39 * immediately after the callback returns. 40 */ 41 typedef void (*opal_keyval_parse_fn_t)(const char *key, const char *value); 42 43 /** 44 * Parse \c filename, made up of key = value pairs. 45 * 46 * Parse \c filename, made up of key = value pairs. For each line 47 * that appears to contain a key = value pair, \c callback will be 48 * called exactly once. In a multithreaded context, calls to 49 * opal_util_keyval_parse() will serialize multiple calls. 50 */ 51 OPAL_DECLSPEC int opal_util_keyval_parse(const char *filename, 52 opal_keyval_parse_fn_t callback); 53 54 OPAL_DECLSPEC int opal_util_keyval_parse_init(void); 55 56 OPAL_DECLSPEC int opal_util_keyval_save_internal_envars(opal_keyval_parse_fn_t callback); 57 58 END_C_DECLS 59 60 #endif