;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; LUSH Lisp Universal Shell
;;;   Copyright (C) 2002 Leon Bottou, Yann Le Cun, AT&T Corp, NECI.
;;; Includes parts of TL3:
;;;   Copyright (C) 1987-1999 Leon Bottou and Neuristique.
;;; Includes selected parts of SN3.2:
;;;   Copyright (C) 1991-2001 AT&T Corp.
;;;
;;; Includes information derived from the GSL (Gnu Scientific Library)
;;;   header files which are copyrighted and distributed under the GPL
;;;   by their respective authors.
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(libload "htk/htk-config")



#? *** htk_util

;; dummy function that adds HTK C header files in C file
(eval `(de dummy_htk_util () ,htk-cpheader-cmd ()))

#? * (dummy_htk_util)
#? * (initutil)
#? * (clonesvector <hmem> <s> <sharing>)
#? * (clonesmatrix <hmem> <s> <sharing>)
#? * (clonestrimat <hmem> <s> <sharing>)
#? * (clonemixpdf <hset> <s> <sharing>)
#? * (clonestream <hset> <ste> <sharing> <result>)
#? * (clonestate <hset> <ssi> <sharing>)
#? * (clonehmm <src> <tgt> <sharing>)
#? * (convdiagc <hset> <convdata>)
#? * (newhmmscan <hset> <hss>)
#? * (endhmmscan <hss>)
#? * (gonexthmm <hss>)
#? * (gonextstate <hss> <noskip>)
#? * (gonextstream <hss> <noskip>)
#? * (gonextmix <hss> <noskip>)
#? * (hmmphysname <hset> <hmm>)
#? * (additem <owner> <item> <list>)
#? * (numitems <list>)
#? * (freeitems <list>)
#? * (createset <size> <result>)
#? * (freeset <s>)
#? * (addmember <s> <x>)
#? * (ismember <s> <x>)
#? * (isfullset <s>)
#? * (clearset <s>)
#? * (setset <s>)
#? * (pitemlist <ilist> <type> <h> <s> <itrace>)
#? * (getmacrohook <ml>)
#? * (setmacrohook <ml> <hook>)
#? * (getmacrouse <ml>)
#? * (setmacrouse <ml> <use>)
#? * (resethooks <hset> <what>)
#? * (loadstatsfile <statfile> <hset> <otrace>)

;; ********************************************************



(de InitUtil (  )
    #{ InitUtil(  );  #} 
    ()
)


(de CloneSVector (  hmem  s  sharing )
    ((-gptr- "MemHeap *") hmem) 
    ((-gptr- "float *") s) 
    ((-int-) sharing)  
    (gptr   #{ CloneSVector(  $hmem   ,$s   ,$sharing  )  #} )          ;; SVector -> gptr
)


(de CloneSMatrix (  hmem  s  sharing )
    ((-gptr- "MemHeap *") hmem) 
    ((-gptr- "float **") s) 
    ((-int-) sharing)  
    (gptr   #{ CloneSMatrix(  $hmem   ,$s   ,$sharing  )  #} )           ;; SMatrix -> gptr
)


(de CloneSTriMat (  hmem  s  sharing )
    ((-gptr- "MemHeap *") hmem) 
    ((-gptr- "float **") s) 
    ((-int-) sharing)  
    (gptr   #{ CloneSTriMat(  $hmem   ,$s   ,$sharing  )  #} )             ;; STriMat -> gptr
)


(de CloneMixPDF (  hset  s  sharing )
    ((-gptr- "HMMSet *") hset) 
    ((-gptr- "MixPDF *") s) 
    ((-int-) sharing)  
    (gptr #{ CloneMixPDF(  $hset   ,$s   ,$sharing  )  #} )            ;; MixPDF *   -> gptr
)


(de CloneStream (  hset  ste  sharing result)
    ((-gptr- "HMMSet *") hset) 
    ((-gptr- "StreamElem *") ste) 
    ((-int-) sharing)  
    ((-gptr- "float *") result)                              ;; return union -> pointer
    #{ {
    MixtureVector tmp;
    tmp = CloneStream(  $hset   ,$ste   ,$sharing  );
    memcpy($result, &tmp, sizeof(MixtureVector));
    } #}
    ()
)


(de CloneState (  hset  ssi  sharing )
    ((-gptr- "HMMSet *") hset) 
    ((-gptr- "StateInfo *") ssi) 
    ((-int-) sharing)  
    (gptr #{ CloneState(  $hset   ,$ssi   ,$sharing  )  #} )            ;; StateInfo *   -> gptr
)


(de CloneHMM (  src  tgt  sharing )
    ((-gptr- "HMMDef *") src) 
    ((-gptr- "HMMDef *") tgt) 
    ((-int-) sharing)  
    #{ CloneHMM(  $src   ,$tgt   ,$sharing  );  #} 
    ()
)


(de ConvDiagC (  hset  convdata )
    ((-gptr- "HMMSet *") hset) 
    ((-int-) convdata)  
    #{ ConvDiagC(  $hset   ,$convdata  );  #} 
    ()
)


(de NewHMMScan (  hset  hss )
    ((-gptr- "HMMSet *") hset) 
    ((-gptr- "HMMScanState *") hss)  
    #{ NewHMMScan(  $hset   ,$hss  );  #} 
    ()
)


(de EndHMMScan (  hss )
    ((-gptr- "HMMScanState *") hss)  
    #{ EndHMMScan(  $hss  );  #} 
    ()
)


(de GoNextHMM (  hss )
    ((-gptr- "HMMScanState *") hss)  
    (int   #{ GoNextHMM(  $hss  )  #} )
)


(de GoNextState (  hss  noskip )
    ((-gptr- "HMMScanState *") hss) 
    ((-int-) noskip)  
    (int   #{ GoNextState(  $hss   ,$noskip  )  #} )
)


(de GoNextStream (  hss  noskip )
    ((-gptr- "HMMScanState *") hss) 
    ((-int-) noskip)  
    (int   #{ GoNextStream(  $hss   ,$noskip  )  #} )
)


(de GoNextMix (  hss  noskip )
    ((-gptr- "HMMScanState *") hss) 
    ((-int-) noskip)  
    (int   #{ GoNextMix(  $hss   ,$noskip  )  #} )
)


(de HMMPhysName (  hset  hmm )
    ((-gptr- "HMMSet *") hset) 
    ((-gptr- "HMMDef *") hmm)  
    (gptr #{ HMMPhysName(  $hset   ,$hmm  )  #} )            ;; char *   -> gptr
)


(de AddItem (  owner  item  list )
    ((-gptr- "HMMDef *") owner) 
    ((-gptr-) item) 
    ((-gptr- "ILink *") list)  
    #{ AddItem(  $owner   ,$item   ,$list  );  #} 
    ()
)


(de NumItems (  list )
    ((-gptr- "ItemRec *") list)           ;; ILink  -> gptr
    (int   #{ NumItems(  $list  )  #} )
)


(de FreeItems (  list )
    ((-gptr- "ILink *") list)  
    #{ FreeItems(  $list  );  #} 
    ()
)


(de CreateSet (  size result)
    ((-int-) size)  
    ((-gptr- "IntSet *") result)         ;; return struct -> pointer
    #{ {
    IntSet tmp;
    tmp = CreateSet(  $size  );
    memcpy($result, &tmp, sizeof(IntSet));
    } #}
    ()
)


(de FreeSet (  s )
    ((-gptr- "IntSet *") s)                 ;; struct -> pointer
    #{ FreeSet(  *$s  );  #} 
    ()
)


(de AddMember (  s  x )
    ((-gptr- "IntSet *") s)                  ;; struct -> pointer
    ((-int-) x)  
    #{ AddMember(  *$s   ,$x  );  #} 
    ()
)


(de IsMember (  s  x )
    ((-gptr- "IntSet *") s)                    ;; struct -> pointer
    ((-int-) x)  
    (int   #{ IsMember(  *$s   ,$x  )  #} )
)


(de IsFullSet (  s )
    ((-gptr- "IntSet *") s)                   ;; struct -> pointer
    (int   #{ IsFullSet(  *$s  )  #} )
)


(de ClearSet (  s )
    ((-gptr- "IntSet *") s)                   ;; struct -> pointer
    #{ ClearSet(  *$s  );  #} 
    ()
)


(de SetSet (  s )
    ((-gptr- "IntSet *") s)                     ;; struct -> pointer
    #{ SetSet(  *$s  );  #} 
    ()
)


(de PItemList (  ilist  type  h  s  itrace )
    ((-gptr- "ILink *") ilist) 
    ((-gptr- "char *") type) 
    ((-gptr- "HMMSet *") h) 
    ((-gptr- "Source *") s) 
    ((-int-) itrace)  
    (gptr #{ PItemList(  $ilist   ,$type   ,$h   ,$s   ,$itrace  )  #} )            ;; char *   -> gptr
)


(de GetMacroHook (  ml )
    ((-gptr- "MacroDef *") ml)  
    (gptr   #{ GetMacroHook(  $ml  )  #} )
)


(de SetMacroHook (  ml  hook )
    ((-gptr- "MacroDef *") ml) 
    ((-gptr-) hook)  
    #{ SetMacroHook(  $ml   ,$hook  );  #} 
    ()
)


(de GetMacroUse (  ml )
    ((-gptr- "MacroDef *") ml)  
    (int   #{ GetMacroUse(  $ml  )  #} )
)


(de SetMacroUse (  ml  use )
    ((-gptr- "MacroDef *") ml) 
    ((-int-) use)  
    #{ SetMacroUse(  $ml   ,$use  );  #} 
    ()
)


(de ResetHooks (  hset  what )
    ((-gptr- "HMMSet *") hset) 
    ((-gptr- "char *") what)  
    #{ ResetHooks(  $hset   ,$what  );  #} 
    ()
)


(de LoadStatsFile (  statfile  hset  otrace )
    ((-gptr- "char *") statfile) 
    ((-gptr- "HMMSet *") hset) 
    ((-int-) otrace)  
    #{ LoadStatsFile(  $statfile   ,$hset   ,$otrace  );  #} 
    ()
)

;; ********************************************************

(dhc-make-with-libs () (list htk-libhtk)
  dummy_htk_util
  initutil
  clonesvector
  clonesmatrix
  clonestrimat
  clonemixpdf
  clonestream
  clonestate
  clonehmm
  convdiagc
  newhmmscan
  endhmmscan
  gonexthmm
  gonextstate
  gonextstream
  gonextmix
  hmmphysname
  additem
  numitems
  freeitems
  createset
  freeset
  addmember
  ismember
  isfullset
  clearset
  setset
  pitemlist
  getmacrohook
  setmacrohook
  getmacrouse
  setmacrouse
  resethooks
  loadstatsfile
)
