Index: /trunk/Ohana/src/opihi/cmd.data/init.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/init.c	(revision 16429)
+++ /trunk/Ohana/src/opihi/cmd.data/init.c	(revision 16430)
@@ -120,123 +120,123 @@
 
 static Command cmds[] = {  
-  {"accum",        accum,	     "accumulate vector values in another vector"},
-  {"applyfit",     applyfit,	     "apply fit to new vector"},
-  {"applyfit2d",   applyfit2d,	     "apply 2-d fit to new vector"},
-  {"box",     	   box,		     "draw a box on the plot"},
-  {"book",    	   book_command,     "commands to manipulate book/page/word data"},
-  {"center",       center,	     "center image on coords"},
-  {"circstats",    circstats,	     "circular statistics"},
-  {"clear",   	   clear,	     "erase plot"},
-  {"clip",         clip,	     "clip values in a buffer to be within a range"},
-  {"close",        close_device,     "close the current display device"},
-  {"concat",  	   concat,	     "reduce vector dimension"},
-  {"contour", 	   contour,	     "create contour from image"},
-  {"create",  	   create,	     "create a new vector"},
-  {"cumulative",   cumulative,	     "build a cumulative histogram from a specific histogram"},
-  {"cursor",  	   cursor,	     "get coords from cursor"},
-  {"cut",	   cut,		     "extract a cut across an image"},
-  {"datafile",     datafile,	     "define file to read vectors"},
-  {"dbconnect",    dbconnect,	     "setup mysql db connection"},
-  {"dbselect", 	   dbselect,	     "extract vectors from mysql database table"},
-  {"delete",  	   delete,	     "delete vectors or matrices"},
-  {"device",  	   device,	     "set / get current graphics device"},
-  {"dimendown",	   dimendown,	     "convert matrix to vector"},
-  {"dimenup",	   dimenup,	     "convert vector to matrix"},
-  {"erase",        erase,	     "erase objects on an overlay"},
-  {"extract",      extract,	     "extract a portion of a buffer into another buffer"},
-  {"fft1d",        fft1d,	     "fft on the pixel-stream in an image"},
-  {"fft2d",        fft2d,	     "fft on an image"},
-  {"fit",     	   fit,		     "fit polynomial to vector pair"},
-  {"fit2d",        fit2d,	     "fit 2-d polynomial to vector triplet"},
-  {"gaussj",  	   gaussjordan,	     "solve Ax = B (N-D)"},
-  {"gaussdev",	   gaussdeviate,     "generate a gaussian deviate vector"},
-  {"gaussint",	   gaussintegral,    "return the integrated gaussian vector"},
-  {"grid",    	   grid,	     "plot cartesian grid"},
-  {"gridify",      gridify,	     "convert vector triplet to buffer"},
-  {"grow",    	   grow,	     "grow a mask"},
-  {"ungridify",    ungridify,        "convert buffer region to vector triplet"},
-  {"header",       header,	     "print buffer header"},
-  {"histogram",    histogram,	     "generate histogram from vector"},
-  {"imcut",        imcut,	     "linear image cut between arbitrary coords"},
-  {"imhist",       imhist,	     "histogram of an image region"},
-  {"imsmooth",     imsmooth,	     "circular gaussian smoothing"},
-  {"integrate",    integrate,	     "integrate a vector"},
-  {"interpolate",  interpolate,	     "interpolate between vector pairs"},
-  {"jpeg",         jpeg,	     "write text line on graph"},
-  {"png",          jpeg,	     "write text line on graph"},
-  {"ppm",          jpeg,	     "write text line on graph"},
-  {"kern",         kern,	     "convolve with 3x3 kernel"},
-  {"keyword",      keyword,	     "extract a FITS keyword from buffer header"},
-  {"labels",  	   labels,	     "define labels for plot"},
-  {"limits",  	   limits,	     "define plot limits"},
-  {"line",         line,	     "plot line"},
-  {"buffers",      list_buffers,     "list the currently allocated buffers"},
-  {"vectors", 	   list_vectors,     "list vectors"},
-  {"load",         load,	     "load an SAOimage style overlay"},
-  {"lookup",       lookup,	     "convert vector via lookup table (vector pair)"},
-  {"mkrgb", 	   mkrgb,	     "convert 3 images to rgb jpeg"},
-  {"mcreate", 	   mcreate,	     "create a matrix"},
-  {"medacc",       medacc,	     "accumulate vector values in another vector"},
-  {"mget",    	   mget,	     "extract a vector from a matrix"},
-  {"minterp",      minterp,	     "interpolate image pixels"},
-  {"mset",    	   mset,	     "insert a vector in a matrix"},
-  {"peak",	   peak,	     "find vector peak in range"},
-  {"periodogram",  periodogram,	     "measure periods in unevenly sampled data"},
-  {"plot",    	   plot,	     "plot a pair of vectors"},
-  {"dot",    	   dot,	             "plot a single point"},
-  {"point",	   point,	     "load overlay with single point"},
-  {"ps",      	   ps,		     "define labels for plot"},
-  {"queuepop", 	   queuepop,	     "pop value from queue to variable"},
-  {"queuedrop",    queuedrop,	     "drop values from queue matching a key"},
-  {"queueprint",   queueprint,	     "print the contents of a queue"},
-  {"queuepush",	   queuepush,	     "push value onto queue"},
-  {"queueinit",	   queueinit,	     "create an empty queue"},
-  {"queuedelete",  queuedelete,	     "delete a queue"},
-  {"queuelist",	   queuelist,	     "list defined queues"},
-  {"queueload",	   queueload,	     "load queue from command"},
-  {"queuesize",    queuesize,	     "show queue size"},
-  {"rd",           rd,		     "load fits image"},
-  {"rdseg",	   rdseg,	     "read a segment of an image from a file"},
-  {"read",         read_vectors,     "read vectors from datafile"},
-  {"rebin",	   rebin,	     "rebin data by factor of N"},
-  {"resize",  	   resize,	     "set graphics/image window size"},
-  {"roll",	   roll,	     "roll image to new start point"},
-  {"rotate",	   rotate,	     "rotate image"},
-  {"save",	   save,	     "save an SAOimage style overlay"},
-  {"section", 	   section,	     "define section of graph"},
-  {"set",     	   set,		     "vector math"},
-  {"shift",	   shift,	     "shift data in an image"},
-  {"sort",    	   sort_vectors,     "sort list of vectors"},
-  {"spline.apply", spline_apply_cmd, "apply spline fit to generate an image"},
-  {"spline.const", spline_construct_cmd, "create spline 2nd deriv. terms"},
-  {"stats",   	   stats,	     "give statistics on a portion of a buffer"},
-  {"style",   	   style,	     "set the style for graph plots"},
-  {"subraster",    subraster,	     "subraster of fits image"},
-  {"subset",  	   subset,	     "expand vector dimension"},
-  {"svd",	   svd,		     "singular value decomposition of a matrix"},
-  {"swapbytes",	   swapbytes,        "byte swap thing"},
-  {"textline",     textline,	     "write text line on graph"},
-  {"tv",      	   tv,		     "display an image on the Kii window"},
-  {"tvchannel",	   tvchannel,	     "set the current tv channel"},
-  {"tvcolors",	   tvcolors,	     "set the tv colormap"},
-  {"tvcontour",	   tvcontour,	     "send contour to overlay"},
-  {"tvgrid",	   tvgrid,	     "wait until return is typed"},
-  {"uniq",    	   uniq,	     "create a uniq vector subset from a vector"},
-  {"unsign",	   unsign,	     "toggle the UNSIGN status"},
-  {"vbin",	   vbin,	     "bin values in a vector to be within a range"},
-  {"vclip",	   vclip,	     "clip values in a vector to be within a range"},
-  {"select",	   vect_select,	     "selective vector assignment"},
-  {"vgauss",       vgauss,	     ""},
-  {"vmaxwell",     vmaxwell,	     ""},
-  {"vgrid",        vgrid,	     ""},
-  {"vload",        vload,	     "load vectors on Kii"},
-  {"vstat",        vstat,	     "get info from imreg database"},
-  {"vsmooth",      vsmooth,	     "gaussian smooth of a vector"},
-  {"vroll",        vroll,	     "roll vector elements"},
-  {"vpop",         vpop, 	     "remove first element"},
-  {"wd",      	   wd,		     "write an image to a file"},
-  {"write",   	   write_vectors,    "write vectors to datafile"},
-  {"zap",     	   zap,		     "delete pixels"},
-  {"zplot",   	   zplot,	     "plot x y with size scaled by z"},
+  {1, "accum",        accum,            "accumulate vector values in another vector"},
+  {1, "applyfit",     applyfit,         "apply fit to new vector"},
+  {1, "applyfit2d",   applyfit2d,       "apply 2-d fit to new vector"},
+  {1, "box",          box,              "draw a box on the plot"},
+  {1, "book",         book_command,     "commands to manipulate book/page/word data"},
+  {1, "center",       center,           "center image on coords"},
+  {1, "circstats",    circstats,        "circular statistics"},
+  {1, "clear",        clear,            "erase plot"},
+  {1, "clip",         clip,             "clip values in a buffer to be within a range"},
+  {1, "close",        close_device,     "close the current display device"},
+  {1, "concat",       concat,           "reduce vector dimension"},
+  {1, "contour",      contour,          "create contour from image"},
+  {1, "create",       create,           "create a new vector"},
+  {1, "cumulative",   cumulative,       "build a cumulative histogram from a specific histogram"},
+  {1, "cursor",       cursor,           "get coords from cursor"},
+  {1, "cut",          cut,              "extract a cut across an image"},
+  {1, "datafile",     datafile,         "define file to read vectors"},
+  {1, "dbconnect",    dbconnect,        "setup mysql db connection"},
+  {1, "dbselect",     dbselect,         "extract vectors from mysql database table"},
+  {1, "delete",       delete,           "delete vectors or matrices"},
+  {1, "device",       device,           "set / get current graphics device"},
+  {1, "dimendown",    dimendown,        "convert matrix to vector"},
+  {1, "dimenup",      dimenup,          "convert vector to matrix"},
+  {1, "erase",        erase,            "erase objects on an overlay"},
+  {1, "extract",      extract,          "extract a portion of a buffer into another buffer"},
+  {1, "fft1d",        fft1d,            "fft on the pixel-stream in an image"},
+  {1, "fft2d",        fft2d,            "fft on an image"},
+  {1, "fit",          fit,              "fit polynomial to vector pair"},
+  {1, "fit2d",        fit2d,            "fit 2-d polynomial to vector triplet"},
+  {1, "gaussj",       gaussjordan,      "solve Ax = B (N-D)"},
+  {1, "gaussdev",     gaussdeviate,     "generate a gaussian deviate vector"},
+  {1, "gaussint",     gaussintegral,    "return the integrated gaussian vector"},
+  {1, "grid",         grid,             "plot cartesian grid"},
+  {1, "gridify",      gridify,          "convert vector triplet to buffer"},
+  {1, "grow",         grow,             "grow a mask"},
+  {1, "ungridify",    ungridify,        "convert buffer region to vector triplet"},
+  {1, "header",       header,           "print buffer header"},
+  {1, "histogram",    histogram,        "generate histogram from vector"},
+  {1, "imcut",        imcut,            "linear image cut between arbitrary coords"},
+  {1, "imhist",       imhist,           "histogram of an image region"},
+  {1, "imsmooth",     imsmooth,         "circular gaussian smoothing"},
+  {1, "integrate",    integrate,        "integrate a vector"},
+  {1, "interpolate",  interpolate,      "interpolate between vector pairs"},
+  {1, "jpeg",         jpeg,             "write text line on graph"},
+  {1, "png",          jpeg,             "write text line on graph"},
+  {1, "ppm",          jpeg,             "write text line on graph"},
+  {1, "kern",         kern,             "convolve with 3x3 kernel"},
+  {1, "keyword",      keyword,          "extract a FITS keyword from buffer header"},
+  {1, "labels",       labels,           "define labels for plot"},
+  {1, "limits",       limits,           "define plot limits"},
+  {1, "line",         line,             "plot line"},
+  {1, "buffers",      list_buffers,     "list the currently allocated buffers"},
+  {1, "vectors",      list_vectors,     "list vectors"},
+  {1, "load",         load,             "load an SAOimage style overlay"},
+  {1, "lookup",       lookup,           "convert vector via lookup table (vector pair)"},
+  {1, "mkrgb",        mkrgb,            "convert 3 images to rgb jpeg"},
+  {1, "mcreate",      mcreate,          "create a matrix"},
+  {1, "medacc",       medacc,           "accumulate vector values in another vector"},
+  {1, "mget",         mget,             "extract a vector from a matrix"},
+  {1, "minterp",      minterp,          "interpolate image pixels"},
+  {1, "mset",         mset,             "insert a vector in a matrix"},
+  {1, "peak",         peak,             "find vector peak in range"},
+  {1, "periodogram",  periodogram,      "measure periods in unevenly sampled data"},
+  {1, "plot",         plot,             "plot a pair of vectors"},
+  {1, "dot",          dot,              "plot a single point"},
+  {1, "point",        point,            "load overlay with single point"},
+  {1, "ps",           ps,               "define labels for plot"},
+  {1, "queuepop",     queuepop,         "pop value from queue to variable"},
+  {1, "queuedrop",    queuedrop,        "drop values from queue matching a key"},
+  {1, "queueprint",   queueprint,       "print the contents of a queue"},
+  {1, "queuepush",    queuepush,        "push value onto queue"},
+  {1, "queueinit",    queueinit,        "create an empty queue"},
+  {1, "queuedelete",  queuedelete,      "delete a queue"},
+  {1, "queuelist",    queuelist,        "list defined queues"},
+  {1, "queueload",    queueload,        "load queue from command"},
+  {1, "queuesize",    queuesize,        "show queue size"},
+  {1, "rd",           rd,               "load fits image"},
+  {1, "rdseg",        rdseg,            "read a segment of an image from a file"},
+  {1, "read",         read_vectors,     "read vectors from datafile"},
+  {1, "rebin",        rebin,            "rebin data by factor of N"},
+  {1, "resize",       resize,           "set graphics/image window size"},
+  {1, "roll",         roll,             "roll image to new start point"},
+  {1, "rotate",       rotate,           "rotate image"},
+  {1, "save",         save,             "save an SAOimage style overlay"},
+  {1, "section",      section,          "define section of graph"},
+  {1, "set",          set,              "vector math"},
+  {1, "shift",        shift,            "shift data in an image"},
+  {1, "sort",         sort_vectors,     "sort list of vectors"},
+  {1, "spline.apply", spline_apply_cmd, "apply spline fit to generate an image"},
+  {1, "spline.const", spline_construct_cmd, "create spline 2nd deriv. terms"},
+  {1, "stats",        stats,            "give statistics on a portion of a buffer"},
+  {1, "style",        style,            "set the style for graph plots"},
+  {1, "subraster",    subraster,        "subraster of fits image"},
+  {1, "subset",       subset,           "expand vector dimension"},
+  {1, "svd",          svd,              "singular value decomposition of a matrix"},
+  {1, "swapbytes",    swapbytes,        "byte swap thing"},
+  {1, "textline",     textline,         "write text line on graph"},
+  {1, "tv",           tv,               "display an image on the Kii window"},
+  {1, "tvchannel",    tvchannel,        "set the current tv channel"},
+  {1, "tvcolors",     tvcolors,         "set the tv colormap"},
+  {1, "tvcontour",    tvcontour,        "send contour to overlay"},
+  {1, "tvgrid",       tvgrid,           "wait until return is typed"},
+  {1, "uniq",         uniq,             "create a uniq vector subset from a vector"},
+  {1, "unsign",       unsign,           "toggle the UNSIGN status"},
+  {1, "vbin",         vbin,             "bin values in a vector to be within a range"},
+  {1, "vclip",        vclip,            "clip values in a vector to be within a range"},
+  {1, "select",       vect_select,      "selective vector assignment"},
+  {1, "vgauss",       vgauss,           ""},
+  {1, "vmaxwell",     vmaxwell,         ""},
+  {1, "vgrid",        vgrid,            ""},
+  {1, "vload",        vload,            "load vectors on Kii"},
+  {1, "vstat",        vstat,            "get info from imreg database"},
+  {1, "vsmooth",      vsmooth,          "gaussian smooth of a vector"},
+  {1, "vroll",        vroll,            "roll vector elements"},
+  {1, "vpop",         vpop,             "remove first element"},
+  {1, "wd",           wd,               "write an image to a file"},
+  {1, "write",        write_vectors,    "write vectors to datafile"},
+  {1, "zap",          zap,              "delete pixels"},
+  {1, "zplot",        zplot,            "plot x y with size scaled by z"},
 }; 
 
@@ -247,8 +247,15 @@
   InitKapa ();
   InitQueues ();
+  InitBooks ();
 
   for (i = 0; i < sizeof (cmds) / sizeof (Command); i++) {
     AddCommand (&cmds[i]);
   }
-
 }
+
+void FreeData () {
+
+  FreeKapa ();
+  FreeQueues ();
+  FreeBooks ();
+}
