[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Wed, 30 Nov 2022 13:36:26 -0500 (EST) |
branch: old/qt-info
commit 947ec4beb7216859638418982966d3b1b0e5214a
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun Apr 7 15:48:02 2019 +0100
new file infopath.c, to look for a HTML manual
---
js/docbrowser/docbrowser.pro | 6 +++--
js/docbrowser/infopath.c | 60 ++++++++++++++++++++++++++++++++++++++++++++
js/docbrowser/infopath.h | 15 +++++++++++
js/docbrowser/mainwindow.cpp | 4 +++
4 files changed, 83 insertions(+), 2 deletions(-)
diff --git a/js/docbrowser/docbrowser.pro b/js/docbrowser/docbrowser.pro
index 7de963d501..2558d080df 100644
--- a/js/docbrowser/docbrowser.pro
+++ b/js/docbrowser/docbrowser.pro
@@ -18,11 +18,13 @@ SOURCES += main.cpp\
mainwindow.cpp \
websocketclientwrapper.cpp \
websockettransport.cpp \
- core.cpp
+ core.cpp \
+ infopath.c
HEADERS += mainwindow.h \
websocketclientwrapper.h \
websockettransport.h \
- core.h
+ core.h \
+ infopath.h
FORMS += mainwindow.ui
diff --git a/js/docbrowser/infopath.c b/js/docbrowser/infopath.c
new file mode 100644
index 0000000000..b56bd4c48c
--- /dev/null
+++ b/js/docbrowser/infopath.c
@@ -0,0 +1,60 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <dirent.h>
+#include <sys/stat.h>
+
+#include "infopath.h"
+
+static char *datadir;
+long datadir_len;
+
+/* Return pathname of the main index.html file for a HTML manual.*/
+char *
+locate_manual (const char *manual)
+{
+ fprintf (stderr, "In C now, looking for %s\n", manual);
+
+ if (!datadir)
+ {
+ datadir = getenv ("QTINFO_DATADIR");
+ if (!datadir)
+ return 0;
+ datadir_len = strlen (datadir);
+ }
+
+ /* Check if datadir exists. */
+ DIR *d = opendir (datadir);
+ if (!d)
+ {
+ fprintf (stderr, "Could not open %s\n", datadir);
+ return 0;
+ }
+ closedir (d);
+
+ char *s = malloc (datadir_len + strlen ("/examples/")
+ + strlen (manual) + 1);
+ sprintf (s, "%s/examples/%s", datadir, manual);
+
+ d = opendir (s);
+ if (!d)
+ {
+ fprintf (stderr, "Could not open %s\n", s);
+ return 0;
+ }
+ closedir (d);
+
+ fprintf (stderr, "success so far\n");
+ free (s);
+ s = malloc (datadir_len + strlen ("/examples/")
+ + strlen (manual) + strlen ("/index.html") + 1);
+ sprintf (s, "%s/examples/%s/index.html", datadir, manual);
+
+ struct stat dummy;
+ if (stat (s, &dummy) == -1)
+ {
+ fprintf (stderr, "no file %s\n", s);
+ return 0;
+ }
+ return s;
+}
diff --git a/js/docbrowser/infopath.h b/js/docbrowser/infopath.h
new file mode 100644
index 0000000000..cc3ded2746
--- /dev/null
+++ b/js/docbrowser/infopath.h
@@ -0,0 +1,15 @@
+#ifndef INFOPATH_H
+#define INFOPATH_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+char *locate_manual (const char *manual);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // INFOPATH_H
diff --git a/js/docbrowser/mainwindow.cpp b/js/docbrowser/mainwindow.cpp
index a01cc5b074..a10e4d43a8 100644
--- a/js/docbrowser/mainwindow.cpp
+++ b/js/docbrowser/mainwindow.cpp
@@ -3,6 +3,8 @@
#include "websocketclientwrapper.h"
#include "websockettransport.h"
+#include "infopath.h"
+
#include <stdlib.h>
#include <QWebEngineView>
@@ -108,4 +110,6 @@ void MainWindow::on_quitButton_clicked()
void MainWindow::on_loadButton_clicked()
{
qDebug() << "load clicked";
+ char *path = locate_manual(qPrintable(ui->manualEdit->text()));
+ qDebug() << "got path" << path;
}
- [no subject], (continued)
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject],
Gavin D. Smith <=
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30