Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: REL-3_2_1
Fetching contributors…

Cannot retrieve contributors at this time

file 133 lines (120 sloc) 2.182 kb
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
//////////////////////////////////////////////////////////////////////////
//
// pgAgent - PostgreSQL Tools
//
// Copyright (C) 2002 - 2012 The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// misc.cpp - misc functions
//
//////////////////////////////////////////////////////////////////////////

#include "pgAgent.h"
#include "connection.h"

#ifndef __WXMSW__
#include <unistd.h>
#endif

// In unix.c or win32.c
void usage(const wxString &executable);

wxString getArg(int &argc, char **&argv)
{
wxString s;
if (argv[0][2])
s = wxString::FromAscii(argv[0] + 2);
else
{
if (argc >= 1)
{
argc--;
argv++;
s = wxString::FromAscii(argv[0]);
}
else
{
// very bad!
LogMessage(_("Invalid command line argument"), LOG_ERROR);
}
}

return s;
}


void setOptions(int argc, char **argv, const wxString &executable)
{
while (argc-- > 0)
{
if (argv[0][0] == '-')
{
switch (argv[0][1])
{
case 't':
{
int val = atoi(getArg(argc, argv).mb_str(wxConvUTF8));
if (val > 0)
shortWait = val;
break;
}
case 'r':
{
int val = atoi(getArg(argc, argv).mb_str(wxConvUTF8));
if (val >= 10)
longWait = val;
break;
}
case 'l':
{
int val = atoi(getArg(argc, argv).mb_str(wxConvUTF8));
if (val >= 0 && val <= 2)
minLogLevel = val;
break;
}
#ifndef __WXMSW__
case 'f':
{
runInForeground = true;
break;
}
case 's':
{
logFile = getArg(argc, argv);
break;
}
#endif
default:
{
usage(executable);
exit(1);
}
}
}
else
{
if (connectString != wxT(""))
connectString += wxT(" ");
connectString += wxString::FromAscii(*argv);
if (**argv == '"')
connectString = connectString.substr(1, connectString.length() - 2);
}
argv++;
}
}


void WaitAWhile(const bool waitLong)
{
int count;
if (waitLong)
count = longWait;
else
count = shortWait;

while (count--)
{
#ifdef WIN32
CheckForInterrupt();
Sleep(1000);
#else
sleep(1);
#endif
}
}



wxString NumToStr(const long l)
{
wxString buf;
buf.Printf(wxT("%ld"), l);
return buf;
}
Something went wrong with that request. Please try again.