mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-31 07:59:30 +02:00
2016-07-21 Fred Gleason <fredg@paravelsystems.com>
* Refactored rdclilogedit(1) to use synchronous input.
This commit is contained in:
parent
985eb461f3
commit
fb5010fa98
@ -15356,3 +15356,5 @@
|
|||||||
* Moved enforcement of user permissions to the
|
* Moved enforcement of user permissions to the
|
||||||
'MainObject::DispatchCommand()' method in
|
'MainObject::DispatchCommand()' method in
|
||||||
'utils/rdclilogedit/parser.cpp'.
|
'utils/rdclilogedit/parser.cpp'.
|
||||||
|
2016-07-21 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Refactored rdclilogedit(1) to use synchronous input.
|
||||||
|
@ -94,7 +94,7 @@ void MainObject::ListLogs() const
|
|||||||
sql=QString("select NAME from LOGS order by NAME");
|
sql=QString("select NAME from LOGS order by NAME");
|
||||||
q=new RDSqlQuery(sql);
|
q=new RDSqlQuery(sql);
|
||||||
while(q->next()) {
|
while(q->next()) {
|
||||||
Print(QString().sprintf("%s\n",(const char *)q->value(0).toString()));
|
printf("%s\n",(const char *)q->value(0).toString());
|
||||||
}
|
}
|
||||||
delete q;
|
delete q;
|
||||||
}
|
}
|
||||||
@ -127,8 +127,7 @@ void MainObject::Load(const QString &logname)
|
|||||||
void MainObject::List()
|
void MainObject::List()
|
||||||
{
|
{
|
||||||
for(int i=0;i<edit_log_event->size();i++) {
|
for(int i=0;i<edit_log_event->size();i++) {
|
||||||
Print(QString().sprintf("%4d %s\n",i,
|
printf("%4d %s\n",i,(const char *)ListLine(edit_log_event,i));
|
||||||
(const char *)ListLine(edit_log_event,i)));
|
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
@ -82,16 +82,17 @@ MainObject::MainObject(QObject *parent)
|
|||||||
// RIPC Connection
|
// RIPC Connection
|
||||||
//
|
//
|
||||||
edit_user=NULL;
|
edit_user=NULL;
|
||||||
edit_input_notifier=NULL;
|
|
||||||
edit_ripc=new RDRipc(edit_config->stationName());
|
edit_ripc=new RDRipc(edit_config->stationName());
|
||||||
connect(edit_ripc,SIGNAL(userChanged()),this,SLOT(userData()));
|
connect(edit_ripc,SIGNAL(userChanged()),this,SLOT(userData()));
|
||||||
edit_ripc->
|
edit_ripc->connectHost("localhost",RIPCD_TCP_PORT,edit_config->password());
|
||||||
connectHost("localhost",RIPCD_TCP_PORT,edit_config->password());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainObject::userData()
|
void MainObject::userData()
|
||||||
{
|
{
|
||||||
|
char data[1024];
|
||||||
|
int n;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get User Context
|
// Get User Context
|
||||||
//
|
//
|
||||||
@ -104,24 +105,8 @@ void MainObject::userData()
|
|||||||
//
|
//
|
||||||
// Start up command processor
|
// Start up command processor
|
||||||
//
|
//
|
||||||
if(edit_input_notifier==NULL) {
|
PrintPrompt();
|
||||||
int flags=fcntl(0,F_GETFL,NULL);
|
while((n=read(0,data,1024))>0) {
|
||||||
flags|=O_NONBLOCK;
|
|
||||||
fcntl(0,F_SETFL,flags);
|
|
||||||
edit_input_notifier=new QSocketNotifier(0,QSocketNotifier::Read,this);
|
|
||||||
connect(edit_input_notifier,SIGNAL(activated(int)),
|
|
||||||
this,SLOT(inputActivatedData(int)));
|
|
||||||
PrintPrompt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MainObject::inputActivatedData(int sock)
|
|
||||||
{
|
|
||||||
char data[1024];
|
|
||||||
int n;
|
|
||||||
|
|
||||||
while((n=read(sock,data,1024))>0) {
|
|
||||||
for(int i=0;i<n;i++) {
|
for(int i=0;i<n;i++) {
|
||||||
switch(0xFF&data[i]) {
|
switch(0xFF&data[i]) {
|
||||||
case 10:
|
case 10:
|
||||||
@ -137,6 +122,8 @@ void MainObject::inputActivatedData(int sock)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printf("\n");
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -147,25 +134,17 @@ void MainObject::OverwriteError(const QString &cmd) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainObject::Print(const QString &str) const
|
|
||||||
{
|
|
||||||
printf("%s",(const char *)str);
|
|
||||||
usleep(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MainObject::PrintPrompt() const
|
void MainObject::PrintPrompt() const
|
||||||
{
|
{
|
||||||
if(edit_log==NULL) {
|
if(edit_log==NULL) {
|
||||||
Print("logedit> ");
|
printf("logedit> ");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(edit_modified) {
|
if(edit_modified) {
|
||||||
Print(QString().sprintf("logedit[%s*]> ",
|
printf("logedit[%s*]> ",(const char *)edit_log->name());
|
||||||
(const char *)edit_log->name()));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Print(QString().sprintf("logedit[%s]> ",(const char *)edit_log->name()));
|
printf("logedit[%s]> ",(const char *)edit_log->name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#define RDCLILOGEDIT_H
|
#define RDCLILOGEDIT_H
|
||||||
|
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qsocketnotifier.h>
|
|
||||||
|
|
||||||
#include <rdairplay_conf.h>
|
#include <rdairplay_conf.h>
|
||||||
#include <rdconfig.h>
|
#include <rdconfig.h>
|
||||||
@ -43,7 +42,6 @@ class MainObject : public QObject
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void userData();
|
void userData();
|
||||||
void inputActivatedData(int sock);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Addcart(int line,unsigned cartnum);
|
void Addcart(int line,unsigned cartnum);
|
||||||
@ -64,11 +62,9 @@ class MainObject : public QObject
|
|||||||
void Settrans(int line,RDLogLine::TransType type);
|
void Settrans(int line,RDLogLine::TransType type);
|
||||||
void Unload();
|
void Unload();
|
||||||
void OverwriteError(const QString &cmd) const;
|
void OverwriteError(const QString &cmd) const;
|
||||||
void Print(const QString &str) const;
|
|
||||||
void DispatchCommand(QString cmd);
|
void DispatchCommand(QString cmd);
|
||||||
QString ListLine(RDLogEvent *evt,int line) const;
|
QString ListLine(RDLogEvent *evt,int line) const;
|
||||||
void PrintPrompt() const;
|
void PrintPrompt() const;
|
||||||
QSocketNotifier *edit_input_notifier;
|
|
||||||
QString edit_accum;
|
QString edit_accum;
|
||||||
bool edit_modified;
|
bool edit_modified;
|
||||||
RDLog *edit_log;
|
RDLog *edit_log;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user