/* login_test.c */ #include #include #include #include #include "form.h" #include "page.h" #include "login.h" #include "password.h" #include "sql.h" char *progname; char *bgcolor = "linen"; /*char *bgcolor = NULL;*/ /*char *fontnames = "arial,helvetica";*/ char *fontnames = NULL; void login_test_help( char *login_url ) { login_form_begin( "Login Test Help",bgcolor,fontnames, "",login_url ); fprintf( stdout,"

This is the Login Test Help Page

\n" ); login_form_okay_button(); login_form_end(); } /* end of login_test_help() */ void login_test_exit( char *username ) { fprintf( stdout,"Content-type: text/html\n\n" ); fprintf( stdout,"Login Test\n" ); fprintf( stdout,"

validated user = %s

\n",username ); } /* end of login_test_exit() */ void main( int argc,char **argv ) { char *username; progname = argv[0]; init_err( "../data/logfile" ); fprintf( stderr,"-----login test start-----\n" ); fflush( stderr ); dbname = malloc( 10 * sizeof( char )); strcpy( dbname,"template1" ); if ( sql_connect_or_fail() ) { printf( "Content-type: text/plain\n\n" ); printf( "Couldn't connect to server\n" ); printf( "Our SQL server may be down; please try again later\n" ); exit( 0 ); } PQtrace( sqldb,stderr ); username = login( sqldb, /* database pointer */ 25, /* username_size */ 10, /* password_size */ "Login Test Page", /* login_title */ bgcolor, /* login_bgcolor */ fontnames, /* login_fontnames */ "Enter login:", /* login_heading */ "login_test.cgi", /* login_url */ "username:", /* username_prompt */ "password:", /* password_prompt */ "new user", /* new_user_button */ "Add User Page", /* add_user_title */ "Enter new user", /* add_user_heading */ "New Password Page", /* new_password_title */ "Enter new password for user", /* new_password_heading */ " again:", /* verify_password_prompt */ "You must enter a username!", /* error_no_username*/ "You must enter a password!", /* error_no_password*/ "Incorrect login!", /* error_incorrect_login */ "Username already exists!", /* error_duplicate_user */ &login_test_help, "testcookie" ); if ( username == NULL ) { exit( 0 ); } login_test_exit( username ); exit( 0 ); } /* end of main() */