// file: $isip/util/demo/isip_comm_server_dialog_database/mysql_interface.h
// version: $Id: mysql_interface.h 10017 2005-04-22 15:05:35Z elliott $
//

/*************************************************************************
 *                                                                       * 
 *                Center for Speech and Language Research		 *
 *                   University of Colorado, Boulder                     *
 *                       Copyright (c) 1999,2000                         *
 *                        All Rights Reserved.                           *
 *                                                                       *
 *  The University of Colorado ("CU") hereby grants to you an            *
 *  irrevocable, nonexclusive, nontransferable, perpetual, royalty-free  *
 *  and worldwide license to use this source code solely for educational,*
 *  research, personal use, or evaluation.  Limitations of Use are       *
 *  described below.  A commercial license can be obtained only through  *
 *  expressed written permission of The Center for Speech and Language   *
 *  Research, University of Colorado at Boulder.			 *
 *									 *
 *  	Non-Commercial License Limitations and Use Requirements		 *
 *									 *
 *  Limitations on Use: The License is limited to noncommercial use.     *
 *  Noncommercial use relates only to educational, research, personal    *
 *  use, or evaluation purposes.  Any other use is commercial use.  You  *
 *  may not use the Software in connection with any business activities. *
 *  You may distribute and/or allow others to use a) the Software or b)  *
 *  the applications you create with the Software only if each new user  *
 *  is bound by the provisions of this Agreement.			 *
 *									 *
 *  Conditions of Use: This work is furnished to you under the following *
 *  conditions:								 *
 *									 *
 *   1. The code must retain the above copyright notice, this list of    *
 *      conditions and the following disclaimer.                         *
 *   2. Any modifications must be clearly marked as such.                *
 *   3. Original authors' names are not deleted.                         *
 *   4. The authors' names are not used to endorse or promote products   *
 *      derived from this software without specific prior written        *
 *      permission.                                                      *
 *   5. You agree to acknowledge CU-Boulder's Center for Speech and      *
 *      Language Reseach with appropriate citations in any publication or*
 *      presentation containing research results obtained in whole or in *
 *      part through the use of the Software.				 *
 *									 *
 *  Term of License: The License is effective upon receipt by you of the *
 *  Software and shall continue until terminated.  The License will      *
 *  terminate immediately without notice by CU if you fail to comply     *
 *  with the terms and conditions of this Agreement.  Upon termination   *
 *  of this License, you shall immediately discontinue all use of the    *
 *  Software provided hereunder, and return to CU or destroy the         *
 *  original and all copies of all such Software.  All of your           *
 *  obligations under this Agreement shall survive the termination of    *
 *  the License.							 *
 *									 *
 *  DISCLAIMER:                                                          *
 *                                                                       *
 *  THE UNIVERSITY OF COLORADO AND THE CONTRIBUTORS TO THIS WORK         *
 *  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      *
 *  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   *
 *  SHALL THE UNIVERSITY OF COLORADO NOR THE CONTRIBUTORS BE LIABLE      *
 *  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    *
 *  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   *
 *  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          *
 *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       *
 *  THIS SOFTWARE.                                                       *
 *                                                                       *
 *************************************************************************/
/*
  NOTICE
   
  This software was produced for the U.S. Government
  under Contract No. DAAB07-97-C-E601, and is
  subject to the Rights in Technical Data and Computer
  Software Clause 252.227-7013 (Oct 88) and Alternate II (APR 93).
  
  Copyright 1998, 1999 The MITRE Corporation
*/

/************************************************************************
 *
 *
 *	Copyright (c) 1997						
 *	Spoken Language Systems Group					
 *	Laboratory for Computer Science					
 *	Massachusetts Institute of Technology				
 *	All Rights Reserved
 *
 ************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <mysql.h>

// Define TCHAR and related functions.
typedef char                TCHAR;
#define _tcslen(s)          strlen(s)
#define _tcscpy(d,s)        strcpy(d,s)
#define _tcscat(d,s)        strcat(d,s)
#define _tcsncpy(d,s,n)     strncpy(d,s,n)
#define _stprintf           sprintf
#define _vstprintf          vsprintf
#define LPTSTR              LPSTR
#define TEXT(s)             s
int     Displaytext(char *, int, TCHAR *, ... );
#define NULL_TEXT               TEXT( "(NULL)" )
#if !defined( TRUE )
    #define TRUE                1
#endif

#if !defined( FALSE )
   #define FALSE               0
#endif

#define SCREEN_WIDTH            79
#define MY_NEWLINE_STR          TEXT( "\n" )
#define MY_NEWLINE_CHAR         '\n'

//#define MY_DATABASE "flatroute"
//#define MY_TABLE    "fax"
//#define MY_HOST    "gold.erc.msstate.edu"
//#define MY_USER    "gao"
//#define MY_PASSWORD "qaz1234"

#define MY_DATABASE "flatroute"
//#define MY_TABLE    "fax"
#define MY_HOST    "chinook.erc.msstate.edu"
#define MY_USER    "dialog"
#define MY_PASSWORD "pass123"

//void  server_shutdown(void);
//void  exit_handler(void);
//void *server_exit(void);
//void  do_command(char *query);
//void  sql_connect(char *username, char *passwd, char *dbname);

// Prototypes from mysql_interface.cc
void  sql_connect();
void  sql_disconnect(void);
int   fetch_row(char *str);
void  fetch_header(char *str);
void  head_row_into_string(char *str);
int   do_sql_query(char* str);
MYSQL* get_sql_connection(void);
