예제 #1
0
파일: LYLeaks.c 프로젝트: avsm/openbsd-lynx
/*
**  String Allocate and Concatenate.
**  Tracks allocations by using other LYLeakFoo functions.
**  Equivalent to HTSACat in HTUtils.c - KW
*/
PUBLIC char * LYLeakSACat ARGS4(
	char **,	dest,
	CONST char *,	src,
	CONST char *,	cp_File,
	CONST short,	ssi_Line)
{
    if (src && *src) {
	if (src == *dest) {
	    CTRACE((tfp,
		   "LYLeakSACat:  *dest equals src, contains \"%s\"\n",
		   src));
	    return *dest;
	}
	if (*dest) {
	    int length = strlen(*dest);
	    *dest = (char *)LYLeakRealloc(*dest,
					  (length + strlen(src) + 1),
					  cp_File,
					  ssi_Line);
	    if (*dest == NULL)
		outofmem(__FILE__, "LYLeakSACat");
	    strcpy (*dest + length, src);
	} else {
	    *dest = (char *)LYLeakMalloc((strlen(src) + 1),
					 cp_File,
					 ssi_Line);
	    if (*dest == NULL)
		outofmem(__FILE__, "LYLeakSACat");
	    strcpy (*dest, src);
	}
    }
    return *dest;
}
예제 #2
0
PUBLIC HTStream* HTExtParse ARGS5(
	HTRequest *,		request,
	void *,			param,
	HTFormat,		input_format,
	HTFormat,		output_format,
	HTStream *,		output_stream)
{
    HTStream* me;
  
    if (TRACE) {
	printf("HTExtConvert..");
	if (input_format && input_format->name)
            printf (".. input format is %s",input_format->name);
	if (output_format && output_format->name)
            printf (".. output format is %s",output_format->name);
	printf("\n");
    }

    me = (HTStream*)calloc(1, sizeof(*me));
    if (me == NULL) outofmem(__FILE__, "HTExtConvert");
    me->isa = &HTExtParseClass;

    me->eps = (HTExtParseStruct *) calloc(1, sizeof(HTExtParseStruct));
    if (me->eps == NULL) outofmem(__FILE__, "HTExtConvert");

    me->eps->content_type = input_format->name;
    me->eps->call_client = HTCallClient;
    me->eps->buffer = (char *)calloc(INPUT_BUFFER_SIZE,1);
    me->eps->used = 0;
    me->eps->finished = NO;
    me->eps->length = INPUT_BUFFER_SIZE;
    me->eps->request = request;
    return me;
}
예제 #3
0
/*								HTErrorAdd
**
**	Add an error message to the error list in HTRequest. `par' and `where'
**	might be set to NULL. If par is a string, it is sufficient to let
**	par_length be unspecified, i.e., 0. If only a part of the string is
**	wanted then specify a par_length inferior to strlen((char *) par).
**	The string is '\0' terminated automaticly.
**
**	NOTE: See also HTErrorSysAdd for system errors
**
**	Returns always < 0
*/
PUBLIC int HTErrorAdd ARGS7(HTRequest *, 	request,
			    HTErrSeverity, 	severity,
			    BOOL,		ignore,
			    int,		element,
			    void *,		par,
			    unsigned int,	par_length,
			    char *,		where)
{
    HTErrorInfo *newError;
    if (!request) {
	if (TRACE) fprintf(stderr, "HTErrorAdd.. Bad argument!\n");
	return -1;
    }
    if ((newError = (HTErrorInfo *) calloc(1, sizeof(HTErrorInfo))) == NULL)
	outofmem(__FILE__, "HTErrorAdd");
    newError->element = element;
    newError->severity = severity;
    newError->ignore = ignore;
    if (par) {
	if (!par_length)
	    par_length = (int) strlen((char *) par);
	if ((newError->par = malloc(par_length+1)) == NULL)
	    outofmem(__FILE__, "HTErrorError");
	memcpy(newError->par, par, par_length);
	*(((char *) newError->par)+par_length) = '\0';
	newError->par_length = par_length;
    }
    newError->where = where;

    /* Add to the stack in the request structure */
    if (!request->error_stack)
	request->error_stack = HTList_new();
    else {			/* Get last object in order to find a handle */
	HTList *cur = request->error_stack;
	HTErrorInfo *pres = (HTErrorInfo *) HTList_nextObject(cur);
	if (pres != NULL)
	    newError->handle = pres->handle+1;
    }
    if (TRACE) {
	fprintf(stderr, "Message..... Handle: %d\tCode: %3d\tMessage: `%s\'\tSeverity: %d\tParameter: `%s\'\tWhere: `%s\'\n",
		newError->handle,
		error_info[newError->element].code,
		error_info[newError->element].msg,
		newError->severity,
		newError->par ? (char *) newError->par : "Unspecified",
		newError->where ? newError->where : "Unspecified");
    }
    HTList_addObject(request->error_stack, (void *) newError);
    return (-element);
}
예제 #4
0
HTStyle *HTStyleRead(HTStyle *style, HTStream *stream)
{
    char myTag[STYLE_NAME_LENGTH];
    char fontName[STYLE_NAME_LENGTH];
    NXTextStyle *p;
    int tab;
    int gotpara;		/* flag: have we got a paragraph definition? */

    NXScanf(stream, "%s%s%f%d",
	    myTag,
	    fontName,
	    &style->fontSize,
	    &gotpara);
    if (gotpara) {
	if (!style->paragraph) {
	    style->paragraph = malloc(sizeof(*(style->paragraph)));
	    if (!style->paragraph)
		outofmem(__FILE__, "HTStyleRead");
	    style->paragraph->tabs = 0;
	}
	p = style->paragraph;
	NXScanf(stream, "%f%f%f%f%hd%f%f%hd",
		&p->indent1st,
		&p->indent2nd,
		&p->lineHt,
		&p->descentLine,
		&p->alignment,
		&style->spaceBefore,
		&style->spaceAfter,
		&p->numTabs);
	FREE(p->tabs);
	p->tabs = malloc(p->numTabs * sizeof(p->tabs[0]));
	if (!p->tabs)
	    outofmem(__FILE__, "HTStyleRead");
	for (tab = 0; tab < p->numTabs; tab++) {
	    NXScanf(stream, "%hd%f",
		    &p->tabs[tab].kind,
		    &p->tabs[tab].x);
	}
    } else {			/* No paragraph */
	FREE(style->paragraph);
    }				/* if no paragraph */
    StrAllocCopy(style->SGMLTag, myTag);
    if (strcmp(fontName, NONE_STRING) == 0)
	style->font = 0;
    else
      style->font =[Font newFont: fontName size:style->fontSize];
    return NULL;
}
예제 #5
0
PUBLIC HTAtom * HTAtom_for ARGS1(CONST char *, string)
{
    int hash;
    HTAtom * a;
    
    /*		First time around, clear hash table
    */
    /*
     *	Memory leak fixed.
     *  05-29-94 Lynx 2-3-1 Garrett Arch Blythe
     */
    if (!initialised) {
        int i;
	for (i = 0; i < HASH_SIZE; i++)
	    hash_table[i] = (HTAtom *) 0;
	initialised = YES;
	atexit(free_atoms);
    }
    
    /*		Generate hash function
    */
    hash = HASH_FUNCTION(string);
    
    /*		Search for the string in the list
    */
    for (a = hash_table[hash]; a; a = a->next) {
	if (0 == strcasecomp(a->name, string)) {
    	    /* CTRACE(tfp, "HTAtom: Old atom %p for `%s'\n", a, string); */
	    return a;				/* Found: return it */
	}
    }
    
    /*		Generate a new entry
    */
    a = (HTAtom *)malloc(sizeof(*a));
    if (a == NULL)
        outofmem(__FILE__, "HTAtom_for");
    a->name = (char *)malloc(strlen(string)+1);
    if (a->name == NULL)
        outofmem(__FILE__, "HTAtom_for");
    strcpy(a->name, string);
    a->next = hash_table[hash];		/* Put onto the head of list */
    hash_table[hash] = a;
#ifdef NOT_DEFINED
    CTRACE(tfp, "HTAtom: New atom %p for `%s'\n", a, string);
#endif /* NOT_DEFINED */
    return a;
}
예제 #6
0
파일: HTChunk.c 프로젝트: avsm/openbsd-lynx
/*	Create a chunk with a certain allocation unit and ensured size
**	--------------
*/
PUBLIC HTChunk * HTChunkCreate2 ARGS2 (int,grow, size_t, needed)
{
    HTChunk * ch = typecalloc(HTChunk);
    if (ch == NULL)
	outofmem(__FILE__, "HTChunkCreate2");

    HTChunkInit (ch, grow);
    if (needed > 0) {
	ch->allocated = needed-1 - ((needed-1) % ch->growby)
	    + ch->growby; /* Round up */
	CTRACE((tfp, "HTChunkCreate2: requested %d, allocate %d\n",
	       (int) needed, ch->allocated));
	ch->data = typecallocn(char, ch->allocated);
	if (!ch->data)
	    outofmem(__FILE__, "HTChunkCreate2 data");
    }
예제 #7
0
파일: LYHistory.c 프로젝트: ezc/lynx
void LYAllocHistory(int entries)
{
    CTRACE((tfp, "LYAllocHistory %d vs %d\n", entries, size_history));
    if (entries + 1 >= size_history) {
	unsigned want;
	int save = size_history;

	size_history = (entries + 2) * 2;
	want = (unsigned) size_history *(unsigned) sizeof(*history);

	if (history == 0) {
	    history = typeMallocn(HistInfo, want);
	} else {
	    history = typeRealloc(HistInfo, history, want);
	}
	if (history == 0)
	    outofmem(__FILE__, "LYAllocHistory");

	assert(history != NULL);

	while (save < size_history) {
	    memset(&history[save++], 0, sizeof(history[0]));
	}
    }
    CTRACE((tfp, "...LYAllocHistory %d vs %d\n", entries, size_history));
}
예제 #8
0
파일: HTFormat.c 프로젝트: kotohvost/yui
/*	Define a presentation system command for a content-type
**	-------------------------------------------------------
*/
PUBLIC void HTSetPresentation ARGS6(
	HTList *,	conversions,
	CONST char *, 	representation,
	CONST char *, 	command,
	float,		quality,
	float,		secs,
	float,		secs_per_byte
){

    HTPresentation * pres = (HTPresentation *)malloc(sizeof(HTPresentation));
    if (pres == NULL) outofmem(__FILE__, "HTSetPresentation");

    pres->rep = HTAtom_for(representation);
    pres->rep_out = WWW_PRESENT;		/* Fixed for now ... :-) */
    pres->converter = HTSaveAndExecute;		/* Fixed for now ...     */
    pres->quality = quality;
    pres->secs = secs;
    pres->secs_per_byte = secs_per_byte;
    pres->rep = HTAtom_for(representation);
    pres->command = 0;
    StrAllocCopy(pres->command, command);

/*    if (!HTPresentations) HTPresentations = HTList_new(); */

#ifdef OLD_CODE
    if (strcmp(representation, "*")==0) {
        if (default_presentation) free(default_presentation);
	default_presentation = pres;
    } else
#endif
    HTList_addObject(conversions, pres);
}
예제 #9
0
/*	Define the representation associated with a file suffix
**	-------------------------------------------------------
**
**	Calling this with suffix set to "*" will set the default
**	representation.
**	Calling this with suffix set to "*.*" will set the default
**	representation for unknown suffix files which contain a ".".
*/
PUBLIC void HTSetSuffix ARGS4(
	WWW_CONST char *,	suffix,
	WWW_CONST char *,	representation,
	WWW_CONST char *,	encoding,
	float,		value)
{
    
    HTSuffix * suff;
    
    if (strcmp(suffix, "*")==0) suff = &no_suffix;
    else if (strcmp(suffix, "*.*")==0) suff = &unknown_suffix;
    else {
	suff = (HTSuffix*) calloc(1, sizeof(HTSuffix));
	if (suff == NULL) outofmem(__FILE__, "HTSetSuffix");
	
	if (!HTSuffixes) HTSuffixes = HTList_new();
	HTList_addObject(HTSuffixes, suff);
	
	StrAllocCopy(suff->suffix, suffix);
    }

    suff->rep = HTAtom_for(representation);
    
    {
    	char *enc = NULL, *p;
	StrAllocCopy(enc, encoding);
	for (p=enc; *p; p++) *p = TOLOWER(*p);
	suff->encoding = HTAtom_for(enc);
        free (enc);
    }
    
    suff->quality = value;
}
예제 #10
0
/* PUBLIC						HTAA_encryptPasswd()
**		ENCRYPT PASSWORD TO THE FORM THAT IT IS SAVED
**		IN THE PASSWORD FILE.
** ON ENTRY:
**	password	is a string of arbitrary lenght.
**
** ON EXIT:
**	returns		password in one-way encrypted form.
**
** NOTE:
**	Uses currently the C library function crypt(), which
**	only accepts at most 8 characters long strings and produces
**	always 13 characters long strings. This function is
**	called repeatedly so that longer strings can be encrypted.
**	This is of course not as safe as encrypting the entire
**	string at once, but then again, we are not that paranoid
**	about the security inside the machine.
**
*/
PUBLIC char *HTAA_encryptPasswd ARGS1(CONST char *, password)
{
    char salt[3];
    char chunk[9];
    char *result;
    char *tmp;
    CONST char *cur = password;
    int len = strlen(password);
    extern time_t theTime;
    int random = (int)theTime;	/* This is random enough */

    if (!(result = (char*)malloc(13*((strlen(password)+7)/8) + 1)))
	outofmem(__FILE__, "HTAA_encryptPasswd");

    *result = (char)0;
    while (len > 0) {
	salt[0] = salt_chars[random%64];
	salt[1] = salt_chars[(random/64)%64];
	salt[2] = (char)0;

	strncpy(chunk, cur, 8);
	chunk[8] = (char)0;

	tmp = crypt((char*)password, salt);  /*crypt() doesn't change its args*/
	strcat(result, tmp);

	cur += 8;
	len -= 8;
    } /* while */

    return result;
}
예제 #11
0
파일: HTFormat.c 프로젝트: kotohvost/yui
/*	Define a built-in function for a content-type
**	---------------------------------------------
*/
PUBLIC void HTSetConversion ARGS7(
	HTList *,	conversions,
	CONST char *, 	representation_in,
	CONST char *, 	representation_out,
	HTConverter*,	converter,
	float,		quality,
	float,		secs,
	float,		secs_per_byte
){

    HTPresentation * pres = (HTPresentation *)malloc(sizeof(HTPresentation));
    if (pres == NULL) outofmem(__FILE__, "HTSetPresentation");

    pres->rep = HTAtom_for(representation_in);
    pres->rep_out = HTAtom_for(representation_out);
    pres->converter = converter;
    pres->command = NULL;		/* Fixed */
    pres->quality = quality;
    pres->secs = secs;
    pres->secs_per_byte = secs_per_byte;
    pres->command = 0;

/*    if (!HTPresentations) HTPresentations = HTList_new();  */

#ifdef OLD_CODE
    if (strcmp(representation_in, "*")==0) {
        if (default_presentation) free(default_presentation);
	default_presentation = pres;
    } else
#endif
    HTList_addObject(conversions, pres);
}
예제 #12
0
/* PUBLIC						HTAA_setupReader()
 *		SET UP HEADER LINE READER, i.e., give
 *		the already-read-but-not-yet-processed
 *		buffer of text to be read before more
 *		is read from the socket.
 * ON ENTRY:
 *	start_of_headers is a pointer to a buffer containing
 *			the beginning of the header lines
 *			(rest will be read from a socket).
 *	length		is the number of valid characters in
 *			'start_of_headers' buffer.
 *	soc		is the socket to use when start_of_headers
 *			buffer is used up.
 * ON EXIT:
 *	returns		nothing.
 *			Subsequent calls to HTAA_getUnfoldedLine()
 *			will use this buffer first and then
 *			proceed to read from socket.
 */
void HTAA_setupReader(char *start_of_headers,
		      size_t length,
		      int soc)
{
    if (!start_of_headers)
	length = 0;		/* initialize length (is this reached at all?) */
    if (buffer == NULL) {	/* first call? */
	buffer_length = length;
	if (buffer_length < BUFFER_SIZE)	/* would fall below BUFFER_SIZE? */
	    buffer_length = BUFFER_SIZE;
	buffer = (char *) malloc((size_t) (sizeof(char) * (buffer_length + 1)));
    } else if (length > buffer_length) {	/* need more space? */
	buffer_length = length;
	buffer = (char *) realloc((char *) buffer,
				  (size_t) (sizeof(char) * (buffer_length + 1)));
    }
    if (buffer == NULL)
	outofmem(__FILE__, "HTAA_setupReader");

#ifdef LY_FIND_LEAKS
    atexit(FreeHTAAUtil);
#endif
    start_pointer = buffer;
    if (start_of_headers) {
	LYStrNCpy(buffer, start_of_headers, length);
	end_pointer = buffer + length;
    } else {
	*start_pointer = '\0';
	end_pointer = start_pointer;
    }
    in_soc = soc;
}
/* PUBLIC							HTVMS_name()
**		CONVERTS WWW name into a VMS name
** ON ENTRY:
**	nn		Node Name (optional)
**	fn		WWW file name
**
** ON EXIT:
**	returns 	vms file specification
**
** Bug:	Returns pointer to static -- non-reentrant
*/
PUBLIC char * HTVMS_name ARGS2(
	CONST char *, nn, 
	CONST char *, fn)
{

/*	We try converting the filename into Files-11 syntax. That is, we assume
**	first that the file is, like us, on a VMS node. We try remote
**	(or local) DECnet access. Files-11, VMS, VAX and DECnet
**	are trademarks of Digital Equipment Corporation. 
**	The node is assumed to be local if the hostname WITHOUT DOMAIN
**	matches the local one. @@@
*/
    static char vmsname[INFINITY];	/* returned */
    char * filename = (char*)malloc(strlen(fn)+1);
    char * nodename = (char*)malloc(strlen(nn)+2+1);	/* Copies to hack */
    char *second;		/* 2nd slash */
    char *last;			/* last slash */
    
    char * hostname = HTHostName();

    if (!filename || !nodename) outofmem(__FILE__, "HTVMSname");
    strcpy(filename, fn);
    strcpy(nodename, "");	/* On same node? Yes if node names match */
    if (strncmp(nn,"localhost",9)) {
        char *p, *q;
        for (p=hostname, q=nn; *p && *p!='.' && *q && *q!='.'; p++, q++){
	    if (TOUPPER(*p)!=TOUPPER(*q)) {
	        strcpy(nodename, nn);
		q = strchr(nodename, '.');	/* Mismatch */
		if (q) *q=0;			/* Chop domain */
		strcat(nodename, "::");		/* Try decnet anyway */
		break;
	    }
	}
    }

    second = strchr(filename+1, '/');		/* 2nd slash */
    last = strrchr(filename, '/');	/* last slash */
        
    if (!second) {				/* Only one slash */
	sprintf(vmsname, "%s%s", nodename, filename + 1);
    } else if(second==last) {		/* Exactly two slashes */
	*second = 0;		/* Split filename from disk */
	sprintf(vmsname, "%s%s:%s", nodename, filename+1, second+1);
	*second = '/';	/* restore */
    } else { 				/* More than two slashes */
	char * p;
	*second = 0;		/* Split disk from directories */
	*last = 0;		/* Split dir from filename */
	sprintf(vmsname, "%s%s:[%s]%s",
		nodename, filename+1, second+1, last+1);
	*second = *last = '/';	/* restore filename */
	for (p=strchr(vmsname, '['); *p!=']'; p++)
	    if (*p=='/') *p='.';	/* Convert dir sep.  to dots */
    }
    free(nodename);
    free(filename);
    return vmsname;
}
예제 #14
0
파일: HTString.c 프로젝트: csev/xmosaic-1.2
PUBLIC char * HTSACat
  ARGS2 (char **,dest, CONST char *,src)
{
  if (src && *src) {
    if (*dest) {
      int length = strlen (*dest);
      *dest = (char *) realloc (*dest, length + strlen(src) + 1);
      if (*dest == NULL) outofmem(__FILE__, "HTSACat");
      strcpy (*dest + length, src);
    } else {
      *dest = (char *) malloc (strlen(src) + 1);
      if (*dest == NULL) outofmem(__FILE__, "HTSACat");
      strcpy (*dest, src);
    }
  }
  return *dest;
}
예제 #15
0
HTStyleSheet *HTStyleSheetNew(void)
{
    HTStyleSheet *self = typecalloc(HTStyleSheet);

    if (self == NULL)
	outofmem(__FILE__, "HTStyleSheetNew");
    return self;
}
예제 #16
0
파일: HTRules.c 프로젝트: kotohvost/yui
PUBLIC int HTAddRule ARGS3(HTRuleOp,		op,
			   CONST char *,	pattern,
			   CONST char *,	equiv)
{ /* BYTE_ADDRESSING removed and memory check - AS - 1 Sep 93 */
    rule *      temp;
    char *      pPattern;

    temp = (rule *)malloc(sizeof(*temp));
    if (temp==NULL) 
	outofmem(__FILE__, "HTAddRule"); 
    pPattern = (char *)malloc(strlen(pattern)+1);
    if (pPattern==NULL) 
	outofmem(__FILE__, "HTAddRule"); 
    if (equiv) {		/* Two operands */
	char *	pEquiv = (char *)malloc(strlen(equiv)+1);
	if (pEquiv==NULL) 
	    outofmem(__FILE__, "HTAddRule"); 
        temp->equiv = pEquiv;
        strcpy(pEquiv, equiv);
    } else {
        temp->equiv = 0;
    }
    temp->pattern = pPattern;
    temp->op = op;

    strcpy(pPattern, pattern);
    if (TRACE) {
       if (equiv)
          fprintf(stderr, "Rule: For `%s' op %d `%s'\n", pattern, op, equiv);
       else
          fprintf(stderr, "Rule: For `%s' op %d\n", pattern, op);
    }

#ifdef PUT_ON_HEAD
    temp->next = rules;
    rules = temp;
#else
    temp->next = 0;
    if (rule_tail) rule_tail->next = temp;
    else rules = temp;
    rule_tail = temp;
#endif

        
    return 0;
}
예제 #17
0
파일: re.C 프로젝트: debdungeon/qint
inline RegExpNode	*Re::allocnode()
{
RegExpNode	*n;

	if ((n=new RegExpNode(nextid++)) == 0)
		outofmem();
	n->next=nodes; nodes=n; return(n);
}
예제 #18
0
/*      Output parent directory entry
**
**    This gives the TITLE and H1 header, and also a link
**    to the parent directory if appropriate.
*/
PUBLIC void HTDirTitles ARGS2(HTStructured *, target,
		 HTAnchor * , anchor)

{
    char * logical = HTAnchor_address(anchor);
    char * path = HTParse(logical, "", PARSE_PATH + PARSE_PUNCTUATION);
    char * current;

    current = strrchr(path, '/');	/* last part or "" */
    free(logical);

    {
      char * printable = NULL;
      StrAllocCopy(printable, (current + 1));
      HTUnEscape(printable);
      START(HTML_TITLE);
      PUTS(*printable ? printable : "Welcome ");
      PUTS(" directory");
      END(HTML_TITLE);    
    
      START(HTML_H1);
      PUTS(*printable ? printable : "Welcome");
      END(HTML_H1);
      free(printable);
    }

    /*  Make link back to parent directory
     */

    if (current && current[1]) {   /* was a slash AND something else too */
        char * parent;
	char * relative;
	*current++ = 0;
      parent = strrchr(path, '/');  /* penultimate slash */

	relative = (char*) malloc(strlen(current) + 4);
	if (relative == NULL) outofmem(__FILE__, "DirRead");
	sprintf(relative, "%s/..", current);
        PUTS ("<A HREF=\"");
        PUTS (relative);
        PUTS ("\">");
	free(relative);

	PUTS("Up to ");
	if (parent) {
	  char * printable = NULL;
	  StrAllocCopy(printable, parent + 1);
	  HTUnEscape(printable);
	  PUTS(printable);
	  free(printable);
	} else {
	  PUTS("/");
	}

        PUTS("</A>");
      }
    free(path);
}
예제 #19
0
/*	Tee creation
*/
PUBLIC HTStream * HTTee ARGS2(HTStream *, s1,HTStream *, s2)
{
    HTStream * me = (HTStream*)malloc(sizeof(*me));
    if (!me) outofmem(__FILE__, "HTTee");
    me->isa = &HTTeeClass;
    me->s1 = s1;
    me->s2 = s2;
    return me;
}
예제 #20
0
int HTAddRule(HTRuleOp op, const char *pattern,
	      const char *equiv,
	      const char *cond_op,
	      const char *cond)
{				/* BYTE_ADDRESSING removed and memory check - AS - 1 Sep 93 */
    rule *temp;
    char *pPattern = NULL;

    temp = typecalloc(rule);
    if (temp == NULL)
	outofmem(__FILE__, "HTAddRule");
    if (equiv) {		/* Two operands */
	char *pEquiv = NULL;

	StrAllocCopy(pEquiv, equiv);
	temp->equiv = pEquiv;
    } else {
	temp->equiv = 0;
    }
    if (cond_op) {
	StrAllocCopy(temp->condition_op, cond_op);
	StrAllocCopy(temp->condition, cond);
    }
    StrAllocCopy(pPattern, pattern);
    temp->pattern = pPattern;
    temp->op = op;

    if (equiv) {
	CTRACE((tfp, "Rule: For `%s' op %d `%s'", pattern, op, equiv));
    } else {
	CTRACE((tfp, "Rule: For `%s' op %d", pattern, op));
    }
    if (cond_op) {
	CTRACE((tfp, "\t%s %s\n", cond_op, NONNULL(cond)));
    } else {
	CTRACE((tfp, "\n"));
    }

    if (!rules) {
#ifdef LY_FIND_LEAKS
	atexit(HTClearRules);
#endif
    }
#ifdef PUT_ON_HEAD
    temp->next = rules;
    rules = temp;
#else
    temp->next = 0;
    if (rule_tail)
	rule_tail->next = temp;
    else
	rules = temp;
    rule_tail = temp;
#endif

    return 0;
}
예제 #21
0
파일: HTChunk.c 프로젝트: avsm/openbsd-lynx
/*	Create a chunk with a certain allocation unit
**	--------------
*/
PUBLIC HTChunk * HTChunkCreate ARGS1 (int,grow)
{
    HTChunk * ch = typecalloc(HTChunk);
    if (ch == NULL)
	outofmem(__FILE__, "creation of chunk");

    HTChunkInit (ch, grow);
    return ch;
}
예제 #22
0
HTStyleSheet *HTStyleSheetNew( void )
{
  HTStyleSheet *self = calloc( 1, sizeof( HTStyleSheet ) );
  if ( self == 0 )
  {
    outofmem( "../../../WWW/Library/Implementation/HTStyle.c", "HTStyleSheetNew" );
  }
  return self;
}
예제 #23
0
PRIVATE HTChildAnchor * HTChildAnchor_new ARGS1(
	HTParentAnchor0 *,	parent)
{
    HTChildAnchor *p = typecalloc(HTChildAnchor);
    if (p == NULL)
	outofmem(__FILE__, "HTChildAnchor_new");

    p->parent = parent;		/* parent reference */
    return p;
}
예제 #24
0
/*
 * Set the value of a variable
 * Add variable to global list if not existent
 */
void set_variable(char *name, char *text, long int intval)
{
int i;

    /* Check if variable is in list */
    for ( i = 0 ; i < numvariables && strcmp(name, variables[i].varsymbol) != 0 ; i++ );
    if (i == numvariables)
    {
	/* Enlarge list for one additional element */
	numvariables++;
	variables = ReAllocVec(variables, sizeof(struct VariableList) * numvariables, MEMF_PUBLIC);
	outofmem(variables);
	variables[i].varsymbol = NULL;
	variables[i].vartext = NULL;
    }
    else
    {
	/* Free space for strings to be replaced in dynamic list */
	FreeVec(variables[i].vartext);
	variables[i].vartext = NULL;
    }

    /* Change values in list */

    /* Duplicate variable name if it does not exist yet */
  
    if (variables[i].varsymbol == NULL)
    {
	variables[i].varsymbol = StrDup(name);
	outofmem(variables[i].varsymbol);
    }

    /* Duplicate variable text if existent */
    if (text != NULL)
    {
	variables[i].vartext = StrDup(text);
	outofmem(variables[i].vartext);
    }

    /* Set integer value */
    variables[i].varinteger = intval;

}
예제 #25
0
파일: HTAtom.c 프로젝트: kotohvost/yui
PUBLIC HTAtom * HTAtom_for ARGS1(CONST char *, string)
{
    int hash;
    CONST char * p;
    HTAtom * a;
    
    /*		First time around, clear hash table
    */
    if (!initialised) {
        int i;
	for (i=0; i<HASH_SIZE; i++)
	    hash_table[i] = (HTAtom *) 0;
	initialised = YES;
    }
    
    /*		Generate hash function
    */
    for(p=string, hash=0; *p; p++) {
        hash = (hash * 3 + *p) % HASH_SIZE;
    }
    
    /*		Search for the string in the list
    */
    for (a=hash_table[hash]; a; a=a->next) {
	if (0==strcmp(a->name, string)) {
    	    /* if (TRACE) fprintf(stderr,
	    	"HTAtom: Old atom %p for `%s'\n", a, string); */
	    return a;				/* Found: return it */
	}
    }
    
    /*		Generate a new entry
    */
    a = (HTAtom *)malloc(sizeof(*a));
    if (a == NULL) outofmem(__FILE__, "HTAtom_for");
    a->name = (char *)malloc(strlen(string)+1);
    if (a->name == NULL) outofmem(__FILE__, "HTAtom_for");
    strcpy(a->name, string);
    a->next = hash_table[hash];		/* Put onto the head of list */
    hash_table[hash] = a;
/*    if (TRACE) fprintf(stderr, "HTAtom: New atom %p for `%s'\n", a, string); */
    return a;
}
예제 #26
0
파일: HTChunk.c 프로젝트: sribits/lynx
/*	Create a chunk with a certain allocation unit and ensured size
 *	--------------
 */
HTChunk *HTChunkCreate2(int grow, size_t needed)
{
    HTChunk *ch = typecalloc(HTChunk);

    if (ch == NULL)
        outofmem(__FILE__, "HTChunkCreate2");

    HTChunkInit(ch, grow);
    if (needed > 0) {
        /* Round up */
        ch->allocated = (int) (needed - 1 - ((needed - 1) % ch->growby)
                               + (unsigned) ch->growby);
        CTRACE((tfp, "HTChunkCreate2: requested %d, allocate %u\n",
                (int) needed, (unsigned) ch->allocated));
        ch->data = typecallocn(char, (unsigned) ch->allocated);

        if (!ch->data)
            outofmem(__FILE__, "HTChunkCreate2 data");
    }
예제 #27
0
/* PUBLIC						HTAA_passwdMatch()
**		VERIFY THE CORRECTNESS OF A GIVEN PASSWORD
**		AGAINST A ONE-WAY ENCRYPTED FORM OF PASSWORD.
** ON ENTRY:
**	password	is cleartext password.
**	encrypted	is one-way encrypted password, as returned
**			by function HTAA_encryptPasswd().
**			This is typically read from the password
**			file.
**
** ON EXIT:
**	returns		YES, if password matches the encrypted one.
**			NO, if not, or if either parameter is NULL.
** FIX:
**	Only the length of original encrypted password is
**	checked -- longer given passwords are accepted if
**	common length is correct (but not shorter).
**	This is to allow interoperation of servers and clients
**	who have a hard-coded limit of 8 to password.
*/
PUBLIC BOOL HTAA_passwdMatch ARGS2(CONST char *, password,
				   CONST char *, encrypted)
{
    char *result;
    int len;
    int status;

    if (!password || !encrypted)
	return NO;

    len = 13*((strlen(password)+7)/8);
    if (len < strlen(encrypted))
	return NO;

    if (!(result = (char*)malloc(len + 1)))
	outofmem(__FILE__, "HTAA_encryptPasswd");

    *result = (char)0;
    while (len > 0) {
	char salt[3];
	char chunk[9];
	CONST char *cur1 = password;
	CONST char *cur2 = encrypted;
	char *tmp;

	salt[0] = *cur2;
	salt[1] = *(cur2+1);
	salt[2] = (char)0;

	strncpy(chunk, cur1, 8);
	chunk[8] = (char)0;

	tmp = crypt((char*)password, salt);
	strcat(result, tmp);

	cur1 += 8;
	cur2 += 13;
	len -= 13;
    } /* while */

    status = strncmp(result, encrypted, strlen(encrypted));

    if (TRACE)
	fprintf(stderr, "%s `%s' with `%s' => %s\n",
		"HTAA_passwdMatch: Matching encrypted password:"******"OK" : "INCORRECT"));

    free(result);

    if (status==0)
	return YES;
    else
	return NO;
}
예제 #28
0
PUBLIC char * WWW_nameOfFile ARGS1 (WWW_CONST char *,name)
{
    char * result;
    result = (char *)malloc(7+strlen(HTHostName())+strlen(name)+1);
    if (result == NULL) outofmem(__FILE__, "WWW_nameOfFile");
    sprintf(result, "file://%s%s", HTHostName(), name);
#ifndef DISABLE_TRACE
    if (www2Trace) fprintf(stderr, "File `%s'\n\tmeans node `%s'\n", name, result);
#endif
    return result;
}
예제 #29
0
HTBTree *HTBTree_new( HTComparer comp )
{
  HTBTree *tree = malloc( ( 1 ) * sizeof( HTBTree ) );
  if ( tree == 0 )
  {
    outofmem( "../../../WWW/Library/Implementation/HTBTree.c", "HTBTree_new" );
  }
  tree->compare = comp;
  tree->top->object = 0;
  return tree;
}
예제 #30
0
PRIVATE HTChildAnchor * HText_pool_ChildAnchor_new ARGS1(
	HTParentAnchor *,	parent)
{
    HTChildAnchor *p = (HTChildAnchor *)HText_pool_calloc((HText*)(parent->document),
						sizeof(HTChildAnchor));
    if (p == NULL)
	outofmem(__FILE__, "HText_pool_ChildAnchor_new");

    p->parent = parent->parent;	/* parent reference */
    return p;
}