File: main.cpp

package info (click to toggle)
libproxy 0.4.15-5%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 960 kB
  • sloc: cpp: 3,829; ansic: 112; makefile: 78; cs: 69; python: 44; perl: 42; sh: 17; ruby: 8
file content (72 lines) | stat: -rw-r--r-- 2,117 bytes parent folder | download | duplicates (5)
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
/*******************************************************************************
 * libmodman - A library for extending applications
 * Copyright (C) 2009 Nathaniel McCallum <nathaniel@natemccallum.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 ******************************************************************************/

#include <iostream>
#include <vector>
#include <cstring>
#ifdef WIN32
#ifdef SYMB
#include <winsock2.h>
#endif
#endif

#include "main.hpp"

int main(int argc, const char** argv) {
	module_manager mm;
#ifdef WIN32
#ifdef SYMB
	void* symb = recv;
#endif
#endif

	if (argc < 2) {
		cout << "Usage: " << argv[0] << " MODULEDIR MODNAME ..." << endl;
		return 1;
	}

	if (!mm.register_type<EXTTYPE>()) {
		cout << "Unable to register type!" << endl;
		return 2;
	}

	if (!mm.load_dir(argv[1]) && argc > 2) {
		if (!mm.load_dir(argv[1], false)) {
			cout << "Unable to load modules!" << endl;
			return 3;
		}
	}

	vector<EXTTYPE*> exts = mm.get_extensions<EXTTYPE>();
	if (exts.size() != (unsigned int) argc - 2) {
		cout << "Wrong number of extensions found!" << endl;
		return 4;
	}

	for (unsigned int i=0 ; i < exts.size() ; i++) {
		if (!strstr(typeid(*(exts[i])).name(), argv[i+2])) {
			cout << "Unable to find extension! Here's the list:" << endl;
			for (unsigned int j=0 ; j < exts.size() ; j++)
				cout << "\t" << typeid(*(exts[j])).name() << endl;
			return 5;
		}
	}

	return 0;
}