Loading src/authdb.cpp +45 −7 Changes for src/authdb.cpp: 45 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -232,7 +232,7 @@ namespace authdb { continue; std::string name; int stortype=TextStorage; int stortype=EmptyStorage; for(libhttppp::HttpForm::MultipartForm::Data::ContentDisposition *curdispo=curformdat->getDisposition(); curdispo; curdispo=curdispo->nextContentDisposition() Loading @@ -243,14 +243,30 @@ namespace authdb { std::transform(tmp.begin(), tmp.end(), tmp.begin(), [](unsigned char c){ return std::tolower(c); }); if(tmp=="name") if(tmp=="name"){ name=curdispo->getValue(); } if(tmp=="filename"){ stortype=BinaryStorage; } } if(stortype==EmptyStorage){ bool numeric=true; for(auto i : curformdat->Value){ if(!std::isdigit(i)){ numeric=false; break; } } if(!numeric) stortype=TextStorage; else stortype=IntStorage; } if(name.empty() || stortype == EmptyStorage) continue; Loading @@ -262,6 +278,7 @@ namespace authdb { cudat.type=UserData; cudat.storage=stortype; strcpy(cudat.fieldname,name.c_str()); if(cudat.storage==BinaryStorage){ Loading @@ -269,7 +286,10 @@ namespace authdb { cudat.data=new char[cudat.datasize]; memcpy(cudat.data,curformdat->Value.data(), cudat.datasize); }else{ udat.Data->append(cudat); delete[] cudat.data; }else if(cudat.storage==TextStorage){ if(strcmp(cudat.fieldname,"pwhash")==0){ Hash hash; std::string pwhash,inpw; Loading @@ -280,18 +300,33 @@ namespace authdb { cudat.data=new char[cudat.datasize]; memcpy(cudat.data,pwhash.c_str(),pwhash.length()); cudat.data[pwhash.length()]='\0'; udat.Data->append(cudat); delete[] cudat.data; }else{ cudat.datasize=curformdat->Value.size()+1; curformdat->Value.push_back('\0'); cudat.datasize=curformdat->Value.size(); cudat.data=new char[cudat.datasize]; memcpy(cudat.data,curformdat->Value.data(), curformdat->Value.size()); cudat.data[curformdat->Value.size()]='\0'; } udat.Data->append(cudat); delete[] cudat.data; } }else if(cudat.storage==IntStorage){ curformdat->Value.push_back('\0'); int val=atoi(curformdat->Value.data()); cudat.datasize=sizeof(int); cudat.data=(char*)new int; memcpy(cudat.data,&val, curformdat->Value.size()); udat.Data->append(cudat); delete[] cudat.data; } } User user; user.create(*backend,&udat); std::cout << "user created!" << std::endl; Loading Loading @@ -461,6 +496,7 @@ namespace authdb { AuthData curec(uid); curec.Data->type=UserData; curec.Data->storage=EmptyStorage; for(libhttppp::HttpForm::MultipartForm::Data::ContentDisposition *curdispo=curformdat->getDisposition(); Loading Loading @@ -508,6 +544,8 @@ namespace authdb { curec.Data->storage=TextStorage; } if(curec.Data->storage==TextStorage) { curformdat->Value.push_back('\0'); if(strcmp(curec.Data->fieldname,"pwhash")==0){ Loading Loading @@ -988,6 +1026,7 @@ VALUEFOUND: AuthData::AuthData(const uuid_t id){ Data = new struct AuthData::Record; memset(Data,0,sizeof(AuthData::Record)); uuid_copy(Data->uuid,id); Data->start=0xFE; Data->storage=EmptyStorage; Loading @@ -1002,7 +1041,6 @@ VALUEFOUND: AuthData *dest=this; for(const AuthData *cursrc=&src; cursrc; cursrc=cursrc->next()){ std::cout << "test" << std::endl; memcpy(dest->Data,cursrc->Data,sizeof(AuthData::Record)); dest->Data->datasize=cursrc->Data->datasize; dest->Data->data=new char[dest->Data->datasize]; Loading Loading
src/authdb.cpp +45 −7 Changes for src/authdb.cpp: 45 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -232,7 +232,7 @@ namespace authdb { continue; std::string name; int stortype=TextStorage; int stortype=EmptyStorage; for(libhttppp::HttpForm::MultipartForm::Data::ContentDisposition *curdispo=curformdat->getDisposition(); curdispo; curdispo=curdispo->nextContentDisposition() Loading @@ -243,14 +243,30 @@ namespace authdb { std::transform(tmp.begin(), tmp.end(), tmp.begin(), [](unsigned char c){ return std::tolower(c); }); if(tmp=="name") if(tmp=="name"){ name=curdispo->getValue(); } if(tmp=="filename"){ stortype=BinaryStorage; } } if(stortype==EmptyStorage){ bool numeric=true; for(auto i : curformdat->Value){ if(!std::isdigit(i)){ numeric=false; break; } } if(!numeric) stortype=TextStorage; else stortype=IntStorage; } if(name.empty() || stortype == EmptyStorage) continue; Loading @@ -262,6 +278,7 @@ namespace authdb { cudat.type=UserData; cudat.storage=stortype; strcpy(cudat.fieldname,name.c_str()); if(cudat.storage==BinaryStorage){ Loading @@ -269,7 +286,10 @@ namespace authdb { cudat.data=new char[cudat.datasize]; memcpy(cudat.data,curformdat->Value.data(), cudat.datasize); }else{ udat.Data->append(cudat); delete[] cudat.data; }else if(cudat.storage==TextStorage){ if(strcmp(cudat.fieldname,"pwhash")==0){ Hash hash; std::string pwhash,inpw; Loading @@ -280,18 +300,33 @@ namespace authdb { cudat.data=new char[cudat.datasize]; memcpy(cudat.data,pwhash.c_str(),pwhash.length()); cudat.data[pwhash.length()]='\0'; udat.Data->append(cudat); delete[] cudat.data; }else{ cudat.datasize=curformdat->Value.size()+1; curformdat->Value.push_back('\0'); cudat.datasize=curformdat->Value.size(); cudat.data=new char[cudat.datasize]; memcpy(cudat.data,curformdat->Value.data(), curformdat->Value.size()); cudat.data[curformdat->Value.size()]='\0'; } udat.Data->append(cudat); delete[] cudat.data; } }else if(cudat.storage==IntStorage){ curformdat->Value.push_back('\0'); int val=atoi(curformdat->Value.data()); cudat.datasize=sizeof(int); cudat.data=(char*)new int; memcpy(cudat.data,&val, curformdat->Value.size()); udat.Data->append(cudat); delete[] cudat.data; } } User user; user.create(*backend,&udat); std::cout << "user created!" << std::endl; Loading Loading @@ -461,6 +496,7 @@ namespace authdb { AuthData curec(uid); curec.Data->type=UserData; curec.Data->storage=EmptyStorage; for(libhttppp::HttpForm::MultipartForm::Data::ContentDisposition *curdispo=curformdat->getDisposition(); Loading Loading @@ -508,6 +544,8 @@ namespace authdb { curec.Data->storage=TextStorage; } if(curec.Data->storage==TextStorage) { curformdat->Value.push_back('\0'); if(strcmp(curec.Data->fieldname,"pwhash")==0){ Loading Loading @@ -988,6 +1026,7 @@ VALUEFOUND: AuthData::AuthData(const uuid_t id){ Data = new struct AuthData::Record; memset(Data,0,sizeof(AuthData::Record)); uuid_copy(Data->uuid,id); Data->start=0xFE; Data->storage=EmptyStorage; Loading @@ -1002,7 +1041,6 @@ VALUEFOUND: AuthData *dest=this; for(const AuthData *cursrc=&src; cursrc; cursrc=cursrc->next()){ std::cout << "test" << std::endl; memcpy(dest->Data,cursrc->Data,sizeof(AuthData::Record)); dest->Data->datasize=cursrc->Data->datasize; dest->Data->data=new char[dest->Data->datasize]; Loading