⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 read_ini.awk

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 AWK
字号:
# $Header: /usr/cvsroot/target/src/wrn/wm/demo/lib/read_ini.awk,v 1.1.1.1 2001/11/05 17:48:41 tneale Exp $#################################################################################  *** Restricted Rights Legend ***##  The programs and information contained herein are licensed only#  pursuant to a license agreement that contains use, reverse#  engineering, disclosure, and other restrictions; accordingly, it#  is "Unpublished--all rights reserved under the applicable#  copyright laws".##  Use duplication, or disclosure by the Government is subject to#  restrictions as set forth in subparagraph (c)(1)(ii) of the Rights#  in Technical Data and Computer Licensed Programs clause of DFARS#  52.227 7013.##  Copyright 2000-2001 Wind River Systems, Inc.#  Copyright 1998 Integrated Systems, Inc.#  All rights reserved.##  *** Government Use ***##  The Licensed Programs and their documentation were developed at#  private expense and no part of them is in the public domain.##  The Licensed Programs are "Restricted Computer Software" as that#  term is defined in Clause 52.227-19 of the Federal Acquisition#  Regulations (FAR) and are "Commercial Computer Software" as that#  term is defined in Subpart 227.401 of the Department of Defense#  Federal Acquisition Regulation Supplement (DFARS).##  (i) If the licensed Programs are supplied to the Department of#      Defense (DoD), the Licensed Programs are classified as#      "Commercial Computer Software" and the Government is acquiring#      only "restricted rights" in the Licensed Programs and their#      documentation as that term is defined in Clause 52.227#      7013(c)(1) of the DFARS, and##  (ii) If the Licensed Programs are supplied to any unit or agency#      of the United States Government other than DoD, the#      Government's rights in the Licensed Programs and their#      documentation will be as defined in Clause 52.227-19(c)(2) of#      the FAR.################################################################################# AWK script to convert from one of the two formats that snark/lib/read_ini.c# knows how to read to the other format.## Ordinarily, the demo configuration routines in read_ini load configuration# data from a file called etc.ini.  However, this does not make a very good# demo on embedded systems where there is no filesystem, so these routines# can also be configured to load configuration information from a static array.# This is still not particularly efficient (if you want efficency, use the# real configuration APIs for the various Epilogue products), but it is fairly# to use and thus makes a reasonable demo.## Rather than having to maintain two sets of configuration files, you can write# configuration files in the normal etc.ini format and use this script to# convert them to the static array format that the snark demo package uses when# you've installed the SNARK_READ_INI_FROM_MEMORY configuration option.## This script is intended to be used only on well-formed etc.ini files.# It does not attempt to detect every possible format violation, and it# transcribes etc.ini comments to C comments without checking them for# possible nested C comments.  We do try to do appropriate quoting for# doublequote and backslash as supported by snark/lib/parse.c.BEGIN {  print "/*";  print " * Automatically generated file.  You may choose to modify this file";  print " * by hand, but beware of accidently overwriting it.";  print " */";  print "";  print "#include <common/h/config.h>";  print "#include <common/h/glue.h>";  print "#include <snark/h/read_ini.h>";  print "";  print "struct ini_table etc_ini_table[] = {";  print "";}END {  print "";  print "  { 0, 0 }";  print "};";}NF == 0 {			# blank line?  print "";  next;}$1 ~ /^;/ {			# comment?  printf "  /* %s */\n", $0;  next;}$1 ~ /^\[/ {			# section label?  sub(/^[ \t]*\[/, "");		# delete leading cruft  sub(/\][ \t]*$/, "");		# delete trailing cruft  printf "  { \"%s\", 0 },\n", $0;  next;}/=/ {				# variable?  eq_pos = match($0, "=");	# find delimiter  key = substr($0, 1, eq_pos - 1);  val = substr($0, eq_pos + 1);  sub(/^[ \t]+/, "", key);	# delete leading whitespace from key  sub(/[ \t]+$/, "", key);	# delete trailing whitespace from key  sub(/^[ \t]+/, "", val);	# delete leading whitespace from val  sub(/[ \t]+$/, "", val);	# delete trailing whitespace from val  gsub(/\\/, "\\\\", val);	# quote backslashes in val  gsub(/"/,  "\\\"", val);	# quote doublequotes in val  printf "  { \"%s\", \"%s\" },\n", key, val;  next;}{				# ???  printf "/* ???: %s */\n", $0;  next;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -