diff options
Diffstat (limited to 'lib/control.sh')
-rw-r--r-- | lib/control.sh | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/control.sh b/lib/control.sh index da48313..0bdf77c 100644 --- a/lib/control.sh +++ b/lib/control.sh @@ -61,6 +61,7 @@ _ob_parse_control_error() ## without verifying that all required fields were found. ## @operand file req The control file to parse, or "-" for standard input. ## @operand field_cb req Callback to run for each field. +## @operand user_data req Data to pass to \fIfield_cb\fP. ## @operand req_fields opt Required fields that must appear in the control file. ## @operand opt_fields opt Optional fields that may appear in the control file. ## @return Returns 0 after parsing, or 125 if called with an incorrect number of @@ -73,6 +74,7 @@ ob_parse_control() { local file= local field_cb= + local user_data= local req_fields= local opt_fields= local check_fields= @@ -83,15 +85,17 @@ ob_parse_control() local name= local value= - if [ ${#} -eq 2 ]; then + if [ ${#} -eq 3 ]; then file="${1}" field_cb="${2}" + user_data="${3}" check_fields='false' - elif [ ${#} -eq 4 ]; then + elif [ ${#} -eq 5 ]; then file="${1}" field_cb="${2}" - req_fields="${3}" - opt_fields="${4}" + user_data="${3}" + req_fields="${4}" + opt_fields="${5}" check_fields='true' all_fields=" ${req_fields} ${opt_fields} " else @@ -113,7 +117,7 @@ ob_parse_control() ;; [!\ ]*':'*) # "Name: Value" line. if [ -n "${name}" ]; then - "${field_cb}" "${name}" "${value}" + "${field_cb}" "${name}" "${value}" "${user_data}" if [ ${?} -ne 0 ]; then return 0 fi @@ -165,7 +169,7 @@ ${line# }" EOF if [ -n "${name}" ]; then - "${field_cb}" "${name}" "${value}" + "${field_cb}" "${name}" "${value}" "${user_data}" if [ ${?} -ne 0 ]; then return 0 fi |