2022-09-22 20:57:46 -04:00
|
|
|
// This file is part of Motion Watch.
|
|
|
|
|
|
|
|
// Motion Watch 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.
|
|
|
|
|
|
|
|
// Motion Watch 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.
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
QString getParam(const QString &key, const QStringList &args)
|
2022-09-22 20:57:46 -04:00
|
|
|
{
|
2023-05-15 15:29:47 -04:00
|
|
|
// this can be used by command objects to pick out parameters
|
|
|
|
// from a command line that are pointed by a name identifier
|
|
|
|
// example: -i /etc/some_file, this function should pick out
|
|
|
|
// "/etc/some_file" from args if "-i" is passed into key.
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
QString ret;
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
int pos = args.indexOf(QRegularExpression(key, QRegularExpression::CaseInsensitiveOption));
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
if (pos != -1)
|
2022-09-22 20:57:46 -04:00
|
|
|
{
|
2023-05-15 15:29:47 -04:00
|
|
|
// key found.
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
if ((pos + 1) <= (args.size() - 1))
|
2023-03-05 16:07:07 -05:00
|
|
|
{
|
2023-05-15 15:29:47 -04:00
|
|
|
// check ahead to make sure pos + 1 will not go out
|
|
|
|
// of range.
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
if (!args[pos + 1].startsWith("-"))
|
2022-12-11 12:33:56 -05:00
|
|
|
{
|
2023-05-15 15:29:47 -04:00
|
|
|
// the "-" used throughout this application
|
|
|
|
// indicates an argument so the above 'if'
|
|
|
|
// statement will check to make sure it does
|
|
|
|
// not return another argument as a parameter
|
|
|
|
// in case a back-to-back "-arg -arg" is
|
|
|
|
// present.
|
|
|
|
|
|
|
|
ret = args[pos + 1];
|
2022-09-22 20:57:46 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
return ret;
|
2022-09-22 20:57:46 -04:00
|
|
|
}
|
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
QStringList lsFilesInDir(const QString &path, const QString &ext)
|
2022-12-04 15:13:39 -05:00
|
|
|
{
|
2023-05-15 15:29:47 -04:00
|
|
|
QStringList filters;
|
2022-12-13 21:13:10 -05:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
filters << "*" + ext;
|
2023-03-26 10:32:56 -04:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
QDir dirObj(path);
|
2023-03-10 19:35:44 -05:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
dirObj.setFilter(QDir::Files);
|
|
|
|
dirObj.setNameFilters(filters);
|
|
|
|
dirObj.setSorting(QDir::Name);
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
return dirObj.entryList();
|
|
|
|
}
|
2023-03-05 16:07:07 -05:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
QStringList lsDirsInDir(const QString &path)
|
2022-09-22 20:57:46 -04:00
|
|
|
{
|
2023-05-15 15:29:47 -04:00
|
|
|
QDir dirObj(path);
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
dirObj.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
|
|
|
|
dirObj.setSorting(QDir::Name);
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
return dirObj.entryList();
|
|
|
|
}
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-05-26 16:12:53 -04:00
|
|
|
QStringList listFacingFiles(const QString &path, const QString &ext, const QDateTime &stamp, int secs, char dir)
|
|
|
|
{
|
|
|
|
QStringList ret;
|
|
|
|
|
|
|
|
for (auto i = 0; i < secs; ++i)
|
|
|
|
{
|
|
|
|
QString filePath;
|
|
|
|
|
|
|
|
if (dir == '-') filePath = path + "/" + stamp.addSecs(-i).toString(DATETIME_FMT) + ext;
|
|
|
|
if (dir == '+') filePath = path + "/" + stamp.addSecs(i).toString(DATETIME_FMT) + ext;
|
|
|
|
|
|
|
|
if (QFile::exists(filePath))
|
|
|
|
{
|
|
|
|
if (dir == '-') ret.insert(0, filePath);
|
|
|
|
if (dir == '+') ret.append(filePath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList backwardFacingFiles(const QString &path, const QString &ext, const QDateTime &stamp, int secs)
|
|
|
|
{
|
|
|
|
return listFacingFiles(path, ext, stamp, secs, '-');
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList forwardFacingFiles(const QString &path, const QString &ext, const QDateTime &stamp, int secs)
|
|
|
|
{
|
|
|
|
return listFacingFiles(path, ext, stamp, secs, '+');
|
|
|
|
}
|
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
void enforceMaxEvents(shared_t *share)
|
|
|
|
{
|
2023-10-27 15:43:17 -04:00
|
|
|
auto names = lsFilesInDir(share->recPath, share->recExt);
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
while (names.size() > share->maxEvents)
|
|
|
|
{
|
2023-10-27 15:43:17 -04:00
|
|
|
auto nameOnly = share->recPath + "/" + names[0];
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-10-19 15:04:39 -04:00
|
|
|
nameOnly.chop(share->recExt.size());
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-10-19 15:04:39 -04:00
|
|
|
auto vidFile = nameOnly + share->recExt;
|
|
|
|
auto imgFile = nameOnly + share->thumbExt;
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-10-19 15:04:39 -04:00
|
|
|
QFile::remove(vidFile);
|
2023-05-15 15:29:47 -04:00
|
|
|
QFile::remove(imgFile);
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
names.removeFirst();
|
|
|
|
}
|
2023-04-20 14:52:59 -04:00
|
|
|
}
|
|
|
|
|
2023-10-19 15:04:39 -04:00
|
|
|
void enforceMaxImages(shared_t *share)
|
2023-05-26 16:12:53 -04:00
|
|
|
{
|
2023-10-27 15:43:17 -04:00
|
|
|
auto names = lsFilesInDir(share->buffPath + "/img", ".bmp");
|
2023-05-26 16:12:53 -04:00
|
|
|
|
2023-11-05 18:44:50 -05:00
|
|
|
while (names.size() > (share->liveSecs / 2))
|
2023-05-26 16:12:53 -04:00
|
|
|
{
|
2023-10-27 15:43:17 -04:00
|
|
|
QFile::remove(share->buffPath + "/img/" + names[0]);
|
2023-05-26 16:12:53 -04:00
|
|
|
|
|
|
|
names.removeFirst();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-05 18:44:50 -05:00
|
|
|
void enforceMaxClips(shared_t *share)
|
2023-06-09 16:24:32 -04:00
|
|
|
{
|
2023-10-27 15:43:17 -04:00
|
|
|
auto names = lsFilesInDir(share->buffPath + "/live", share->streamExt);
|
2023-06-09 16:24:32 -04:00
|
|
|
|
2023-11-05 18:44:50 -05:00
|
|
|
while (names.size() > (share->liveSecs / 2))
|
2023-06-09 16:24:32 -04:00
|
|
|
{
|
2023-10-27 15:43:17 -04:00
|
|
|
QFile::remove(share->buffPath + "/live/" + names[0]);
|
2023-06-09 16:24:32 -04:00
|
|
|
|
|
|
|
names.removeFirst();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
void rdLine(const QString ¶m, const QString &line, QString *value)
|
2022-09-22 20:57:46 -04:00
|
|
|
{
|
2023-05-15 15:29:47 -04:00
|
|
|
if (line.startsWith(param))
|
2022-09-22 20:57:46 -04:00
|
|
|
{
|
2023-10-27 15:43:17 -04:00
|
|
|
*value = line.mid(param.size()).trimmed();
|
2022-09-22 20:57:46 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
void rdLine(const QString ¶m, const QString &line, int *value)
|
2022-09-22 20:57:46 -04:00
|
|
|
{
|
2023-05-15 15:29:47 -04:00
|
|
|
if (line.startsWith(param))
|
2022-09-22 20:57:46 -04:00
|
|
|
{
|
2023-10-27 15:43:17 -04:00
|
|
|
*value = line.mid(param.size()).trimmed().toInt();
|
2022-09-22 20:57:46 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-08 10:09:15 -04:00
|
|
|
void rdLine(const QString ¶m, const QString &line, bool *value)
|
|
|
|
{
|
|
|
|
if (line.startsWith(param))
|
|
|
|
{
|
2023-10-19 15:04:39 -04:00
|
|
|
auto val = line.mid(param.size()).trimmed();
|
|
|
|
|
|
|
|
*value = (val == "y" || val == "Y");
|
2023-10-08 10:09:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 15:04:39 -04:00
|
|
|
void extCorrection(QString &ext)
|
2023-07-18 18:47:14 -04:00
|
|
|
{
|
2023-10-19 15:04:39 -04:00
|
|
|
if (!ext.startsWith("."))
|
2023-07-18 18:47:14 -04:00
|
|
|
{
|
2023-10-19 15:04:39 -04:00
|
|
|
ext = "." + ext;
|
2023-07-18 18:47:14 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 15:04:39 -04:00
|
|
|
bool mkPath(const QString &path)
|
2023-10-08 10:09:15 -04:00
|
|
|
{
|
2023-10-19 15:04:39 -04:00
|
|
|
auto ret = true;
|
|
|
|
|
|
|
|
if (!QDir().exists(path))
|
2023-10-08 10:09:15 -04:00
|
|
|
{
|
2023-10-19 15:04:39 -04:00
|
|
|
ret = QDir().mkpath(path);
|
2023-10-08 10:09:15 -04:00
|
|
|
}
|
2023-10-19 15:04:39 -04:00
|
|
|
|
|
|
|
return ret;
|
2023-10-08 10:09:15 -04:00
|
|
|
}
|
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
bool rdConf(const QString &filePath, shared_t *share)
|
2022-09-22 20:57:46 -04:00
|
|
|
{
|
2023-05-15 15:29:47 -04:00
|
|
|
QFile varFile(filePath);
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
if (!varFile.open(QFile::ReadOnly))
|
2022-09-22 20:57:46 -04:00
|
|
|
{
|
|
|
|
share->retCode = ENOENT;
|
|
|
|
|
2023-10-19 15:04:39 -04:00
|
|
|
QTextStream(stderr) << "err: config file - " << filePath << " does not exists or lack read permissions." << Qt::endl;
|
2022-09-22 20:57:46 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-08 10:09:15 -04:00
|
|
|
share->recordUri.clear();
|
2023-07-31 11:16:07 -04:00
|
|
|
share->postCmd.clear();
|
|
|
|
share->camName.clear();
|
2023-10-27 15:43:17 -04:00
|
|
|
share->buffPath.clear();
|
|
|
|
share->recPath.clear();
|
2023-12-23 17:38:11 -05:00
|
|
|
share->servGroup.clear();
|
2023-10-19 15:04:39 -04:00
|
|
|
|
|
|
|
auto thrCount = QThread::idealThreadCount() / 2;
|
2023-07-31 11:16:07 -04:00
|
|
|
|
2023-10-08 10:09:15 -04:00
|
|
|
share->retCode = 0;
|
|
|
|
share->imgThresh = 8000;
|
2023-11-05 18:44:50 -05:00
|
|
|
share->maxEvents = 30;
|
2023-10-08 10:09:15 -04:00
|
|
|
share->skipCmd = false;
|
|
|
|
share->postSecs = 60;
|
|
|
|
share->evMaxSecs = 30;
|
|
|
|
share->conf = filePath;
|
|
|
|
share->outputType = "stderr";
|
|
|
|
share->compCmd = "magick compare -metric FUZZ " + QString(PREV_IMG) + " " + QString(NEXT_IMG) + " /dev/null";
|
|
|
|
share->streamCodec = "copy";
|
2023-11-05 18:44:50 -05:00
|
|
|
share->streamExt = ".avi";
|
|
|
|
share->recExt = ".avi";
|
2023-10-08 10:09:15 -04:00
|
|
|
share->thumbExt = ".jpg";
|
2023-10-19 15:04:39 -04:00
|
|
|
share->recFps = 30;
|
2023-11-05 18:44:50 -05:00
|
|
|
share->liveSecs = 80;
|
2023-10-19 15:04:39 -04:00
|
|
|
share->recScale = "1280:720";
|
|
|
|
share->imgScale = "320:240";
|
2023-10-27 15:43:17 -04:00
|
|
|
share->servUser = APP_BIN;
|
2023-07-31 11:16:07 -04:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
QString line;
|
2022-09-22 20:57:46 -04:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2023-05-15 15:29:47 -04:00
|
|
|
line = QString::fromUtf8(varFile.readLine());
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
if (!line.startsWith("#"))
|
2022-09-22 20:57:46 -04:00
|
|
|
{
|
2023-10-08 10:09:15 -04:00
|
|
|
rdLine("cam_name = ", line, &share->camName);
|
|
|
|
rdLine("recording_uri = ", line, &share->recordUri);
|
|
|
|
rdLine("buffer_path = ", line, &share->buffPath);
|
2023-10-19 15:04:39 -04:00
|
|
|
rdLine("rec_path = ", line, &share->recPath);
|
2023-10-08 10:09:15 -04:00
|
|
|
rdLine("max_event_secs = ", line, &share->evMaxSecs);
|
|
|
|
rdLine("post_secs = ", line, &share->postSecs);
|
|
|
|
rdLine("post_cmd = ", line, &share->postCmd);
|
|
|
|
rdLine("img_thresh = ", line, &share->imgThresh);
|
|
|
|
rdLine("max_events = ", line, &share->maxEvents);
|
|
|
|
rdLine("img_comp_out = ", line, &share->outputType);
|
|
|
|
rdLine("img_comp_cmd = ", line, &share->compCmd);
|
|
|
|
rdLine("stream_codec = ", line, &share->streamCodec);
|
|
|
|
rdLine("stream_ext = ", line, &share->streamExt);
|
|
|
|
rdLine("rec_ext = ", line, &share->recExt);
|
|
|
|
rdLine("thumbnail_ext = ", line, &share->thumbExt);
|
2023-10-19 15:04:39 -04:00
|
|
|
rdLine("rec_fps = ", line, &share->recFps);
|
|
|
|
rdLine("rec_scale = ", line, &share->recScale);
|
|
|
|
rdLine("img_scale = ", line, &share->imgScale);
|
2023-10-27 15:43:17 -04:00
|
|
|
rdLine("service_user = ", line, &share->servUser);
|
2023-12-23 17:38:11 -05:00
|
|
|
rdLine("service_group = ", line, &share->servGroup);
|
2023-11-05 18:44:50 -05:00
|
|
|
rdLine("live_secs = ", line, &share->liveSecs);
|
2022-09-22 20:57:46 -04:00
|
|
|
}
|
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
} while(!line.isEmpty());
|
2022-12-24 13:48:51 -05:00
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
if (share->camName.isEmpty())
|
2023-02-05 14:05:56 -05:00
|
|
|
{
|
2023-11-05 18:44:50 -05:00
|
|
|
share->camName = QFileInfo(share->conf).baseName();
|
2023-02-05 14:05:56 -05:00
|
|
|
}
|
2023-10-08 10:09:15 -04:00
|
|
|
|
|
|
|
extCorrection(share->streamExt);
|
|
|
|
extCorrection(share->recExt);
|
|
|
|
extCorrection(share->thumbExt);
|
2023-11-05 18:44:50 -05:00
|
|
|
|
|
|
|
if (share->outputType != "stdout" && share->outputType != "stderr")
|
|
|
|
{
|
|
|
|
share->outputType = "stderr";
|
|
|
|
}
|
2023-10-08 10:09:15 -04:00
|
|
|
|
2023-10-27 15:43:17 -04:00
|
|
|
if (share->buffPath.isEmpty())
|
2023-10-08 10:09:15 -04:00
|
|
|
{
|
2023-10-27 15:43:17 -04:00
|
|
|
share->buffPath = "/var/buffer/" + share->camName;
|
2023-10-08 10:09:15 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-27 15:43:17 -04:00
|
|
|
share->buffPath = QDir::cleanPath(share->buffPath);
|
2023-10-08 10:09:15 -04:00
|
|
|
}
|
|
|
|
|
2023-10-27 15:43:17 -04:00
|
|
|
if (share->recPath.isEmpty())
|
2023-10-19 15:04:39 -04:00
|
|
|
{
|
2023-10-27 15:43:17 -04:00
|
|
|
share->recPath = "/var/footage/" + share->camName;
|
2023-10-19 15:04:39 -04:00
|
|
|
}
|
2023-10-27 15:43:17 -04:00
|
|
|
else
|
2023-10-19 15:04:39 -04:00
|
|
|
{
|
2023-10-27 15:43:17 -04:00
|
|
|
share->recPath = QDir::cleanPath(share->recPath);
|
2023-10-19 15:04:39 -04:00
|
|
|
}
|
2023-11-05 18:44:50 -05:00
|
|
|
|
|
|
|
if (share->liveSecs < 10)
|
|
|
|
{
|
|
|
|
share->liveSecs = 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((share->liveSecs - 4) < share->evMaxSecs)
|
|
|
|
{
|
|
|
|
share->evMaxSecs = share->liveSecs - 4;
|
|
|
|
}
|
2023-12-23 17:38:11 -05:00
|
|
|
|
|
|
|
if (share->servGroup.isEmpty())
|
2023-10-19 15:04:39 -04:00
|
|
|
{
|
2023-12-23 17:38:11 -05:00
|
|
|
share->servGroup = share->servUser;
|
2023-10-19 15:04:39 -04:00
|
|
|
}
|
2023-12-23 17:38:11 -05:00
|
|
|
|
|
|
|
share->servMainLoop = QString(APP_BIN) + ".main_loop." + share->camName;
|
|
|
|
share->servVidLoop = QString(APP_BIN) + ".vid_loop." + share->camName;
|
2022-09-22 20:57:46 -04:00
|
|
|
}
|
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
return share->retCode == 0;
|
2023-03-05 16:07:07 -05:00
|
|
|
}
|
2023-05-17 15:06:58 -04:00
|
|
|
|
2023-10-19 15:04:39 -04:00
|
|
|
QString buildThreadCount(int count)
|
|
|
|
{
|
|
|
|
QString ret = "0";
|
|
|
|
|
|
|
|
for (auto i = 1; i < count; ++i)
|
|
|
|
{
|
|
|
|
ret.append(","); ret.append(QString::number(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-08-06 10:17:10 -04:00
|
|
|
QStringList parseArgs(const QByteArray &data, int maxArgs, int *pos)
|
|
|
|
{
|
|
|
|
QStringList ret;
|
|
|
|
QString arg;
|
|
|
|
|
|
|
|
auto line = QString::fromUtf8(data);
|
|
|
|
auto inDQuotes = false;
|
|
|
|
auto inSQuotes = false;
|
|
|
|
auto escaped = false;
|
|
|
|
|
|
|
|
if (pos != nullptr) *pos = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < line.size(); ++i)
|
|
|
|
{
|
|
|
|
if (pos != nullptr) *pos += 1;
|
|
|
|
|
|
|
|
if ((line[i] == '\'') && !inDQuotes && !escaped)
|
|
|
|
{
|
|
|
|
// single quote '
|
|
|
|
|
|
|
|
inSQuotes = !inSQuotes;
|
|
|
|
}
|
|
|
|
else if ((line[i] == '\"') && !inSQuotes && !escaped)
|
|
|
|
{
|
|
|
|
// double quote "
|
|
|
|
|
|
|
|
inDQuotes = !inDQuotes;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
escaped = false;
|
|
|
|
|
|
|
|
if (line[i].isSpace() && !inDQuotes && !inSQuotes)
|
|
|
|
{
|
|
|
|
// space
|
|
|
|
|
|
|
|
if (!arg.isEmpty())
|
|
|
|
{
|
|
|
|
ret.append(arg);
|
|
|
|
arg.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((line[i] == '\\') && ((i + 1) < line.size()))
|
|
|
|
{
|
|
|
|
if ((line[i + 1] == '\'') || (line[i + 1] == '\"'))
|
|
|
|
{
|
|
|
|
escaped = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
arg.append(line[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
arg.append(line[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((ret.size() >= maxArgs) && (maxArgs != -1))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!arg.isEmpty() && !inDQuotes && !inSQuotes)
|
|
|
|
{
|
|
|
|
ret.append(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|