Ejemplo n.º 1
0
const char *
map_PQX(const char *text, int count)
{
  struct pqx_info *pqx = calloc(count, sizeof(struct pqx_info));
  struct pqx_info **remaps = malloc(count * sizeof(struct pqx_info *));
  char *curr = NULL, *end = NULL, *replace = NULL;
  int i = 0, r = 0, newbufsize = 0;
  curr = malloc(strlen(text)+1);
  strcpy(curr, text);
  for (; i < count; ++i)
    {
      if (!(end = strchr(curr, ',')))
	end = curr + strlen(curr);
      pqx[i].orig = curr;
      if (*end)
	{
	  *end = '\0';
	  curr = end + 1;
	}
      else
	curr = end;
      if (project && !(pqx[i].xmd = map_needs_remap(pqx[i].orig)))
	remaps[r++] = &pqx[i];
    }
  if (r > 0)
    {
      remaps[r] = NULL;
      map_remaps(remaps, r);
      if (remaps[0])
	{
	  /* we didn't find all the replacements */
	  fprintf(stderr, "%s not found\n", text);
	  do404();
	  return NULL;
	}
      else
	{
	  for (i = 0; i < count; ++i)
	    newbufsize += strlen(pqx[i].replace ? pqx[i].replace : pqx[i].orig);
	  newbufsize += (count + 1);
	  replace = malloc(newbufsize);
	  *replace = 0;
	  for (i = 0; i < count; ++i)
	    {
	      strcat(replace, pqx[i].replace ? pqx[i].replace : pqx[i].orig);
	      if ((i+1) < count)
		strcat(replace, ",");
	    }
	  fprintf(stderr, "%s mapped to %s\n", text, replace);
	  return replace;
	}
    }
  else
    return text;
}
Ejemplo n.º 2
0
void prc(char *rq,int f)
{
   char cmd[BUFSIZ], arg[BUFSIZ];

   if (fork()!=0) return;  //
   strcpy(arg,"./");      // cur dir   - add the path
   if ( sscanf(rq,"%s%s",cmd,arg+2)!=2) return;  //  parse for cmd and arg
   
   if( strcmp(cmd,"GET")!=0 ) cntdo(f);   // there is no GET
   else if (ntxt(arg)) do404(arg,f);  // there are no args in request
   else do_cat(arg,f);                  // is html
}
Ejemplo n.º 3
0
void
or_gdf(void)
{
  if (_is_ncname(elements[0]))
    {
      char *dataset = NULL, *tmp = NULL, *exe, *exedot;
      if ((dataset = strrchr(project, '/')))
	{
	  extern const char *oodroot;
	  tmp = malloc(strlen(oodroot) + strlen(project) + strlen(dataset) + 7);
	  sprintf(tmp, "%s/%s%s.xml", oodroot, project, dataset);
	  exe = malloc(strlen(tmp)+1);
	  strcpy(exe, tmp);
	  exedot = strrchr(exe, '.');
	  strcpy(exedot+1, "sh");
	  if (!access(exe, R_OK|X_OK))
	    {
	      execl("/bin/sh", "sh", exe, elements[0], NULL);
	      do404();
	    }
	  else
	    {
	      if (elements[1] && !strcmp(elements[1], "xml"))
		{
		  print_hdr_xml();
		  execl("/bin/sh", "sh", "/home/oracc/bin/gdf-entry.sh", tmp, elements[0], "xml", NULL);
		}
	      else if (!elements[1] || !strcmp(elements[1], "html"))
		{
		  print_hdr();
		  execl("/bin/sh", "sh", "/home/oracc/bin/gdf-entry.sh", tmp, elements[0], NULL);
		}
	    }
	}
    }
  do404();
}