/* NULL terminated list of names/aliases sorted in order of descending importance */
ASDatabaseRecord *
fill_asdb_record (ASDatabase * db, char **names, ASDatabaseRecord * reusable_memory, Bool dup_strings)
{
	ASDatabaseRecord *db_rec = NULL;

	if (db && names)
	{
		if (reusable_memory)
		{
			db_rec = reusable_memory;
			memset (db_rec, 0x00, sizeof (ASDatabaseRecord));
		} else
			db_rec = (ASDatabaseRecord *) safecalloc (1, sizeof (ASDatabaseRecord));

		db_rec->magic = MAGIC_ASDBRECORD;

		/* TODO : */
		/* build list of matching styles in order of descending importance */
		if (build_matching_list (db, names))
		{									   /* go through the list trying to extract as much data as possible  */
			register int  i;

			match_flags (&(db_rec->set_flags), &(db_rec->flags), db, MATCH_Flags);
			if (get_flags (db_rec->set_flags, STYLE_BUTTONS))
				match_flags (&(db_rec->set_buttons), &(db_rec->buttons), db, MATCH_Buttons);

			match_data_flags (&(db_rec->set_data_flags), db);
			
			if (get_flags (db_rec->set_data_flags, STYLE_STARTUP_DESK))
				db_rec->desk = match_int (db, MATCH_Desk);
			if (get_flags (db_rec->set_data_flags, STYLE_LAYER))
				db_rec->layer = match_int (db, MATCH_layer);
			if (get_flags (db_rec->set_data_flags, STYLE_VIEWPORTX))
			{
				LOCAL_DEBUG_OUT( "Matching viewport_x%s","");	  
				db_rec->viewport_x = match_int (db, MATCH_ViewportX);
			}
			if (get_flags (db_rec->set_data_flags, STYLE_VIEWPORTY))
				db_rec->viewport_y = match_int (db, MATCH_ViewportY);
			if (get_flags (db_rec->set_data_flags, STYLE_BORDER_WIDTH))
				db_rec->border_width = match_int (db, MATCH_border_width);
			if (get_flags (db_rec->set_data_flags, STYLE_HANDLE_WIDTH))
				db_rec->resize_width = match_int (db, MATCH_resize_width);
			if (get_flags (db_rec->set_data_flags, STYLE_GRAVITY))
				db_rec->gravity = match_int (db, MATCH_gravity);
			if (get_flags (db_rec->set_data_flags, STYLE_WINDOW_OPACITY))
				db_rec->window_opacity = match_int (db, MATCH_window_opacity);

			if (get_flags (db_rec->set_data_flags, STYLE_DEFAULT_GEOMETRY))
				db_rec->default_geometry = *((ASGeometry *) match_struct (db, MATCH_DefaultGeometry));

			if (get_flags (db_rec->set_data_flags, STYLE_ICON))
				db_rec->icon_file = match_string (db, MATCH_Icon, 0, dup_strings);
			if (get_flags (db_rec->set_data_flags, STYLE_FRAME))
				db_rec->frame_name = match_string (db, MATCH_Frame, 0, dup_strings);
			if (get_flags (db_rec->set_data_flags, STYLE_WINDOWBOX))
				db_rec->windowbox_name = match_string (db, MATCH_Windowbox, 0, dup_strings);
			if (get_flags (db_rec->set_flags, STYLE_MYSTYLES))
				for (i = 0; i < BACK_STYLES; i++)
					if (db_rec->window_styles[i])
						db_rec->window_styles[i] = match_string (db, MATCH_MyStyle, i, dup_strings);
		}
	}
	return db_rec;
}
Beispiel #2
0
static inline bool
match_packet(const struct sk_buff *skb,
	     unsigned int offset,
	     const struct xt_sctp_info *info,
	     bool *hotdrop)
{
	u_int32_t chunkmapcopy[256 / sizeof (u_int32_t)];
	const sctp_chunkhdr_t *sch;
	sctp_chunkhdr_t _sch;
	int chunk_match_type = info->chunk_match_type;
	const struct xt_sctp_flag_info *flag_info = info->flag_info;
	int flag_count = info->flag_count;

#ifdef DEBUG_SCTP
	int i = 0;
#endif

	if (chunk_match_type == SCTP_CHUNK_MATCH_ALL)
		SCTP_CHUNKMAP_COPY(chunkmapcopy, info->chunkmap);

	do {
		sch = skb_header_pointer(skb, offset, sizeof(_sch), &_sch);
		if (sch == NULL || sch->length == 0) {
			duprintf("Dropping invalid SCTP packet.\n");
			*hotdrop = true;
			return false;
		}

		duprintf("Chunk num: %d\toffset: %d\ttype: %d\tlength: %d\tflags: %x\n",
				++i, offset, sch->type, htons(sch->length), sch->flags);

		offset += (ntohs(sch->length) + 3) & ~3;

		duprintf("skb->len: %d\toffset: %d\n", skb->len, offset);

		if (SCTP_CHUNKMAP_IS_SET(info->chunkmap, sch->type)) {
			switch (chunk_match_type) {
			case SCTP_CHUNK_MATCH_ANY:
				if (match_flags(flag_info, flag_count,
					sch->type, sch->flags)) {
					return true;
				}
				break;

			case SCTP_CHUNK_MATCH_ALL:
				if (match_flags(flag_info, flag_count,
				    sch->type, sch->flags))
					SCTP_CHUNKMAP_CLEAR(chunkmapcopy, sch->type);
				break;

			case SCTP_CHUNK_MATCH_ONLY:
				if (!match_flags(flag_info, flag_count,
				    sch->type, sch->flags))
					return false;
				break;
			}
		} else {
			switch (chunk_match_type) {
			case SCTP_CHUNK_MATCH_ONLY:
				return false;
			}
		}
	} while (offset < skb->len);

	switch (chunk_match_type) {
	case SCTP_CHUNK_MATCH_ALL:
		return SCTP_CHUNKMAP_IS_CLEAR(chunkmapcopy);
	case SCTP_CHUNK_MATCH_ANY:
		return false;
	case SCTP_CHUNK_MATCH_ONLY:
		return true;
	}

	/* This will never be reached, but required to stop compiler whine */
	return false;
}