99 lines
2.2 KiB
C
99 lines
2.2 KiB
C
/*
|
|
* idpc - IDP as a C CGI program
|
|
* Copyright (C) 2004 Entr'ouvert
|
|
*
|
|
* Author: Frederic Peters <fpeters@entrouvert.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
#include "idpc.h"
|
|
|
|
extern int single_sign_on();
|
|
extern int soap_end_point();
|
|
static int credits();
|
|
|
|
struct page {
|
|
char *name;
|
|
int (*page_function) ();
|
|
};
|
|
|
|
struct page pages[] = {
|
|
{"", credits},
|
|
{"credits", credits},
|
|
{"singleSignOn", single_sign_on},
|
|
{"soapEndpoint", soap_end_point},
|
|
NULL
|
|
};
|
|
|
|
|
|
static int credits()
|
|
{
|
|
printf("Content-type: text/plain\n\n");
|
|
printf(" * idpc - IDP as a C CGI program\n");
|
|
printf(" * Copyright (C) 2004 Entr'ouvert\n");
|
|
return 0;
|
|
}
|
|
|
|
static int four_zero_four()
|
|
{
|
|
printf("Status: 404 Not Found\n");
|
|
printf("Content-type: text/plain\n\n");
|
|
printf("Page not found");
|
|
return 0;
|
|
}
|
|
|
|
int error_page(char* msg)
|
|
{
|
|
printf("Status: 500 Server Error\n");
|
|
printf("Content-type: text/plain\n\n");
|
|
printf("Error; %s\n", msg);
|
|
return 0;
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
char *path_info, *uri = NULL;
|
|
lasso_init();
|
|
int i = 0, rc = 0;
|
|
|
|
path_info = getenv("PATH_INFO");
|
|
if (path_info) {
|
|
uri = strdup(path_info+1); /* +1 to ignore first slash */
|
|
if (strlen(uri) && uri[strlen(uri)-1] == '/') {
|
|
/* remove trailing slash */
|
|
uri[strlen(uri)-1] = 0;
|
|
}
|
|
} else {
|
|
uri = strdup("");
|
|
}
|
|
|
|
while (pages[i].name) {
|
|
if (strcmp(uri, pages[i].name) == 0) {
|
|
g_free(uri);
|
|
rc = pages[i].page_function();
|
|
goto shutdown;
|
|
}
|
|
i++;
|
|
}
|
|
|
|
rc = four_zero_four();
|
|
|
|
shutdown:
|
|
lasso_shutdown();
|
|
return rc;
|
|
}
|
|
|