#!/bin/sh

# Usage: gen_fallback app-defaults-file
#        Generates a list of fallback resources suitable for including
#        in the fallback resources array

# This shellscript just echos each line in the source file with a " at
# the beginning of the line, and a ", at the and of the line.

echo '/* fallback.h generated by gen_fallback from '$1' - do not edit! */'
echo ""
cat $1 | awk ' \
  BEGIN { first = 1 } \
  /\\$/ && first == 0 { printf("%s\n", $0); } \
  /\\$/ && first == 1 { first = 0; printf("\"%s\n", $0); } \
  $0 !~ /\\$/ && first == 1  { printf("\"%s\",\n", $0); } \
  $0 !~ /\\$/ && first == 0  { first = 1 ; printf("\",\n\"%s\",\n", $0); } \
  END  { printf("NULL\n"); }'
