Skip to content

Commit 0a0b112

Browse files
authored
Add files via upload
1 parent da05dc1 commit 0a0b112

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

htmlhunter.cpp

25.8 KB
Binary file not shown.

xgetopt.cpp

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#ifndef XGetopt_cpp
2+
#define XGetopt_cpp
3+
4+
5+
6+
#ifdef WIN32
7+
8+
9+
#include <windows.h>
10+
#include <stdio.h>
11+
#include <tchar.h>
12+
13+
14+
15+
#include "xgetopt.h"
16+
17+
18+
/
19+
20+
TCHAR *optarg; // global argument pointer
21+
int optind = 0; // global argv index
22+
23+
int getopt(int argc, TCHAR *argv[], TCHAR *optstring)
24+
{
25+
static TCHAR *next = NULL;
26+
if (optind == 0)
27+
next = NULL;
28+
29+
optarg = NULL;
30+
31+
if (next == NULL || *next == _T('\0'))
32+
{
33+
if (optind == 0)
34+
optind++;
35+
36+
if (optind >= argc || argv[optind][0] != _T('-') || argv[optind][1] == _T('\0'))
37+
{
38+
optarg = NULL;
39+
if (optind < argc)
40+
optarg = argv[optind];
41+
return EOF;
42+
}
43+
44+
if (_tcscmp(argv[optind], _T("--")) == 0)
45+
{
46+
optind++;
47+
optarg = NULL;
48+
if (optind < argc)
49+
optarg = argv[optind];
50+
return EOF;
51+
}
52+
53+
next = argv[optind];
54+
next++; // skip past -
55+
optind++;
56+
}
57+
58+
TCHAR c = *next++;
59+
TCHAR *cp = _tcschr(optstring, c);
60+
61+
if (cp == NULL || c == _T(':'))
62+
return _T('?');
63+
64+
cp++;
65+
if (*cp == _T(':'))
66+
{
67+
if (*next != _T('\0'))
68+
{
69+
optarg = next;
70+
next = NULL;
71+
}
72+
else if (optind < argc)
73+
{
74+
optarg = argv[optind];
75+
optind++;
76+
}
77+
else
78+
{
79+
return _T('?');
80+
}
81+
}
82+
83+
return c;
84+
}
85+
86+
#endif
87+
#endif
88+
89+

xgetopt.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef XGETOPT_H
2+
#define XGETOPT_H
3+
4+
extern int optind, opterr;
5+
extern TCHAR *optarg;
6+
7+
int getopt(int argc, TCHAR*argv[], TCHAR*optstring);
8+
9+
#endif //XGETOPT_H

0 commit comments

Comments
 (0)