#include <stdio.h>

#include "global.h"

#include "manhat-lib/shared_util.h"
#include "manhat-lib/shared_cs_util.h"
#include "manhat-lib/shared_server_string.h"
#include "manhat-lib/shared_podcast_util.h"


static void
read_parameters (char *course, char *key)
{

  cs_get_required_parameter ("crs", course, MAX_FILENAME);	/* cgihtml library */
  cs_get_required_parameter ("id", key, MAX_KEY);

}


static 
void set_podcast_rss_url(const char *course, CONFIG_STRUCT *conf)
{
 char url[MAX_PATH + 1];
 char podcast_key[MAX_KEY + 1];
 char server_name[MAX_PATH + 1];
 
  get_podcast_key(conf, podcast_key);   /* shared_podcast_util.c */
  get_server_string(server_name, MAX_PATH + 1);         /* shared_server_string.c */
  
  snprintf(url, MAX_PATH + 1, "%s/%s/podcaster?crs=%s&amp;id=%s&amp;ext=.xml", server_name, ALIAS,course, podcast_key);
  
  cs_set_value("podcast_rss_url", url);
}

  
  
  

 

int
main (void)
{
  char course[MAX_PATH + 1];	/* from crs=? command line */
  char key[MAX_KEY + 1];	/* from id=? command line */
  SESSION user;
  CONFIG_STRUCT conf;
  
  cs_cgi_init();

  read_parameters (course, key);
  read_configuration_file (course, &conf);	/* shared_util.c */
  validate_key (key, &user, &conf);	/* shared_util.c */

  set_podcast_rss_url(course, &conf);
  
  cs_cgi_display("podcast_subscribe", 1);
  cs_cgi_destroy();
  return (0);
}

