This is htp.c in view mode; [Download] [Up]
#import <stdio.h> #import <string.h> #import <stdlib.h> #import <ctype.h> #import "structures.h" extern Boolean prescan; extern shalfword hh, vv; extern integer pagenum; int last_pagenum; int lasthh; int lastvv; int last_thing; char *last_string = 0; #define HTAG 2 #define HPT_EXT 4 #define HPT 3 void ht_add_tag(); void ht_add_pt(); void process_ht(char *st) { int len = strlen(st); if (strncmp(st, "a href=\"", 8) == 0) { char *pt; int i; int pti = 0; pt = (char *)malloc(len - 12 + 1 + 4); for (i = 7; i < len; i++) { if ((st[i] != '#') && (st[i] != '\"')) { pt[pti] = st[i]; pti++; } } pt[pti] = 0; lasthh = hh; lastvv = vv; last_thing = HPT; last_string = pt; last_pagenum = pagenum; /*Determine whether or not it is an external reference*/ if((strncmp(pt,"file:",5)==0)||(strncmp(pt,"http:",5)==0)) last_thing=HPT_EXT; } else if (strncmp(st, "a name=\"", 8) == 0) { char *pt; int i; int pti = 0; pt = (char *)malloc(len - 12 + 1 + 4); for (i = 7; i < len; i++) { if ((st[i] != '#') && (st[i] != '\"')) { pt[pti] = st[i]; pti++; } } pt[pti] = 0; last_pagenum = pagenum; lasthh = hh; lastvv = vv; last_thing = HTAG; last_string = pt; } else if (strncmp(st, "/a", 2) == 0) { if (last_thing == HTAG) ht_add_tag(last_string); if (last_thing == HPT_EXT) ht_add_pt(last_string, 1); if (last_thing == HPT) ht_add_pt(last_string,0); if (last_string) { free(last_string); last_string = 0; };last_thing=0; } else { printf("Unknown html\n"); } }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.