Beispiel #1
0
const char *my_stristr(const char *whole, const char *part)
{
    int part_len = strlen(part);
    while (*whole) {
        if (my_strncasecmp(whole, part, part_len) == 0)
            return whole;
        ++whole;
    }
    return NULL;
}
Beispiel #2
0
/*
 * Verify that given file has certain extension
 */
int
match_extension(const char *path, const char *ext_list)
{
	size_t		len, path_len;
	
	path_len = strlen(path);

	FOR_EACH_WORD_IN_LIST(ext_list, len)
		if (len < path_len &&
		    !my_strncasecmp(path + path_len - len, ext_list, len))
			return (1);

	return (0);
}
Beispiel #3
0
PUBLIC int HTSendMailTo ARGS4(
      WWW_CONST char *,     arg,
      HTParentAnchor *,	anAnchor,
      HTFormat,		format_out,
      HTStream*,	stream)
{
  char *mailtoURL;
  char *mailtoSubject;

#ifndef DISABLE_TRACE
  if (www2Trace) 
    fprintf(stderr, "HTMailto: Mailing to %s\n", arg);
#endif
  
  if (!initialized) 
    initialized = initialize();
  if (!initialized) 
    {
      HTProgress ((char *) 0);
      return HT_NOT_LOADED;
    }

  {
    WWW_CONST char * p1=arg;
    
    /*	We will ask for the document, omitting the host name & anchor.
     **
     **	Syntax of address is
     **		xxx@yyy			User xxx at site yyy (xxx is optional).
     */        
    if (!my_strncasecmp (arg, "mailto:", 7))
      p1 = arg + 7;		/* Skip "mailto:" prefix */
    
    if (!*arg) 
      {
	HTProgress ("Could not find email address");
	return HT_NOT_LOADED;	/* Ignore if no name */
      }

    GetMailtoKludgeInfo(&mailtoURL,&mailtoSubject);
    (void) mo_post_mailto_win(p1,mailtoSubject);
    return HT_LOADED;
  }
}
Beispiel #4
0
/* Basically we show the urls that appear within the frameset tag
   as urls and add some text explaining that these are the urls they
   were supposed to see as frames. We also show the NOFRAMES stuff. */
static void frame_hack()
{
  extern char *ParseMarkTag();
  char *start, *new_src, *place,*tmp, *url, *frame_anchors[25], *new_html;
  int num_frames=0, new_size=0, i;
  char *ptr;

  start=NULL;
  for (i=0,ptr=HTMainText->htmlSrc; ptr && i<FRAME_CHECK_SIZE; ptr++,i++) {
	if (*ptr=='<' && (*(ptr+1)=='f' || *(ptr+1)=='F')) {
		if (!my_strncasecmp("rameset",ptr+2,7)) {
			start=ptr;
			break;
		}
	}
  }
/*
  start = strstr(HTMainText->htmlSrc, "<frameset");

  if(!start)
    start = strstr(HTMainText->htmlSrc, "<FRAMESET");
*/

  if(!start)
    return;

  place = start;

  while((tmp=strstr(place, "<frame ")) || (tmp=strstr(place, "<FRAME ")))
    {
      url = ParseMarkTag(tmp, "FRAME", "SRC");
      if (url) {
	frame_anchors[num_frames] = malloc(strlen(url)*2 +
					 strlen("<LI> <A HREF=  > </A> ")+4);
	sprintf(frame_anchors[num_frames], "<LI> <A HREF=\"%s\"> %s </A>", url, url);
	new_size += strlen(frame_anchors[num_frames])+1;
	num_frames++;
      }
      place = tmp+6;
    }

  new_src = malloc(new_size+strlen(HTMainText->htmlSrc) + strlen(" <HR> ") +
		   strlen("<H2> Frame Index: </H2> <UL> </UL>") +6);

  /* copy everything up to first frameset tag to new_src */
  strncpy(new_src, HTMainText->htmlSrc, strlen(HTMainText->htmlSrc) -
	  strlen(start));

  new_src[strlen(HTMainText->htmlSrc) - strlen(start)]='\0';

  sprintf(new_src, "%s <H2> Frame Index: </H2> <UL>", new_src);

  for(i=0;i<num_frames;i++)
    {
      sprintf(new_src, "%s%s", new_src, frame_anchors[i]);
      free(frame_anchors[i]);
    }

  /* end list */
  sprintf(new_src, "%s </UL> <HR>", new_src);

  /* add in rest of document */
  strcat(new_src, start);

  free(HTMainText->htmlSrc);
  HTMainText->htmlSrc = new_src;
}
Beispiel #5
0
PUBLIC HTFormat HTFileFormat ARGS4 (
			char *,	filename,
			HTAtom **,	pencoding,
                        HTAtom *,       default_type,
                        int *, compressed)
{
  HTSuffix *suff;
  int n, i, lf;

  if (!filename)
    return NULL;

  /* Make a copy to hack and slash. */
  filename = strdup (filename);

  lf = strlen (filename);

  /* Step backward through filename, looking for '?'. */
  for (i = lf - 1; i >= 0; i--)
    {
      if (filename[i] == '?')
        {
          /* Clip query. */
          filename[i] = '\0';
          /* Get new strlen, since we just changed it. */
          lf = strlen (filename);
          goto ok_ready;
        }
    }

  *compressed = 0;

  /* Check for .Z and .z. */
  if (lf > 2)
    {
      if (strcmp (&(filename[lf-2]), ".Z") == 0)
        {
          *compressed = COMPRESSED_BIGZ;
          filename[lf-2] = '\0';
          lf = strlen (filename);
#ifndef DISABLE_TRACE
          if (www2Trace)
            fprintf (stderr, "[HTFileFormat] Got hit on .Z; filename '%s'\n",
                     filename);
#endif
          goto ok_ready;
        }
      else if (strcmp (&(filename[lf-2]), ".z") == 0)
        {
          *compressed = COMPRESSED_GNUZIP;
          filename[lf-2] = '\0';
          lf = strlen (filename);
#ifndef DISABLE_TRACE
          if (www2Trace)
            fprintf (stderr, "[HTFileFormat] Got hit on .z; filename '%s'\n",
                     filename);
#endif
          goto ok_ready;
        }
      else if (lf > 3)
        {
          if (strcmp (&(filename[lf-3]), ".gz") == 0)
            {
              *compressed = COMPRESSED_GNUZIP;
              filename[lf-3] = '\0';
              lf = strlen (filename);
#ifndef DISABLE_TRACE
              if (www2Trace)
                fprintf (stderr, 
                         "[HTFileFormat] Got hit on .gz; filename '%s'\n",
                         filename);
#endif
              goto ok_ready;
            }
        }      
    }      
  
 ok_ready:
  if (!HTSuffixes) 
    HTFileInit();

  *pencoding = NULL;

  n = HTList_count(HTSuffixes);

  for(i=0; i<n; i++) 
    {
      int ls;
      suff = HTList_objectAt(HTSuffixes, i);
      ls = strlen(suff->suffix);
      if ((ls <= lf) && 0==my_strcasecmp(suff->suffix, filename + lf - ls)) 
        {
          int j;
          *pencoding = suff->encoding;
          if (suff->rep) 
            goto done;
          
          for(j=0; j<n; j++) 
            {  /* Got encoding, need representation */
              int ls2;
              suff = HTList_objectAt(HTSuffixes, j);
              ls2 = strlen(suff->suffix);
              if ((ls <= lf) && 
                  0==my_strncasecmp(suff->suffix, filename + lf - ls -ls2, ls2)) 
                if (suff->rep) 
                  goto done;
	    }
        }
    }
  
  suff = strchr(filename, '.') ? 	/* Unknown suffix */
    ( unknown_suffix.rep ? &unknown_suffix : &no_suffix)
      : &no_suffix;
  
  /* For now, assuming default is 8bit text/plain.
     We also want default 8bit text/html for http connections. */
  
  /* set default encoding unless found with suffix already */
  if (!*pencoding) *pencoding = suff->encoding ? suff->encoding
    : HTAtom_for("8bit");

 done:

  /* Free our copy. */
  free (filename);
  return suff->rep ? suff->rep : default_type;
}