49 lines
1.3 KiB
C
49 lines
1.3 KiB
C
/*
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*
|
|
* PlumbMsg — a plan9port plumbing message and its wire codec.
|
|
*
|
|
* Wire format (plan9port libplumb/mesg.c):
|
|
* src\n source application ("ollie")
|
|
* dst\n destination port ("" lets the rules decide)
|
|
* wdir\n working directory (resolves relative paths)
|
|
* type\n data type ("text")
|
|
* attr\n space-separated name=value attributes
|
|
* ndata\n decimal byte count of the data that follows
|
|
* <ndata bytes> the data (NOT newline-terminated)
|
|
*/
|
|
#ifndef OLLIE_PLUMBMSG_H
|
|
#define OLLIE_PLUMBMSG_H
|
|
|
|
#include <QByteArray>
|
|
#include <QList>
|
|
#include <QString>
|
|
|
|
struct PlumbAttr {
|
|
QString name;
|
|
QString value;
|
|
bool operator==(const PlumbAttr &o) const
|
|
{
|
|
return name == o.name && value == o.value;
|
|
}
|
|
};
|
|
|
|
struct PlumbMsg {
|
|
QString src;
|
|
QString dst;
|
|
QString wdir;
|
|
QString type;
|
|
QList<PlumbAttr> attr;
|
|
QByteArray data;
|
|
|
|
QString lookup(const QString &name) const;
|
|
void setAttr(const QString &name, const QString &value);
|
|
QByteArray pack() const;
|
|
static bool unpack(const QByteArray &buf, PlumbMsg *out);
|
|
};
|
|
|
|
QByteArray packPlumbAttr(const QList<PlumbAttr> &attr);
|
|
QList<PlumbAttr> unpackPlumbAttr(const QByteArray &line);
|
|
|
|
#endif
|