1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
/*
** Copyright (C) 2000 by Alex Hayward
**
*/
/*
** This program 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 2 of the License, or
** (at your option) any later version.
**
** This program 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.
**
** You should have received a copy of the GNU General Public License
** along with this program in a file called COPYING; if not, write to
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
** MA 02110-1301, USA.
*/
/*
** Bug reports and questions can be sent to kde-devel@kde.org
*/
#ifndef FBSD_IFACE_H
#define FBSD_IFACE_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
//#ifdef HAVE_FBSD_PKGTOOLS
#include <tqptrlist.h>
#include <tqmap.h>
#include "packageInfo.h"
#include "pkgInterface.h"
class KDir;
class cacheObj;
class bsdPortsIndexItem;
class fbsdInterface : public pkgInterface
{
Q_OBJECT
public:
fbsdInterface();
~fbsdInterface();
void init();
bool isType(char *buf, const TQString &fname);
packageInfo *getPackageInfo(char mode, const TQString &name, const TQString &version);
TQStringList getFileList(packageInfo *p);
TQStringList getChangeLog(packageInfo *p);
bool filesTab(packageInfo *p);
// If files tab is to be enabled
bool changeTab(packageInfo *p);
// If change log tab is to be enabled
TQString uninstall(int uninstallFlags, TQPtrList<packageInfo> *p, bool &test);
TQString uninstall(int uninstallFlags, packageInfo *p, bool &test);
TQString doUninstall(int uninstallFlags, const TQString &packs, bool &test);
TQString doInstall(int installFlags, const TQString &packs, bool &test);
TQStringList FindFile(const TQString &name, bool seachAll=false);
void collectDepends(packageInfo *p, const TQString &name, int src);
bool parseName(const TQString& name, TQString *n, TQString *v);
void listInstalledPackages(TQPtrList<packageInfo> *pki);
void listPackages(TQPtrList<packageInfo> *pki);
TQDict <bsdPortsIndexItem> ports;
public slots:
void setLocation();
void setAvail(LcacheObj *);
private:
/**
* @short Add the name and version identifiers to a TQMap<TQString, TQString>.
*
* name is parsed in to name and version and these are added to
* d. Errors are handled.
*/
void addNV(TQMap<TQString, TQString> &d, const TQString &name);
int parseItem(TQStringList::Iterator &it, TQString &name, TQString &value, TQString separator, TQStringList list );
int pathInfo(TQMap<TQString, TQString> &a);
};
/**
* @short Ports description linked list item
*
* Each item in the list describes one port from the ports collection.
*/
class bsdPortsIndexItem {
public:
/**
* desc is a line from the INDEX file (/usr/ports/INDEX under FreeBSD)
* which has a particular format:
*
* name|port path|inst prefix|1 line commect|DESCR file|maintainer|categories|build-deps|run-deps
*
* Multiple space separated categories may be specified.
*
* desc must remain allocated (ie, its not copied) will be modified.
*
* binaries should be true if this is a binary package.
*
* dname is the name of the base directory of this ports/packages tree.
*/
bsdPortsIndexItem(fbsdInterface *parent, char *desc, bool binaries, const TQString &dname);
/** @short true if this has a binary packages. */
bool bin;
/** @short true if this has a source port available. */
bool port;
/** @short true if this package is installed (set in listInstalledPackages) */
bool installed;
/** @short The next item in this linked list */
bsdPortsIndexItem *next;
TQStringList fields;
enum {NAME=0, PATH, PREFIX, COMMENT, DESC_PATH, MAINT, CATS, BDEPS, RDEPS};
TQString bin_filename;
TQString bin_filename_base;
TQString port_dirname;
/**
* @short Given the path to an INDEX file process each port in it.
*
* binaries should be true if the file is an index for packages, false for ports.
* dname is the base directory.
*/
static void processFile(fbsdInterface *parent, const TQString &fname, bool binaries, const TQString &dname);
private:
unsigned int name_hash;
static unsigned char calc_hash1(const char *name);
static unsigned int calc_hash4(const char *name);
static unsigned char hash1(unsigned int hash4);
};
#endif
|