#!/bin/gawk -f
# usage: echo "driver name" | vcdb

BEGIN { 
        database="/usr/share/alterator-x11/videocards";
        FS = ":"; 
       	OFS="\t";

	OPT_SEPARATOR="\t";
	ARGV[ARGC++] = database;
	ARGV[ARGC++] = "-";
       }


/^[a-z]+/   { 
		if (FILENAME == "-")
		{
			if (current[$0])
				print current[$0,"priority"],
				      $0,
				      current[$0,"description"],
				      current[$0,"depth"],
					  current[$0,"dlist"],
					  current[$0,"options"];
			else
				print 0,
				      $0,
				      $0,
				      16,
				      "";
		}
		else
		{
			driver=$0;
			current[$0] = $0;
			current[$0,"priority"] = 0;
			current[$0,"description"] = $0;
			current[$0,"depth"] = 16;
			current[$0,"options"] = "";
			current[$0,"dlist"]= "8 16 24";
		}
            }

/^+priority/ {  current[driver,"priority"]=$2; }
/^+description/ { current[driver,"description"]=$2; }
/^+depth/ { current[driver,"depth"]=$2; }
/^+dlist/ { current[driver,"dlist"]=$2; }
/^+option/ { current[driver,"options"]=current[driver,"options"] OPT_SEPARATOR $2; }
