Navigation
Home
gpl
sqlmeta
v1.0b
dbinfo.cpp








































dbinfo.cpp
   
   /*
    * DBInfo.cpp
    * Part of SQLMeta, a language to use sql-queries in html pages.
    *
    * Copyright (C) 2001  Daan Vreeken
    *
    * 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-1307, USA.
    *
    */
   
   #include "sqlmeta.h"
   
   
   
   
   
   DBInfo::DBInfo(MetaParser *MyParent)
   {
   	Host=NULL;
   	User=NULL;
   	Password=NULL;
   	DB=NULL;
   
   	Parent=MyParent;
   }
   
   
   
   int DBInfo::SetHost(char *NewHost)
   {
   	if (Host)
   		free(Host);
   
   	Host=(char *)malloc(strlen(NewHost)+1);
   	if (Host==NULL)
   		return Parent->Error(ErrMalloc,"DBInfo::SetHost");
   
   	strcpy(Host,NewHost);
   
   	return 1;
   }
   
   
   
   int DBInfo::SetUser(char *NewUser, char *NewPassword)
   {
   	if (User)
   		free(User);
   	if (Password)
   		free(Password);
   
   	User=(char *)malloc(strlen(NewUser)+1);
   	if (User==NULL)
   		return Parent->Error(ErrMalloc,"DBInfo::SetUser");
   	Password=(char *)malloc(strlen(NewPassword)+1);
   	if (Password==NULL)
   		return Parent->Error(ErrMalloc,"DBInfo::SetUser"); 
   
   	strcpy(User,NewUser);
   	strcpy(Password,NewPassword);
   
   	return 1;
   }
   
   
   
   int DBInfo::SetDB(char *NewDB)
   {
   	if (DB)
   		free(DB);
   
   	DB=(char *)malloc(strlen(NewDB)+1);
   	if (DB==NULL)
   		return Parent->Error(ErrMalloc,"DBInfo::SetDB");
   
   	strcpy(DB,NewDB);
   
   	return 1;
   }
   
   
   
   DBInfo::~DBInfo(void)
   {
   	if (Host!=NULL)
   		free(Host);
   	if (User!=NULL)
   		free(User);
   	if (Password!=NULL)
   		free(Password);
   	if (DB!=NULL)
   		free(DB);
   }
   
   
   
   
   

syntax highlighted by Code2HTML, v. 0.9.1


Email me with questions/comments : Daan <Daan @ pa4dan . nl>