Skip to content

Commit

Permalink
fix: remove line
Browse files Browse the repository at this point in the history
  • Loading branch information
martim01 committed Nov 25, 2024
1 parent f1cf4ad commit de1cb4d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions dosetup/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
#include "logtofile.h"
#include <filesystem>


static const std::string STR_DTPARAM = "dtparam=audio";
static const std::string STR_DTOVERLAY = "dtoverlay=";
static const std::string STR_LOCAL = "127.0.1.1";
static const std::string STR_VC4 = "dtoverlay=vc4-kms-v3d";

int SetHostname(const std::string& sHostname)
{
Expand Down Expand Up @@ -131,7 +133,6 @@ int SetOverlay(const std::string& sOverlay, const std::string& sLineNumber, cons
}

std::string sLine;
std::string sFind = "dtoverlay=vc4-fkms-v3d";
int nCount = 0;
bool bAdded(false);
bool bRotateDone(false);
Expand Down Expand Up @@ -171,10 +172,14 @@ int SetOverlay(const std::string& sOverlay, const std::string& sLineNumber, cons
}
bRotateDone = true;
}
else if(sLine.substr(0,sFind.length()) != sFind)
else if(sLine.substr(0,STR_VC4.length()) != STR_VC4)
{
output << sLine << '\n';
}
else
{
std::cout << "removed" << std::endl;
}
nCount++;
}
if(!bAdded)
Expand Down Expand Up @@ -235,6 +240,7 @@ int main(int argc, char* argv[])
pmlLog(pml::LOG_ERROR, "dosetup") << "Not enough arguments. Need 6 given " << argc;
pmlLog(pml::LOG_INFO, "dosetup") << "Usage: hostname password overlay line_to_replace";
pml::LogStream::Stop();
std::cout << "STOPPED" << std::endl;
return -1;
}

Expand All @@ -243,6 +249,7 @@ int main(int argc, char* argv[])
{
pmlLog(pml::LOG_CRITICAL, "dosetup") << "Failed to set hostname. Exiting";
pml::LogStream::Stop();
std::cout << "STOPPED" << std::endl;

return -1;
}
Expand All @@ -251,6 +258,7 @@ int main(int argc, char* argv[])
{
pmlLog(pml::LOG_CRITICAL, "dosetup") << "Failed to set password. Exiting";
pml::LogStream::Stop();
std::cout << "STOPPED" << std::endl;

return -1;
}
Expand All @@ -259,12 +267,15 @@ int main(int argc, char* argv[])
if(SetOverlay(argv[3], argv[4], argv[5]) != 0)
{
pml::LogStream::Stop();
std::cout << "STOPPED" << std::endl;
return -1;
}

SetRotate(argv[5]);

pmlLog(pml::LOG_INFO, "dosetup") << "------ FINISHED ------";
pml::LogStream::Stop();
std::cout << "STOPPED" << std::endl;

return 0;
}

0 comments on commit de1cb4d

Please sign in to comment.