Commit a98de0d0 authored by jan.koester's avatar jan.koester
Browse files

some moderenize

parent cdcafb98
Loading
Loading
Loading
Loading
Loading
+0 −3
Changes for src/admin.cpp: 0 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -722,9 +722,6 @@ namespace authdb {

                        std::string tmp=curdispo->getKey().data();

                        std::transform(tmp.begin(), tmp.end(), tmp.begin(),
                                       [](unsigned char c){ return std::tolower(c); });

                        if(tmp=="name")
                            name=curdispo->getValue().data();

+9 −10
Changes for src/domain.cpp: 9 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -44,11 +44,10 @@ authdb::DomainData::DomainData(uuid::uuid duuid) :AuthData(duuid){
authdb::DomainData::~DomainData(){
}

void authdb::DomainData::setDomainName(const char* name){
    setAuthData<char>(DataType::DomainData,StorageType::TextStorage,this,&_name,"domainname",name,strlen(name)+1);
void authdb::DomainData::setDomainName(const std::string &name){
    setAuthData<char>(DataType::DomainData,StorageType::TextStorage,this,&_name,"domainname",name.c_str(),name.length()+1);
}

const char * authdb::DomainData::getDomainName(){
const std::string authdb::DomainData::getDomainName(){
    return getAuthData<char>(DataType::DomainData,StorageType::TextStorage,this,&_name,"domainname");
}

@@ -61,11 +60,11 @@ int authdb::DomainData::getStorageType(){
    return *getAuthData<int>(DataType::DomainData,StorageType::IntStorage,this,&_storageType,"domainstorage");
}

void authdb::DomainData::setStorageOptions(const char *opts){
    return setAuthData<char>(DataType::DomainData,StorageType::TextStorage,this,&_storageOptions,"domainoptions",opts,strlen(opts)+1);
void authdb::DomainData::setStorageOptions(const std::string &opts){
    return setAuthData<char>(DataType::DomainData,StorageType::TextStorage,this,&_storageOptions,"domainoptions",opts.c_str(),opts.length()+1);
}

const char * authdb::DomainData::getStorageOptions(){
const std::string authdb::DomainData::getStorageOptions(){
    return getAuthData<char>(DataType::DomainData,StorageType::TextStorage,
                             this,&_storageOptions,"domainoptions");
}
@@ -74,7 +73,7 @@ void authdb::Domain::create(authdb::AuthBackend& backend,class DomainData *data)
    int exi=0;


    if(exits(backend,data->Data.ruid,data->getDomainName(),exi)){
    if(exits(backend,data->Data.ruid,data->getDomainName().c_str(),exi)){
        switch(exi){
            case 1:
                throw authdb::AuthBackendError("Create Domain: Domainname already Exists aborting!");
@@ -113,7 +112,7 @@ void authdb::Domain::remove(AuthBackend& backend, const uuid::uuid &uid){
}


bool authdb::Domain::exits(AuthBackend& backend,const uuid::uuid& did, const char* name,int &ret){
bool authdb::Domain::exits(AuthBackend& backend,const uuid::uuid& did, const std::string &name,int &ret){
    authdb::AuthData::Record cur;

    size_t rd=sizeof(authdb::AuthHeader),end=backend.end();
@@ -125,7 +124,7 @@ bool authdb::Domain::exits(AuthBackend& backend,const uuid::uuid& did, const cha
        if(cur.type==DataType::DomainData && strcmp(cur.fieldname,"domainname")==0){
            cur.data=new char[cur.datasize];
            backend.read((unsigned char*)cur.data,cur.datasize);
            if(name && strcmp(cur.data,name) == 0){
            if(!name.empty() && name==cur.data ){
                delete[] cur.data;
                ret=1;
                return true;
+5 −5
Changes for src/domain.h: 5 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -38,14 +38,14 @@ namespace authdb {

        DomainData *next();

        void setDomainName(const char *name);
        const char*getDomainName();
        void setDomainName(const std::string &name);
        const std::string getDomainName();

        void setStorageType(const int type);
        int getStorageType();

        void setStorageOptions(const char *opts);
        const char*getStorageOptions();
        void setStorageOptions(const std::string &opts);
        const std::string getStorageOptions();

    private:
        AuthData::Record  *_name;
@@ -58,7 +58,7 @@ namespace authdb {
    public:
        void create(AuthBackend &backend,class DomainData *data);
        void remove(AuthBackend &backend,const uuid::uuid &uid);
        bool exits(AuthBackend&  backend,const uuid::uuid &uid, const char* name,int &ret);
        bool exits(AuthBackend&  backend,const uuid::uuid &uid, const std::string  &name,int &ret);
        void info(AuthBackend   &backend,class DomainData &dat,size_t &pos);
    };
};