#include <string.h>
#include <stdlib.h>
#include "dblogin.h"

@implementation SybaseLogin

- initWith: (const char*)uName password: (const char*) passwd
{
  id rval = NULL;
  if (_login = dblogin()){
    _userName = (char*)malloc(sizeof(char)*(strlen(uName)+1));
    strcpy(_userName, uName);
    DBSETLUSER(_login, _userName);
    DBSETLPWD(_login, passwd);
    rval = self;
  }
  else [self free];
  return rval;
}

- (const char*) userName
{
  return (const char*) _userName;
}

- (LOGINREC*) loginRec
{
  return _login;
}

- free
{
  if (_login) dbloginfree(_login);
  if (_userName) free(_userName);
}

@end
    
