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
|
#include <kapplication.h>
#include <kdebug.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include "authinfo.h"
void output( const KURL& u )
{
kdDebug() << "Looking up auto login for: " << u.url() << endl;
TDEIO::NetRC::AutoLogin l;
bool result = TDEIO::NetRC::self()->lookup( u, l, true );
if ( !result )
{
kdDebug() << "Either no .netrc and/or .kionetrc file was "
"found or there was problem when attempting to "
"read from them! Please make sure either or both "
"of the above files exist and have the correct "
"permission, i.e. a regular file owned by you with "
"with a read/write permission (0600)" << endl;
return;
}
kdDebug() << "Type: " << l.type << endl
<< "Machine: " << l.machine << endl
<< "Login: " << l.login << endl
<< "Password: " << l.password << endl;
TQMap<TQString,TQStringList>::ConstIterator it = l.macdef.begin();
for ( ; it != l.macdef.end(); ++it )
{
kdDebug() << "Macro: " << it.key() << "= "
<< it.data().join(" ") << endl;
}
}
int main(int argc, char **argv)
{
const char *version = "0.5";
const char *description = "Unit test for .netrc and kionetrc parser.";
KCmdLineOptions options[] =
{
{ "+command", "[url1,url2 ,...]", 0 },
KCmdLineLastOption
};
TDECmdLineArgs::init( argc, argv, "kionetrctest", description, version );
TDECmdLineArgs::addCmdLineOptions( options );
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
int count = args->count();
TDEApplication app;
if ( !count )
args->usage();
else
{
KURL u;
for( int i=0 ; i < count; i++ )
{
u = args->arg(i);
if ( !u.isValid() )
{
kdDebug() << u.url() << " is invalid! Ignoring..." << endl;
continue;
}
output( u );
}
}
args->clear();
return 0;
}
|