#include <stdio.h>
#include <string.h>
#include "secupass_auth.h"

#pragma comment(lib, "Agent_vc_dll_MT.lib")
int main(int argc, char *argv[])
{
	int nret;
	int nchellenge;
	char szbuf[100];
	int nvalid;
    int nport = 1812;
    int ntmout = 5;
    if (argc < 5)
    {
        printf("Usage:uniotpdemo username OTP[PIN] host secret port timeout\n");
        return -1;
    }
    if (argc > 5)
    {
        nport = atoi(argv[5]);
    }
    if (argc > 6)
    {
        ntmout = atoi(argv[6]);
    }

	nret = secuauth(argv[3], argv[4], strlen(argv[4]), argv[1], strlen(argv[1]), argv[2], strlen(argv[2]), &nchellenge, &nvalid, szbuf, 99, nport, ntmout);
    if (RD_ERROR_SUCCESS == nret)
    {
        printf("Authentication successfully!\n");
    }
    else if (RD_ERROR_CHALLENGENEED == nret && nvalid)
    {
        printf("Challenge need!Challenge code:%d\n", nchellenge);
        printf("Information:%s\n", szbuf);
    }
    else
    {
        printf("Authentication failed!Error Code:#%d\n", nret);
    }
	return 0;
}