missing files
This commit is contained in:
parent
f3b84af062
commit
d4f49a20ba
65
console/terminal/console.h
Normal file
65
console/terminal/console.h
Normal file
@ -0,0 +1,65 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
|
||||
** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the QtSerialPort module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONSOLE_H
|
||||
#define CONSOLE_H
|
||||
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
class Console : public QPlainTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
void getData(const QString &data);
|
||||
|
||||
public:
|
||||
explicit Console(QWidget *parent = 0);
|
||||
|
||||
void putData(const QString &data);
|
||||
|
||||
void setLocalEchoEnabled(bool set);
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent *e);
|
||||
virtual void mousePressEvent(QMouseEvent *e);
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *e);
|
||||
virtual void contextMenuEvent(QContextMenuEvent *e);
|
||||
|
||||
private:
|
||||
bool localEchoEnabled;
|
||||
|
||||
};
|
||||
|
||||
#endif // CONSOLE_H
|
84
console/terminal/mainwindow.h
Normal file
84
console/terminal/mainwindow.h
Normal file
@ -0,0 +1,84 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
|
||||
** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the QtSerialPort module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
#include <yapi.hh>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class Console;
|
||||
class SettingsDialog;
|
||||
|
||||
|
||||
|
||||
class MainWindow : public QMainWindow, public YAPEngine
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
private slots:
|
||||
void startYAP(YAPEngine *&eng);
|
||||
void stopYAP(YAPEngine *eng);
|
||||
void about();
|
||||
void writeData(const QString &data);
|
||||
void readData();
|
||||
|
||||
void handleError(YAPError error);
|
||||
|
||||
private:
|
||||
void initActionsConnections();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
Console *console;
|
||||
SettingsDialog *settings;
|
||||
YAPEngine *eng;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
95
console/terminal/settingsdialog.h
Normal file
95
console/terminal/settingsdialog.h
Normal file
@ -0,0 +1,95 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
|
||||
** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the QtSerialPort module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef SETTINGSDIALOG_H
|
||||
#define SETTINGSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace Ui {
|
||||
class SettingsDialog;
|
||||
}
|
||||
|
||||
class QIntValidator;
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class SettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
struct Settings {
|
||||
QString name;
|
||||
qint32 baudRate;
|
||||
QString stringBaudRate;
|
||||
QSerialPort::DataBits dataBits;
|
||||
QString stringDataBits;
|
||||
QSerialPort::Parity parity;
|
||||
QString stringParity;
|
||||
QSerialPort::StopBits stopBits;
|
||||
QString stringStopBits;
|
||||
QSerialPort::FlowControl flowControl;
|
||||
QString stringFlowControl;
|
||||
bool localEchoEnabled;
|
||||
};
|
||||
|
||||
explicit SettingsDialog(QWidget *parent = 0);
|
||||
~SettingsDialog();
|
||||
|
||||
Settings settings() const;
|
||||
|
||||
private slots:
|
||||
void showPortInfo(int idx);
|
||||
void apply();
|
||||
void checkCustomBaudRatePolicy(int idx);
|
||||
void checkCustomDevicePathPolicy(int idx);
|
||||
|
||||
private:
|
||||
void fillPortsParameters();
|
||||
void fillPortsInfo();
|
||||
void updateSettings();
|
||||
|
||||
private:
|
||||
Ui::SettingsDialog *ui;
|
||||
Settings currentSettings;
|
||||
QIntValidator *intValidator;
|
||||
};
|
||||
|
||||
#endif // SETTINGSDIALOG_H
|
169
console/terminal/ui_mainwindow.h
Normal file
169
console/terminal/ui_mainwindow.h
Normal file
@ -0,0 +1,169 @@
|
||||
/********************************************************************************
|
||||
** Form generated from reading UI file 'mainwindow.ui'
|
||||
**
|
||||
** Created by: Qt User Interface Compiler version 5.4.2
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef UI_MAINWINDOW_H
|
||||
#define UI_MAINWINDOW_H
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtWidgets/QAction>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QButtonGroup>
|
||||
#include <QtWidgets/QHeaderView>
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <QtWidgets/QMenu>
|
||||
#include <QtWidgets/QMenuBar>
|
||||
#include <QtWidgets/QStatusBar>
|
||||
#include <QtWidgets/QToolBar>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class Ui_MainWindow
|
||||
{
|
||||
public:
|
||||
QAction *actionAbout;
|
||||
QAction *actionAboutQt;
|
||||
QAction *actionConnect;
|
||||
QAction *actionDisconnect;
|
||||
QAction *actionConfigure;
|
||||
QAction *actionClear;
|
||||
QAction *actionQuit;
|
||||
QWidget *centralWidget;
|
||||
QVBoxLayout *verticalLayout;
|
||||
QMenuBar *menuBar;
|
||||
QMenu *menuCalls;
|
||||
QMenu *menuTools;
|
||||
QMenu *menuHelp;
|
||||
QToolBar *mainToolBar;
|
||||
QStatusBar *statusBar;
|
||||
|
||||
void setupUi(QMainWindow *MainWindow)
|
||||
{
|
||||
if (MainWindow->objectName().isEmpty())
|
||||
MainWindow->setObjectName(QStringLiteral("MainWindow"));
|
||||
MainWindow->resize(400, 300);
|
||||
actionAbout = new QAction(MainWindow);
|
||||
actionAbout->setObjectName(QStringLiteral("actionAbout"));
|
||||
actionAboutQt = new QAction(MainWindow);
|
||||
actionAboutQt->setObjectName(QStringLiteral("actionAboutQt"));
|
||||
actionConnect = new QAction(MainWindow);
|
||||
actionConnect->setObjectName(QStringLiteral("actionConnect"));
|
||||
QIcon icon;
|
||||
icon.addFile(QStringLiteral(":/images/connect.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
actionConnect->setIcon(icon);
|
||||
actionDisconnect = new QAction(MainWindow);
|
||||
actionDisconnect->setObjectName(QStringLiteral("actionDisconnect"));
|
||||
QIcon icon1;
|
||||
icon1.addFile(QStringLiteral(":/images/disconnect.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
actionDisconnect->setIcon(icon1);
|
||||
actionConfigure = new QAction(MainWindow);
|
||||
actionConfigure->setObjectName(QStringLiteral("actionConfigure"));
|
||||
QIcon icon2;
|
||||
icon2.addFile(QStringLiteral(":/images/settings.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
actionConfigure->setIcon(icon2);
|
||||
actionClear = new QAction(MainWindow);
|
||||
actionClear->setObjectName(QStringLiteral("actionClear"));
|
||||
QIcon icon3;
|
||||
icon3.addFile(QStringLiteral(":/images/clear.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
actionClear->setIcon(icon3);
|
||||
actionQuit = new QAction(MainWindow);
|
||||
actionQuit->setObjectName(QStringLiteral("actionQuit"));
|
||||
QIcon icon4;
|
||||
icon4.addFile(QStringLiteral(":/images/application-exit.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
actionQuit->setIcon(icon4);
|
||||
centralWidget = new QWidget(MainWindow);
|
||||
centralWidget->setObjectName(QStringLiteral("centralWidget"));
|
||||
verticalLayout = new QVBoxLayout(centralWidget);
|
||||
verticalLayout->setSpacing(6);
|
||||
verticalLayout->setContentsMargins(11, 11, 11, 11);
|
||||
verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
|
||||
MainWindow->setCentralWidget(centralWidget);
|
||||
menuBar = new QMenuBar(MainWindow);
|
||||
menuBar->setObjectName(QStringLiteral("menuBar"));
|
||||
menuBar->setGeometry(QRect(0, 0, 400, 19));
|
||||
menuCalls = new QMenu(menuBar);
|
||||
menuCalls->setObjectName(QStringLiteral("menuCalls"));
|
||||
menuTools = new QMenu(menuBar);
|
||||
menuTools->setObjectName(QStringLiteral("menuTools"));
|
||||
menuHelp = new QMenu(menuBar);
|
||||
menuHelp->setObjectName(QStringLiteral("menuHelp"));
|
||||
MainWindow->setMenuBar(menuBar);
|
||||
mainToolBar = new QToolBar(MainWindow);
|
||||
mainToolBar->setObjectName(QStringLiteral("mainToolBar"));
|
||||
MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar);
|
||||
statusBar = new QStatusBar(MainWindow);
|
||||
statusBar->setObjectName(QStringLiteral("statusBar"));
|
||||
MainWindow->setStatusBar(statusBar);
|
||||
|
||||
menuBar->addAction(menuCalls->menuAction());
|
||||
menuBar->addAction(menuTools->menuAction());
|
||||
menuBar->addAction(menuHelp->menuAction());
|
||||
menuCalls->addAction(actionConnect);
|
||||
menuCalls->addAction(actionDisconnect);
|
||||
menuCalls->addSeparator();
|
||||
menuCalls->addAction(actionQuit);
|
||||
menuTools->addAction(actionConfigure);
|
||||
menuTools->addAction(actionClear);
|
||||
menuHelp->addAction(actionAbout);
|
||||
menuHelp->addAction(actionAboutQt);
|
||||
mainToolBar->addAction(actionConnect);
|
||||
mainToolBar->addAction(actionDisconnect);
|
||||
mainToolBar->addAction(actionConfigure);
|
||||
mainToolBar->addAction(actionClear);
|
||||
|
||||
retranslateUi(MainWindow);
|
||||
|
||||
QMetaObject::connectSlotsByName(MainWindow);
|
||||
} // setupUi
|
||||
|
||||
void retranslateUi(QMainWindow *MainWindow)
|
||||
{
|
||||
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "Simple Terminal", 0));
|
||||
actionAbout->setText(QApplication::translate("MainWindow", "&About", 0));
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
actionAbout->setToolTip(QApplication::translate("MainWindow", "About program", 0));
|
||||
#endif // QT_NO_TOOLTIP
|
||||
actionAbout->setShortcut(QApplication::translate("MainWindow", "Alt+A", 0));
|
||||
actionAboutQt->setText(QApplication::translate("MainWindow", "About Qt", 0));
|
||||
actionConnect->setText(QApplication::translate("MainWindow", "C&onnect", 0));
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
actionConnect->setToolTip(QApplication::translate("MainWindow", "Connect to serial port", 0));
|
||||
#endif // QT_NO_TOOLTIP
|
||||
actionConnect->setShortcut(QApplication::translate("MainWindow", "Ctrl+O", 0));
|
||||
actionDisconnect->setText(QApplication::translate("MainWindow", "&Disconnect", 0));
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
actionDisconnect->setToolTip(QApplication::translate("MainWindow", "Disconnect from serial port", 0));
|
||||
#endif // QT_NO_TOOLTIP
|
||||
actionDisconnect->setShortcut(QApplication::translate("MainWindow", "Ctrl+D", 0));
|
||||
actionConfigure->setText(QApplication::translate("MainWindow", "&Configure", 0));
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
actionConfigure->setToolTip(QApplication::translate("MainWindow", "Configure serial port", 0));
|
||||
#endif // QT_NO_TOOLTIP
|
||||
actionConfigure->setShortcut(QApplication::translate("MainWindow", "Alt+C", 0));
|
||||
actionClear->setText(QApplication::translate("MainWindow", "C&lear", 0));
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
actionClear->setToolTip(QApplication::translate("MainWindow", "Clear data", 0));
|
||||
#endif // QT_NO_TOOLTIP
|
||||
actionClear->setShortcut(QApplication::translate("MainWindow", "Alt+L", 0));
|
||||
actionQuit->setText(QApplication::translate("MainWindow", "&Quit", 0));
|
||||
actionQuit->setShortcut(QApplication::translate("MainWindow", "Ctrl+Q", 0));
|
||||
menuCalls->setTitle(QApplication::translate("MainWindow", "Calls", 0));
|
||||
menuTools->setTitle(QApplication::translate("MainWindow", "Tools", 0));
|
||||
menuHelp->setTitle(QApplication::translate("MainWindow", "Help", 0));
|
||||
} // retranslateUi
|
||||
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow: public Ui_MainWindow {};
|
||||
} // namespace Ui
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // UI_MAINWINDOW_H
|
230
console/terminal/ui_settingsdialog.h
Normal file
230
console/terminal/ui_settingsdialog.h
Normal file
@ -0,0 +1,230 @@
|
||||
/********************************************************************************
|
||||
** Form generated from reading UI file 'settingsdialog.ui'
|
||||
**
|
||||
** Created by: Qt User Interface Compiler version 5.4.2
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef UI_SETTINGSDIALOG_H
|
||||
#define UI_SETTINGSDIALOG_H
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtWidgets/QAction>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QButtonGroup>
|
||||
#include <QtWidgets/QCheckBox>
|
||||
#include <QtWidgets/QComboBox>
|
||||
#include <QtWidgets/QDialog>
|
||||
#include <QtWidgets/QGridLayout>
|
||||
#include <QtWidgets/QGroupBox>
|
||||
#include <QtWidgets/QHBoxLayout>
|
||||
#include <QtWidgets/QHeaderView>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QSpacerItem>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class Ui_SettingsDialog
|
||||
{
|
||||
public:
|
||||
QGridLayout *gridLayout_3;
|
||||
QGroupBox *parametersBox;
|
||||
QGridLayout *gridLayout_2;
|
||||
QLabel *baudRateLabel;
|
||||
QComboBox *baudRateBox;
|
||||
QLabel *dataBitsLabel;
|
||||
QComboBox *dataBitsBox;
|
||||
QLabel *parityLabel;
|
||||
QComboBox *parityBox;
|
||||
QLabel *stopBitsLabel;
|
||||
QComboBox *stopBitsBox;
|
||||
QLabel *flowControlLabel;
|
||||
QComboBox *flowControlBox;
|
||||
QGroupBox *selectBox;
|
||||
QGridLayout *gridLayout;
|
||||
QComboBox *serialPortInfoListBox;
|
||||
QLabel *descriptionLabel;
|
||||
QLabel *manufacturerLabel;
|
||||
QLabel *serialNumberLabel;
|
||||
QLabel *locationLabel;
|
||||
QLabel *vidLabel;
|
||||
QLabel *pidLabel;
|
||||
QHBoxLayout *horizontalLayout;
|
||||
QSpacerItem *horizontalSpacer;
|
||||
QPushButton *applyButton;
|
||||
QGroupBox *additionalOptionsGroupBox;
|
||||
QVBoxLayout *verticalLayout;
|
||||
QCheckBox *localEchoCheckBox;
|
||||
|
||||
void setupUi(QDialog *SettingsDialog)
|
||||
{
|
||||
if (SettingsDialog->objectName().isEmpty())
|
||||
SettingsDialog->setObjectName(QStringLiteral("SettingsDialog"));
|
||||
SettingsDialog->resize(281, 262);
|
||||
gridLayout_3 = new QGridLayout(SettingsDialog);
|
||||
gridLayout_3->setObjectName(QStringLiteral("gridLayout_3"));
|
||||
parametersBox = new QGroupBox(SettingsDialog);
|
||||
parametersBox->setObjectName(QStringLiteral("parametersBox"));
|
||||
gridLayout_2 = new QGridLayout(parametersBox);
|
||||
gridLayout_2->setObjectName(QStringLiteral("gridLayout_2"));
|
||||
baudRateLabel = new QLabel(parametersBox);
|
||||
baudRateLabel->setObjectName(QStringLiteral("baudRateLabel"));
|
||||
|
||||
gridLayout_2->addWidget(baudRateLabel, 0, 0, 1, 1);
|
||||
|
||||
baudRateBox = new QComboBox(parametersBox);
|
||||
baudRateBox->setObjectName(QStringLiteral("baudRateBox"));
|
||||
|
||||
gridLayout_2->addWidget(baudRateBox, 0, 1, 1, 1);
|
||||
|
||||
dataBitsLabel = new QLabel(parametersBox);
|
||||
dataBitsLabel->setObjectName(QStringLiteral("dataBitsLabel"));
|
||||
|
||||
gridLayout_2->addWidget(dataBitsLabel, 1, 0, 1, 1);
|
||||
|
||||
dataBitsBox = new QComboBox(parametersBox);
|
||||
dataBitsBox->setObjectName(QStringLiteral("dataBitsBox"));
|
||||
|
||||
gridLayout_2->addWidget(dataBitsBox, 1, 1, 1, 1);
|
||||
|
||||
parityLabel = new QLabel(parametersBox);
|
||||
parityLabel->setObjectName(QStringLiteral("parityLabel"));
|
||||
|
||||
gridLayout_2->addWidget(parityLabel, 2, 0, 1, 1);
|
||||
|
||||
parityBox = new QComboBox(parametersBox);
|
||||
parityBox->setObjectName(QStringLiteral("parityBox"));
|
||||
|
||||
gridLayout_2->addWidget(parityBox, 2, 1, 1, 1);
|
||||
|
||||
stopBitsLabel = new QLabel(parametersBox);
|
||||
stopBitsLabel->setObjectName(QStringLiteral("stopBitsLabel"));
|
||||
|
||||
gridLayout_2->addWidget(stopBitsLabel, 3, 0, 1, 1);
|
||||
|
||||
stopBitsBox = new QComboBox(parametersBox);
|
||||
stopBitsBox->setObjectName(QStringLiteral("stopBitsBox"));
|
||||
|
||||
gridLayout_2->addWidget(stopBitsBox, 3, 1, 1, 1);
|
||||
|
||||
flowControlLabel = new QLabel(parametersBox);
|
||||
flowControlLabel->setObjectName(QStringLiteral("flowControlLabel"));
|
||||
|
||||
gridLayout_2->addWidget(flowControlLabel, 4, 0, 1, 1);
|
||||
|
||||
flowControlBox = new QComboBox(parametersBox);
|
||||
flowControlBox->setObjectName(QStringLiteral("flowControlBox"));
|
||||
|
||||
gridLayout_2->addWidget(flowControlBox, 4, 1, 1, 1);
|
||||
|
||||
|
||||
gridLayout_3->addWidget(parametersBox, 0, 1, 1, 1);
|
||||
|
||||
selectBox = new QGroupBox(SettingsDialog);
|
||||
selectBox->setObjectName(QStringLiteral("selectBox"));
|
||||
gridLayout = new QGridLayout(selectBox);
|
||||
gridLayout->setObjectName(QStringLiteral("gridLayout"));
|
||||
serialPortInfoListBox = new QComboBox(selectBox);
|
||||
serialPortInfoListBox->setObjectName(QStringLiteral("serialPortInfoListBox"));
|
||||
|
||||
gridLayout->addWidget(serialPortInfoListBox, 0, 0, 1, 1);
|
||||
|
||||
descriptionLabel = new QLabel(selectBox);
|
||||
descriptionLabel->setObjectName(QStringLiteral("descriptionLabel"));
|
||||
|
||||
gridLayout->addWidget(descriptionLabel, 1, 0, 1, 1);
|
||||
|
||||
manufacturerLabel = new QLabel(selectBox);
|
||||
manufacturerLabel->setObjectName(QStringLiteral("manufacturerLabel"));
|
||||
|
||||
gridLayout->addWidget(manufacturerLabel, 2, 0, 1, 1);
|
||||
|
||||
serialNumberLabel = new QLabel(selectBox);
|
||||
serialNumberLabel->setObjectName(QStringLiteral("serialNumberLabel"));
|
||||
|
||||
gridLayout->addWidget(serialNumberLabel, 3, 0, 1, 1);
|
||||
|
||||
locationLabel = new QLabel(selectBox);
|
||||
locationLabel->setObjectName(QStringLiteral("locationLabel"));
|
||||
|
||||
gridLayout->addWidget(locationLabel, 4, 0, 1, 1);
|
||||
|
||||
vidLabel = new QLabel(selectBox);
|
||||
vidLabel->setObjectName(QStringLiteral("vidLabel"));
|
||||
|
||||
gridLayout->addWidget(vidLabel, 5, 0, 1, 1);
|
||||
|
||||
pidLabel = new QLabel(selectBox);
|
||||
pidLabel->setObjectName(QStringLiteral("pidLabel"));
|
||||
|
||||
gridLayout->addWidget(pidLabel, 6, 0, 1, 1);
|
||||
|
||||
|
||||
gridLayout_3->addWidget(selectBox, 0, 0, 1, 1);
|
||||
|
||||
horizontalLayout = new QHBoxLayout();
|
||||
horizontalLayout->setObjectName(QStringLiteral("horizontalLayout"));
|
||||
horizontalSpacer = new QSpacerItem(96, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
|
||||
horizontalLayout->addItem(horizontalSpacer);
|
||||
|
||||
applyButton = new QPushButton(SettingsDialog);
|
||||
applyButton->setObjectName(QStringLiteral("applyButton"));
|
||||
|
||||
horizontalLayout->addWidget(applyButton);
|
||||
|
||||
|
||||
gridLayout_3->addLayout(horizontalLayout, 2, 0, 1, 2);
|
||||
|
||||
additionalOptionsGroupBox = new QGroupBox(SettingsDialog);
|
||||
additionalOptionsGroupBox->setObjectName(QStringLiteral("additionalOptionsGroupBox"));
|
||||
verticalLayout = new QVBoxLayout(additionalOptionsGroupBox);
|
||||
verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
|
||||
localEchoCheckBox = new QCheckBox(additionalOptionsGroupBox);
|
||||
localEchoCheckBox->setObjectName(QStringLiteral("localEchoCheckBox"));
|
||||
localEchoCheckBox->setChecked(true);
|
||||
|
||||
verticalLayout->addWidget(localEchoCheckBox);
|
||||
|
||||
|
||||
gridLayout_3->addWidget(additionalOptionsGroupBox, 1, 0, 1, 2);
|
||||
|
||||
|
||||
retranslateUi(SettingsDialog);
|
||||
|
||||
QMetaObject::connectSlotsByName(SettingsDialog);
|
||||
} // setupUi
|
||||
|
||||
void retranslateUi(QDialog *SettingsDialog)
|
||||
{
|
||||
SettingsDialog->setWindowTitle(QApplication::translate("SettingsDialog", "Settings", 0));
|
||||
parametersBox->setTitle(QApplication::translate("SettingsDialog", "Select Parameters", 0));
|
||||
baudRateLabel->setText(QApplication::translate("SettingsDialog", "BaudRate:", 0));
|
||||
dataBitsLabel->setText(QApplication::translate("SettingsDialog", "Data bits:", 0));
|
||||
parityLabel->setText(QApplication::translate("SettingsDialog", "Parity:", 0));
|
||||
stopBitsLabel->setText(QApplication::translate("SettingsDialog", "Stop bits:", 0));
|
||||
flowControlLabel->setText(QApplication::translate("SettingsDialog", "Flow control:", 0));
|
||||
selectBox->setTitle(QApplication::translate("SettingsDialog", "Select Serial Port", 0));
|
||||
descriptionLabel->setText(QApplication::translate("SettingsDialog", "Description:", 0));
|
||||
manufacturerLabel->setText(QApplication::translate("SettingsDialog", "Manufacturer:", 0));
|
||||
serialNumberLabel->setText(QApplication::translate("SettingsDialog", "Serial number:", 0));
|
||||
locationLabel->setText(QApplication::translate("SettingsDialog", "Location:", 0));
|
||||
vidLabel->setText(QApplication::translate("SettingsDialog", "Vendor ID:", 0));
|
||||
pidLabel->setText(QApplication::translate("SettingsDialog", "Product ID:", 0));
|
||||
applyButton->setText(QApplication::translate("SettingsDialog", "Apply", 0));
|
||||
additionalOptionsGroupBox->setTitle(QApplication::translate("SettingsDialog", "Additional options", 0));
|
||||
localEchoCheckBox->setText(QApplication::translate("SettingsDialog", "Local echo", 0));
|
||||
} // retranslateUi
|
||||
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class SettingsDialog: public Ui_SettingsDialog {};
|
||||
} // namespace Ui
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // UI_SETTINGSDIALOG_H
|
63
library/readutil.yap
Normal file
63
library/readutil.yap
Normal file
@ -0,0 +1,63 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: readutil.yap *
|
||||
* Last rev: 5/12/99 *
|
||||
* mods: *
|
||||
* comments: SWI compatible read utilities *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
:- module(readutil, [
|
||||
read_line_to_codes/2,
|
||||
read_line_to_codes/3,
|
||||
read_stream_to_codes/2,
|
||||
read_stream_to_codes/3,
|
||||
read_file_to_codes/2,
|
||||
read_file_to_codes/3,
|
||||
read_file_to_terms/2,
|
||||
read_file_to_terms/3
|
||||
]).
|
||||
|
||||
|
||||
read_stream_to_codes(Stream, Codes) :-
|
||||
read_stream_to_codes(Stream, Codes, []).
|
||||
|
||||
read_file_to_codes(File, Codes, _) :-
|
||||
open(File, read, Stream),
|
||||
read_stream_to_codes(Stream, Codes, []),
|
||||
close(Stream).
|
||||
|
||||
read_file_to_codes(File, Codes) :-
|
||||
open(File, read, Stream),
|
||||
read_stream_to_codes(Stream, Codes, []),
|
||||
close(Stream).
|
||||
|
||||
read_file_to_terms(File, Codes, _) :-
|
||||
open(File, read, Stream),
|
||||
prolog_read_stream_to_terms(Stream, Codes, []),
|
||||
close(Stream).
|
||||
|
||||
read_file_to_terms(File, Codes) :-
|
||||
open(File, read, Stream),
|
||||
read_stream_to_terms(Stream, Codes, []),
|
||||
close(Stream).
|
||||
|
||||
|
||||
prolog_read_stream_to_terms(Stream, Terms, Terms0) :-
|
||||
read(Stream, Term),
|
||||
(Term == end_of_file ->
|
||||
Terms = Terms0
|
||||
;
|
||||
Terms = [Term|TermsI],
|
||||
prolog_read_stream_to_terms(Stream, TermsI, Terms0)
|
||||
).
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
|
@ -24,6 +24,7 @@ static char SccsId[] = "%W% %G%";
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
|
@ -222,7 +222,8 @@ write_term ( int output_stream, Term t, xarg *args USES_REGS )
|
||||
flags |= Handle_vars_f;
|
||||
}
|
||||
if (args[WRITE_NUMBERVARS].used) {
|
||||
flags |= Handle_vars_f;
|
||||
if (args[WRITE_NUMBERVARS].tvalue == TermTrue)
|
||||
flags |= Handle_vars_f;
|
||||
}
|
||||
if (args[WRITE_ATTRIBUTES].used) {
|
||||
Term ctl = args[WRITE_ATTRIBUTES].tvalue;
|
||||
@ -364,7 +365,9 @@ write2 ( USES_REGS1 )
|
||||
if (args == NULL)
|
||||
return false;
|
||||
int output_stream = Yap_CheckStream (ARG1, Output_Stream_f, "write/2");
|
||||
write_term( output_stream, ARG2, args PASS_REGS);
|
||||
args[WRITE_NUMBERVARS].used = true;
|
||||
args[WRITE_NUMBERVARS].tvalue = TermTrue;
|
||||
write_term( output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
@ -386,6 +389,8 @@ write1 ( USES_REGS1 )
|
||||
int output_stream = LOCAL_c_output_stream;
|
||||
if (output_stream == -1) output_stream = 1;
|
||||
xarg * args = Yap_ArgListToVector ( TermNil, write_defs, WRITE_END );
|
||||
args[WRITE_NUMBERVARS].used = true;
|
||||
args[WRITE_NUMBERVARS].tvalue = TermTrue;
|
||||
if (args == NULL)
|
||||
return false;
|
||||
LOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
@ -582,10 +587,12 @@ writeln1 ( USES_REGS1 )
|
||||
xarg *args = Yap_ArgListToVector ( TermNil, write_defs, WRITE_END );
|
||||
if (args == NULL)
|
||||
return false;
|
||||
args[WRITE_NL].used = true;
|
||||
args[WRITE_NL].used = true;
|
||||
args[WRITE_NL].tvalue = TermTrue;
|
||||
args[WRITE_NUMBERVARS].used = true;
|
||||
args[WRITE_NUMBERVARS].tvalue = TermTrue;
|
||||
LOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
write_term( output_stream, ARG1, args PASS_REGS);
|
||||
write_term( output_stream, ARG1, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
@ -613,7 +620,9 @@ writeln ( USES_REGS1 )
|
||||
return false;
|
||||
args[WRITE_NL].used = true;
|
||||
args[WRITE_NL].tvalue = TermTrue;
|
||||
write_term( output_stream, ARG1, args PASS_REGS);
|
||||
args[WRITE_NUMBERVARS].used = true;
|
||||
args[WRITE_NUMBERVARS].tvalue = TermTrue;
|
||||
write_term( output_stream, ARG1, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
|
298
packages/bdd/simplecudd/general.c
Normal file
298
packages/bdd/simplecudd/general.c
Normal file
@ -0,0 +1,298 @@
|
||||
/******************************************************************************\
|
||||
* *
|
||||
* SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) *
|
||||
* SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) *
|
||||
* *
|
||||
* Copyright Katholieke Universiteit Leuven 2008, 2009, 2010 *
|
||||
* *
|
||||
* Author: Theofrastos Mantadelis *
|
||||
* File: general.c *
|
||||
* $Date:: 2010-10-06 13:20:59 +0200 (Wed, 06 Oct 2010) $ *
|
||||
* $Revision:: 4880 $ *
|
||||
* *
|
||||
********************************************************************************
|
||||
* *
|
||||
* Artistic License 2.0 *
|
||||
* *
|
||||
* Copyright (c) 2000-2006, The Perl Foundation. *
|
||||
* *
|
||||
* Everyone is permitted to copy and distribute verbatim copies of this license *
|
||||
* document, but changing it is not allowed. *
|
||||
* *
|
||||
* Preamble *
|
||||
* *
|
||||
* This license establishes the terms under which a given free software Package *
|
||||
* may be copied, modified, distributed, and/or redistributed. The intent is *
|
||||
* that the Copyright Holder maintains some artistic control over the *
|
||||
* development of that Package while still keeping the Package available as *
|
||||
* open source and free software. *
|
||||
* *
|
||||
* You are always permitted to make arrangements wholly outside of this license *
|
||||
* directly with the Copyright Holder of a given Package. If the terms of this *
|
||||
* license do not permit the full use that you propose to make of the Package, *
|
||||
* you should contact the Copyright Holder and seek a different licensing *
|
||||
* arrangement. *
|
||||
* Definitions *
|
||||
* *
|
||||
* "Copyright Holder" means the individual(s) or organization(s) named in the *
|
||||
* copyright notice for the entire Package. *
|
||||
* *
|
||||
* "Contributor" means any party that has contributed code or other material to *
|
||||
* the Package, in accordance with the Copyright Holder's procedures. *
|
||||
* *
|
||||
* "You" and "your" means any person who would like to copy, distribute, or *
|
||||
* modify the Package. *
|
||||
* *
|
||||
* "Package" means the collection of files distributed by the Copyright Holder, *
|
||||
* and derivatives of that collection and/or of those files. A given Package *
|
||||
* may consist of either the Standard Version, or a Modified Version. *
|
||||
* *
|
||||
* "Distribute" means providing a copy of the Package or making it accessible *
|
||||
* to anyone else, or in the case of a company or organization, to others *
|
||||
* outside of your company or organization. *
|
||||
* *
|
||||
* "Distributor Fee" means any fee that you charge for Distributing this *
|
||||
* Package or providing support for this Package to another party. It does not *
|
||||
* mean licensing fees. *
|
||||
* *
|
||||
* "Standard Version" refers to the Package if it has not been modified, or has *
|
||||
* been modified only in ways explicitly requested by the Copyright Holder. *
|
||||
* *
|
||||
* "Modified Version" means the Package, if it has been changed, and such *
|
||||
* changes were not explicitly requested by the Copyright Holder. *
|
||||
* *
|
||||
* "Original License" means this Artistic License as Distributed with the *
|
||||
* Standard Version of the Package, in its current version or as it may be *
|
||||
* modified by The Perl Foundation in the future. *
|
||||
* *
|
||||
* "Source" form means the source code, documentation source, and configuration *
|
||||
* files for the Package. *
|
||||
* *
|
||||
* "Compiled" form means the compiled bytecode, object code, binary, or any *
|
||||
* other form resulting from mechanical transformation or translation of the *
|
||||
* Source form. *
|
||||
* Permission for Use and Modification Without Distribution *
|
||||
* *
|
||||
* (1) You are permitted to use the Standard Version and create and use *
|
||||
* Modified Versions for any purpose without restriction, provided that you do *
|
||||
* not Distribute the Modified Version. *
|
||||
* Permissions for Redistribution of the Standard Version *
|
||||
* *
|
||||
* (2) You may Distribute verbatim copies of the Source form of the Standard *
|
||||
* Version of this Package in any medium without restriction, either gratis or *
|
||||
* for a Distributor Fee, provided that you duplicate all of the original *
|
||||
* copyright notices and associated disclaimers. At your discretion, such *
|
||||
* verbatim copies may or may not include a Compiled form of the Package. *
|
||||
* *
|
||||
* (3) You may apply any bug fixes, portability changes, and other *
|
||||
* modifications made available from the Copyright Holder. The resulting *
|
||||
* Package will still be considered the Standard Version, and as such will be *
|
||||
* subject to the Original License. *
|
||||
* Distribution of Modified Versions of the Package as Source *
|
||||
* *
|
||||
* (4) You may Distribute your Modified Version as Source (either gratis or for *
|
||||
* a Distributor Fee, and with or without a Compiled form of the Modified *
|
||||
* Version) provided that you clearly document how it differs from the Standard *
|
||||
* Version, including, but not limited to, documenting any non-standard *
|
||||
* features, executables, or modules, and provided that you do at least ONE of *
|
||||
* the following: *
|
||||
* *
|
||||
* (a) make the Modified Version available to the Copyright Holder of the *
|
||||
* Standard Version, under the Original License, so that the Copyright Holder *
|
||||
* may include your modifications in the Standard Version. *
|
||||
* (b) ensure that installation of your Modified Version does not prevent the *
|
||||
* user installing or running the Standard Version. In addition, the Modified *
|
||||
* Version must bear a name that is different from the name of the Standard *
|
||||
* Version. *
|
||||
* (c) allow anyone who receives a copy of the Modified Version to make the *
|
||||
* Source form of the Modified Version available to others under *
|
||||
* (i) the Original License or *
|
||||
* (ii) a license that permits the licensee to freely copy, modify and *
|
||||
* redistribute the Modified Version using the same licensing terms that apply *
|
||||
* to the copy that the licensee received, and requires that the Source form of *
|
||||
* the Modified Version, and of any works derived from it, be made freely *
|
||||
* available in that license fees are prohibited but Distributor Fees are *
|
||||
* allowed. *
|
||||
* Distribution of Compiled Forms of the Standard Version or Modified Versions *
|
||||
* without the Source *
|
||||
* *
|
||||
* (5) You may Distribute Compiled forms of the Standard Version without the *
|
||||
* Source, provided that you include complete instructions on how to get the *
|
||||
* Source of the Standard Version. Such instructions must be valid at the time *
|
||||
* of your distribution. If these instructions, at any time while you are *
|
||||
* carrying out such distribution, become invalid, you must provide new *
|
||||
* instructions on demand or cease further distribution. If you provide valid *
|
||||
* instructions or cease distribution within thirty days after you become aware *
|
||||
* that the instructions are invalid, then you do not forfeit any of your *
|
||||
* rights under this license. *
|
||||
* *
|
||||
* (6) You may Distribute a Modified Version in Compiled form without the *
|
||||
* Source, provided that you comply with Section 4 with respect to the Source *
|
||||
* of the Modified Version. *
|
||||
* Aggregating or Linking the Package *
|
||||
* *
|
||||
* (7) You may aggregate the Package (either the Standard Version or Modified *
|
||||
* Version) with other packages and Distribute the resulting aggregation *
|
||||
* provided that you do not charge a licensing fee for the Package. Distributor *
|
||||
* Fees are permitted, and licensing fees for other components in the *
|
||||
* aggregation are permitted. The terms of this license apply to the use and *
|
||||
* Distribution of the Standard or Modified Versions as included in the *
|
||||
* aggregation. *
|
||||
* *
|
||||
* (8) You are permitted to link Modified and Standard Versions with other *
|
||||
* works, to embed the Package in a larger work of your own, or to build *
|
||||
* stand-alone binary or bytecode versions of applications that include the *
|
||||
* Package, and Distribute the result without restriction, provided the result *
|
||||
* does not expose a direct interface to the Package. *
|
||||
* Items That are Not Considered Part of a Modified Version *
|
||||
* *
|
||||
* (9) Works (including, but not limited to, modules and scripts) that merely *
|
||||
* extend or make use of the Package, do not, by themselves, cause the Package *
|
||||
* to be a Modified Version. In addition, such works are not considered parts *
|
||||
* of the Package itself, and are not subject to the terms of this license. *
|
||||
* General Provisions *
|
||||
* *
|
||||
* (10) Any use, modification, and distribution of the Standard or Modified *
|
||||
* Versions is governed by this Artistic License. By using, modifying or *
|
||||
* distributing the Package, you accept this license. Do not use, modify, or *
|
||||
* distribute the Package, if you do not accept this license. *
|
||||
* *
|
||||
* (11) If your Modified Version has been derived from a Modified Version made *
|
||||
* by someone other than you, you are nevertheless required to ensure that your *
|
||||
* Modified Version complies with the requirements of this license. *
|
||||
* *
|
||||
* (12) This license does not grant you the right to use any trademark, service *
|
||||
* mark, tradename, or logo of the Copyright Holder. *
|
||||
* *
|
||||
* (13) This license includes the non-exclusive, worldwide, free-of-charge *
|
||||
* patent license to make, have made, use, offer to sell, sell, import and *
|
||||
* otherwise transfer the Package with respect to any patent claims licensable *
|
||||
* by the Copyright Holder that are necessarily infringed by the Package. If *
|
||||
* you institute patent litigation (including a cross-claim or counterclaim) *
|
||||
* against any party alleging that the Package constitutes direct or *
|
||||
* contributory patent infringement, then this Artistic License to you shall *
|
||||
* terminate on the date that such litigation is filed. *
|
||||
* *
|
||||
* (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER *
|
||||
* AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE *
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR *
|
||||
* NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. *
|
||||
* UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE *
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN *
|
||||
* ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF *
|
||||
* SUCH DAMAGE. *
|
||||
* *
|
||||
* The End *
|
||||
* *
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
#include "general.h"
|
||||
|
||||
/* Number Handling */
|
||||
|
||||
int getRealNumber(char *c, double *number) {
|
||||
char *unparsed_string;
|
||||
errno = 0;
|
||||
*number = strtod(c, &unparsed_string);
|
||||
return !(errno == ERANGE || unparsed_string == c || *unparsed_string != '\0');
|
||||
}
|
||||
|
||||
int getIntNumber(char *c, int *number) {
|
||||
char *unparsed_string;
|
||||
errno = 0;
|
||||
long int numberl = strtol(c, &unparsed_string, 10);
|
||||
*number = (int) numberl;
|
||||
return !(errno == ERANGE || unparsed_string == c || *unparsed_string != '\0' || numberl > INT_MAX || numberl < INT_MIN);
|
||||
}
|
||||
|
||||
inline int getPosNumber(char *c, int *number) {
|
||||
return (getIntNumber(c, number) && *number >= 0);
|
||||
}
|
||||
|
||||
int IsRealNumber(char *c) {
|
||||
int i, l;
|
||||
l = strlen(c);
|
||||
if (l <= 0) return 0;
|
||||
if (l == 1) return IsNumberDigit(c[0]);
|
||||
for(i = 1; i < strlen(c); i++) {
|
||||
if (c[i] == '.') return IsPosNumber(&c[i + 1]);
|
||||
if (!IsNumberDigit(c[i])) return 0;
|
||||
}
|
||||
return (IsNumberDigit(c[0]) || IsSignDigit(c[0]));
|
||||
}
|
||||
|
||||
int IsPosNumber(const char *c) {
|
||||
int i, l;
|
||||
l = strlen(c);
|
||||
if (l <= 0) return 0;
|
||||
for(i = 0; i < strlen(c); i++) {
|
||||
if (!IsNumberDigit(c[i])) return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsNumber(const char *c) {
|
||||
int i, l;
|
||||
l = strlen(c);
|
||||
if (l <= 0) return 0;
|
||||
if (l == 1) return IsNumberDigit(c[0]);
|
||||
for(i = 1; i < strlen(c); i++) {
|
||||
if (!IsNumberDigit(c[i])) return 0;
|
||||
}
|
||||
return (IsNumberDigit(c[0]) || IsSignDigit(c[0]));
|
||||
}
|
||||
|
||||
/* File Handling */
|
||||
|
||||
char * freadstr(FILE *fd, const char *separators) {
|
||||
char *str;
|
||||
int buf, icur = 0, max = 10;
|
||||
str = (char *) malloc(sizeof(char) * max);
|
||||
str[0] = '\0';
|
||||
do {
|
||||
if ((buf = fgetc(fd)) != EOF) {
|
||||
if (icur == (max - 1)) {
|
||||
max = max * 2;
|
||||
str = (char *) realloc(str, sizeof(char) * max);
|
||||
}
|
||||
if (!CharIn((char) buf, separators)) {
|
||||
str[icur] = (char) buf;
|
||||
icur++;
|
||||
str[icur] = '\0';
|
||||
}
|
||||
}
|
||||
} while(!CharIn(buf, separators) && !feof(fd));
|
||||
return str;
|
||||
}
|
||||
|
||||
int CharIn(const char c, const char *in) {
|
||||
int i;
|
||||
for (i = 0; i < strlen(in); i++)
|
||||
if (c == in[i]) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* string handling */
|
||||
|
||||
int patternmatch(char *pattern, char *thestr) {
|
||||
int i, j = -1, pl = strlen(pattern), sl = strlen(thestr);
|
||||
for(i = 0; i < pl; i++) {
|
||||
if (pattern[i] == '*') {
|
||||
do {
|
||||
i++;
|
||||
if (i == pl) return 1;
|
||||
} while(pattern[i] == '*');
|
||||
do {
|
||||
j++;
|
||||
if (j >= sl) return 0;
|
||||
if ((thestr[j] == pattern[i]) && patternmatch(pattern + i, thestr + j)) return 1;
|
||||
} while(1);
|
||||
} else {
|
||||
j++;
|
||||
if (j >= sl) return 0;
|
||||
if (pattern[i] != thestr[j]) return 0;
|
||||
}
|
||||
}
|
||||
return (pl == sl);
|
||||
}
|
Reference in New Issue
Block a user