cstorage/new.main.cpp

84 lines
2.3 KiB
C++

/*
* new.main.cpp
* Copyright (C) 2023 Leonardo de Araújo Lima <leonardo@deb-horus.local>
*
* dstorage 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 3 of the License, or
* (at your option) any later version.
*
* dstorage 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, see <http://www.gnu.org/licenses/>.
*/
/*
# Copyright 2022 Leonardo de Araújo Lima
#
# 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 3 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, see http://www.gnu.org/licenses/.
#
#
#
#
*/
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#include <iostream>
#include <string>
#include "sdata.h"
int main(int argc, char* argv[])
{
const char *homedir;
if ((homedir = getenv("HOME")) == NULL)
{
homedir = getpwuid(getuid())->pw_dir;
}
string path=homedir;
path+="/databases/";
sdata monka;
monka.debug = 1;
monka.set_dpath(path.c_str());
path+="sData.db";
monka.set_db(path.c_str());
monka.set_tb("info");
monka.dbinfo();
monka.dbtest();
if (argv[1] > " ")
{
monka.objid = atoi(argv[1]);
}
else
{
cout << "é necessário informar o id do registro!"<< endl;
return 0;
}
cout << "\nloading..." << endl;
cout << "registro número : " << monka.objid << endl;
bool t = monka.load();
// monka.show();
cout << t << endl;
cout << "\ndata loaded..." << endl;
monka.citens();
monka.tsize();
return 0;
}