1/* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License as 4 * published by the Free Software Foundation; either version 2 of 5 * the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software 14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 15 * MA 02111-1307 USA 16 */ 17/* 18 Copyright 2001, ASUSTeK Inc. 19 All Rights Reserved. 20 21 This is UNPUBLISHED PROPRIETARY SOURCE CODE of ASUSTeK Inc.; 22 the contents of this file may not be disclosed to third parties, copied or 23 duplicated in any form, in whole or in part, without the prior written 24 permission of ASUSTeK Inc.. 25*/ 26/* 27 * NVRAM variable manipulation 28 * 29 * Copyright (C) 2001 ASUSTeK Inc. 30 * 31 * $Id: bcmnvram_f.h,v 1.1 2007/06/08 10:20:42 arthur Exp $ 32 */ 33 34#ifndef _bcmnvram_f_h_ 35#define _bcmnvram_f_h_ 36 37#ifndef _LANGUAGE_ASSEMBLY 38 39 40extern char * nvram_get_x(const char *sid, const char *name); 41extern char * nvram_get_f(const char *file, const char *field); 42 43/* 44 * Get the value of an NVRAM variable 45 * @param name name of variable to get 46 * @return value of variable or NUL if undefined 47 */ 48/*#define nvram_safe_get(name) (nvram_get(name) ? : "")*/ 49#define nvram_safe_get_x(sid, name) (nvram_get_x(sid, name) ? : "") 50#define nvram_safe_get_f(file, field) (nvram_get_f(file, field) ? : "") 51 52/* 53 * Match an NVRAM variable 54 * @param name name of variable to match 55 * @param match value to compare against value of variable 56 * @return TRUE if variable is defined and its value is string equal to match or FALSE otherwise 57 */ 58#define nvram_match_x(sid, name, match) ({ const char *value = nvram_get_x(sid, name); (value && !strcmp(value, match)); }) 59 60 61/* 62 * Match an NVRAM variable 63 * @param name name of variable to match 64 * @param match value to compare against value of variable 65 * @return TRUE if variable is defined and its value is string equal to match or FALSE otherwise 66 */ 67#define nvram_match_list_x(sid, name, match, index) ({ const char *value = nvram_get_list_x(sid, name, index); (value && !strcmp(value, match)); }) 68 69/* 70 * Match an NVRAM variable 71 * @param name name of variable to match 72 * @param match value to compare against value of variable 73 * @return TRUE if variable is defined and its value is not string equal to invmatch or FALSE otherwise 74 */ 75#define nvram_invmatch_x(sid, name, invmatch) ({ const char *value = nvram_get_x(sid, name); (value && strcmp(value, invmatch)); }) 76 77 78/* 79 * Set the value of an NVRAM variable 80 * @param name name of variable to set 81 * @param value value of variable 82 * @return 0 on success and errno on failure 83 * NOTE: use nvram_commit to commit this change to flash. 84 */ 85extern int nvram_set_x(const char *sid, const char *name, const char *value); 86extern int nvram_set_f(const char *file, const char *field, const char *value); 87 88/* 89 * Get all NVRAM variables (format name=value\0 ... \0\0) 90 * @param buf buffer to store variables 91 * @param count size of buffer in bytes 92 * @return 0 on success and errno on failure 93 */ 94extern int nvram_getall_x(const char *sid); 95 96extern char *nvram_get_list_x(const char *sid, const char *name, int index); 97extern int nvram_add_list_x(const char *sid, const char *name, const char *value); 98extern int nvram_del_list_x(const char *sid, const char *name, int index); 99#endif /* _LANGUAGE_ASSEMBLY */ 100#endif /* _bcmnvram_f_h_ */ 101