diff --git a/common/list.c b/common/list.c index b5039869..02763bf3 100644 --- a/common/list.c +++ b/common/list.c @@ -341,16 +341,6 @@ list_dump_items(struct list *self) } } -/******************************************************************************/ -/** - * Appends a string fragment to a list - * @param[in,out] start Pointer to start of fragment (by reference) - * @param end Pointer to one past end of fragment - * @param list List to append to - * @result 1 for success - * - * In the event of a memory failure, 0 is returned and the list is deleted. - */ int split_string_append_fragment(const char **start, const char *end, struct list *list) diff --git a/common/list.h b/common/list.h index c330fa8a..e04eaa03 100644 --- a/common/list.h +++ b/common/list.h @@ -95,6 +95,19 @@ list_append_list_strdup(struct list *self, struct list *dest, int start_index); void list_dump_items(struct list *self); +/** + * Appends a string fragment to a list + * @param[in,out] start Pointer to start of fragment (by reference) + * @param end Pointer to one past end of fragment + * @param list List to append to + * @result 1 for success + * + * In the event of a memory failure, 0 is returned and the list is deleted. + */ +int +split_string_append_fragment(const char **start, const char *end, + struct list *list); + /** * Splits a string on a separation character and then returns a list of * the string split by the character, without the character contained within diff --git a/common/log.c b/common/log.c index fe8bbcb5..51362e6a 100644 --- a/common/log.c +++ b/common/log.c @@ -55,7 +55,7 @@ static struct log_config *g_staticLogConfig = NULL; * @return see open(2) return values * */ -int +static int internal_log_file_open(const char *fname) { int ret = -1; @@ -88,7 +88,7 @@ internal_log_file_open(const char *fname) * @return syslog equivalent logging level * */ -int +static int internal_log_xrdp2syslog(const enum logLevels lvl) { switch (lvl) @@ -275,7 +275,7 @@ internal_log_text2level(const char *buf) } /******************************************************************************/ -struct log_config * +static struct log_config * internal_config_read_logging(int file, const char *applicationName, const char *section_prefix) @@ -547,7 +547,7 @@ internal_log_config_copy_levels(struct log_config *dest, #endif } -void +static void internal_log_config_copy(struct log_config *dest, const struct log_config *src) { if (src != NULL && dest != NULL) diff --git a/common/pixman-region.c b/common/pixman-region.c index 25ea48da..899bd58e 100644 --- a/common/pixman-region.c +++ b/common/pixman-region.c @@ -306,96 +306,6 @@ alloc_data (size_t n) } \ } while (0) -PIXMAN_EXPORT pixman_bool_t -PREFIX (_equal) (region_type_t *reg1, region_type_t *reg2) -{ - int i; - box_type_t *rects1; - box_type_t *rects2; - - if (reg1->extents.x1 != reg2->extents.x1) - { - return FALSE; - } - - if (reg1->extents.x2 != reg2->extents.x2) - { - return FALSE; - } - - if (reg1->extents.y1 != reg2->extents.y1) - { - return FALSE; - } - - if (reg1->extents.y2 != reg2->extents.y2) - { - return FALSE; - } - - if (PIXREGION_NUMRECTS (reg1) != PIXREGION_NUMRECTS (reg2)) - { - return FALSE; - } - - rects1 = PIXREGION_RECTS (reg1); - rects2 = PIXREGION_RECTS (reg2); - - for (i = 0; i != PIXREGION_NUMRECTS (reg1); i++) - { - if (rects1[i].x1 != rects2[i].x1) - { - return FALSE; - } - - if (rects1[i].x2 != rects2[i].x2) - { - return FALSE; - } - - if (rects1[i].y1 != rects2[i].y1) - { - return FALSE; - } - - if (rects1[i].y2 != rects2[i].y2) - { - return FALSE; - } - } - - return TRUE; -} - -int -PREFIX (_print) (region_type_t *rgn) -{ - int num, size; - int i; - box_type_t *rects; - - num = PIXREGION_NUMRECTS (rgn); - size = PIXREGION_SIZE (rgn); - rects = PIXREGION_RECTS (rgn); - - fprintf (stderr, "num: %d size: %d\n", num, size); - fprintf (stderr, "extents: %d %d %d %d\n", - rgn->extents.x1, - rgn->extents.y1, - rgn->extents.x2, - rgn->extents.y2); - - for (i = 0; i < num; i++) - { - fprintf (stderr, "%d %d %d %d \n", - rects[i].x1, rects[i].y1, rects[i].x2, rects[i].y2); - } - - fprintf (stderr, "\n"); - - return (num); -} - PIXMAN_EXPORT void PREFIX (_init) (region_type_t *region) @@ -429,23 +339,6 @@ PREFIX (_init_rect) (region_type_t *region, region->data = NULL; } -PIXMAN_EXPORT void -PREFIX (_init_with_extents) (region_type_t *region, box_type_t *extents) -{ - if (!GOOD_RECT (extents)) - { - if (BAD_RECT (extents)) - { - _pixman_log_error (FUNC, "Invalid rectangle passed"); - } - PREFIX (_init) (region); - return; - } - region->extents = *extents; - - region->data = NULL; -} - PIXMAN_EXPORT void PREFIX (_fini) (region_type_t *region) { @@ -453,12 +346,6 @@ PREFIX (_fini) (region_type_t *region) FREE_DATA (region); } -PIXMAN_EXPORT int -PREFIX (_n_rects) (region_type_t *region) -{ - return PIXREGION_NUMRECTS (region); -} - PIXMAN_EXPORT box_type_t * PREFIX (_rectangles) (region_type_t *region, int *n_rects) @@ -551,7 +438,7 @@ pixman_rect_alloc (region_type_t *region, return TRUE; } -PIXMAN_EXPORT pixman_bool_t +static PIXMAN_EXPORT pixman_bool_t PREFIX (_copy) (region_type_t *dst, region_type_t *src) { GOOD (dst); @@ -1408,24 +1295,6 @@ pixman_region_union_o (region_type_t *region, return TRUE; } -PIXMAN_EXPORT pixman_bool_t -PREFIX(_intersect_rect) (region_type_t *dest, - region_type_t *source, - int x, int y, - unsigned int width, - unsigned int height) -{ - region_type_t region; - - region.data = NULL; - region.extents.x1 = x; - region.extents.y1 = y; - region.extents.x2 = x + width; - region.extents.y2 = y + height; - - return PREFIX(_intersect) (dest, source, ®ion); -} - PIXMAN_EXPORT pixman_bool_t PREFIX (_union) (region_type_t *new_reg, region_type_t *reg1, @@ -1525,38 +1394,6 @@ PREFIX (_union) (region_type_t *new_reg, return TRUE; } -/* Convenience function for performing union of region with a - * single rectangle - */ -PIXMAN_EXPORT pixman_bool_t -PREFIX (_union_rect) (region_type_t *dest, - region_type_t *source, - int x, - int y, - unsigned int width, - unsigned int height) -{ - region_type_t region; - - region.extents.x1 = x; - region.extents.y1 = y; - region.extents.x2 = x + width; - region.extents.y2 = y + height; - - if (!GOOD_RECT (®ion.extents)) - { - if (BAD_RECT (®ion.extents)) - { - _pixman_log_error (FUNC, "Invalid rectangle passed"); - } - return PREFIX (_copy) (dest, source); - } - - region.data = NULL; - - return PREFIX (_union) (dest, source, ®ion); -} - /*====================================================================== * Batch Rectangle Union *====================================================================*/ @@ -1569,395 +1406,6 @@ PREFIX (_union_rect) (region_type_t *dest, rects[b] = t; \ } -static void -quick_sort_rects ( - box_type_t rects[], - int numRects) -{ - int y1; - int x1; - int i, j; - box_type_t *r; - - /* Always called with numRects > 1 */ - - do - { - if (numRects == 2) - { - if (rects[0].y1 > rects[1].y1 || - (rects[0].y1 == rects[1].y1 && rects[0].x1 > rects[1].x1)) - { - EXCHANGE_RECTS (0, 1); - } - - return; - } - - /* Choose partition element, stick in location 0 */ - EXCHANGE_RECTS (0, numRects >> 1); - y1 = rects[0].y1; - x1 = rects[0].x1; - - /* Partition array */ - i = 0; - j = numRects; - - do - { - r = &(rects[i]); - do - { - r++; - i++; - } - while (i != numRects && (r->y1 < y1 || (r->y1 == y1 && r->x1 < x1))); - - r = &(rects[j]); - do - { - r--; - j--; - } - while (y1 < r->y1 || (y1 == r->y1 && x1 < r->x1)); - - if (i < j) - { - EXCHANGE_RECTS (i, j); - } - } - while (i < j); - - /* Move partition element back to middle */ - EXCHANGE_RECTS (0, j); - - /* Recurse */ - if (numRects - j - 1 > 1) - { - quick_sort_rects (&rects[j + 1], numRects - j - 1); - } - - numRects = j; - } - while (numRects > 1); -} - -/*- - *----------------------------------------------------------------------- - * pixman_region_validate -- - * - * Take a ``region'' which is a non-y-x-banded random collection of - * rectangles, and compute a nice region which is the union of all the - * rectangles. - * - * Results: - * TRUE if successful. - * - * Side Effects: - * The passed-in ``region'' may be modified. - * overlap set to TRUE if any rectangles overlapped, - * else FALSE; - * - * Strategy: - * Step 1. Sort the rectangles into ascending order with primary key y1 - * and secondary key x1. - * - * Step 2. Split the rectangles into the minimum number of proper y-x - * banded regions. This may require horizontally merging - * rectangles, and vertically coalescing bands. With any luck, - * this step in an identity transformation (ala the Box widget), - * or a coalescing into 1 box (ala Menus). - * - * Step 3. Merge the separate regions down to a single region by calling - * pixman_region_union. Maximize the work each pixman_region_union call does by using - * a binary merge. - * - *----------------------------------------------------------------------- - */ - -static pixman_bool_t -validate (region_type_t *badreg) -{ - /* Descriptor for regions under construction in Step 2. */ - typedef struct - { - region_type_t reg; - int prev_band; - int cur_band; - } region_info_t; - - region_info_t stack_regions[64]; - - int numRects; /* Original numRects for badreg */ - region_info_t *ri; /* Array of current regions */ - int num_ri; /* Number of entries used in ri */ - int size_ri; /* Number of entries available in ri */ - int i; /* Index into rects */ - int j; /* Index into ri */ - region_info_t *rit; /* &ri[j] */ - region_type_t *reg; /* ri[j].reg */ - box_type_t *box; /* Current box in rects */ - box_type_t *ri_box; /* Last box in ri[j].reg */ - region_type_t *hreg; /* ri[j_half].reg */ - pixman_bool_t ret = TRUE; - - if (!badreg->data) - { - GOOD (badreg); - return TRUE; - } - - numRects = badreg->data->numRects; - if (!numRects) - { - if (PIXREGION_NAR (badreg)) - { - return FALSE; - } - GOOD (badreg); - return TRUE; - } - - if (badreg->extents.x1 < badreg->extents.x2) - { - if ((numRects) == 1) - { - FREE_DATA (badreg); - badreg->data = (region_data_type_t *) NULL; - } - else - { - DOWNSIZE (badreg, numRects); - } - - GOOD (badreg); - - return TRUE; - } - - /* Step 1: Sort the rects array into ascending (y1, x1) order */ - quick_sort_rects (PIXREGION_BOXPTR (badreg), numRects); - - /* Step 2: Scatter the sorted array into the minimum number of regions */ - - /* Set up the first region to be the first rectangle in badreg */ - /* Note that step 2 code will never overflow the ri[0].reg rects array */ - ri = stack_regions; - size_ri = sizeof (stack_regions) / sizeof (stack_regions[0]); - num_ri = 1; - ri[0].prev_band = 0; - ri[0].cur_band = 0; - ri[0].reg = *badreg; - box = PIXREGION_BOXPTR (&ri[0].reg); - ri[0].reg.extents = *box; - ri[0].reg.data->numRects = 1; - badreg->extents = *pixman_region_empty_box; - badreg->data = pixman_region_empty_data; - - /* Now scatter rectangles into the minimum set of valid regions. If the - * next rectangle to be added to a region would force an existing rectangle - * in the region to be split up in order to maintain y-x banding, just - * forget it. Try the next region. If it doesn't fit cleanly into any - * region, make a new one. - */ - - for (i = numRects; --i > 0;) - { - box++; - /* Look for a region to append box to */ - for (j = num_ri, rit = ri; --j >= 0; rit++) - { - reg = &rit->reg; - ri_box = PIXREGION_END (reg); - - if (box->y1 == ri_box->y1 && box->y2 == ri_box->y2) - { - /* box is in same band as ri_box. Merge or append it */ - if (box->x1 <= ri_box->x2) - { - /* Merge it with ri_box */ - if (box->x2 > ri_box->x2) - { - ri_box->x2 = box->x2; - } - } - else - { - RECTALLOC_BAIL (reg, 1, bail); - *PIXREGION_TOP (reg) = *box; - reg->data->numRects++; - } - - goto next_rect; /* So sue me */ - } - else if (box->y1 >= ri_box->y2) - { - /* Put box into new band */ - if (reg->extents.x2 < ri_box->x2) - { - reg->extents.x2 = ri_box->x2; - } - - if (reg->extents.x1 > box->x1) - { - reg->extents.x1 = box->x1; - } - - COALESCE (reg, rit->prev_band, rit->cur_band); - rit->cur_band = reg->data->numRects; - RECTALLOC_BAIL (reg, 1, bail); - *PIXREGION_TOP (reg) = *box; - reg->data->numRects++; - - goto next_rect; - } - /* Well, this region was inappropriate. Try the next one. */ - } /* for j */ - - /* Uh-oh. No regions were appropriate. Create a new one. */ - if (size_ri == num_ri) - { - size_t data_size; - - /* Oops, allocate space for new region information */ - size_ri <<= 1; - - data_size = size_ri * sizeof(region_info_t); - if (data_size / size_ri != sizeof(region_info_t)) - { - goto bail; - } - - if (ri == stack_regions) - { - rit = (region_info_t *) malloc(data_size); - if (!rit) - { - goto bail; - } - memcpy (rit, ri, num_ri * sizeof (region_info_t)); - } - else - { - rit = (region_info_t *) realloc (ri, data_size); - if (!rit) - { - goto bail; - } - } - ri = rit; - rit = &ri[num_ri]; - } - num_ri++; - rit->prev_band = 0; - rit->cur_band = 0; - rit->reg.extents = *box; - rit->reg.data = (region_data_type_t *)NULL; - - /* MUST force allocation */ - if (!pixman_rect_alloc (&rit->reg, (i + num_ri) / num_ri)) - { - goto bail; - } - -next_rect: - ; - } /* for i */ - - /* Make a final pass over each region in order to COALESCE and set - * extents.x2 and extents.y2 - */ - for (j = num_ri, rit = ri; --j >= 0; rit++) - { - reg = &rit->reg; - ri_box = PIXREGION_END (reg); - reg->extents.y2 = ri_box->y2; - - if (reg->extents.x2 < ri_box->x2) - { - reg->extents.x2 = ri_box->x2; - } - - COALESCE (reg, rit->prev_band, rit->cur_band); - - if (reg->data->numRects == 1) /* keep unions happy below */ - { - FREE_DATA (reg); - reg->data = (region_data_type_t *)NULL; - } - } - - /* Step 3: Union all regions into a single region */ - while (num_ri > 1) - { - int half = num_ri / 2; - for (j = num_ri & 1; j < (half + (num_ri & 1)); j++) - { - reg = &ri[j].reg; - hreg = &ri[j + half].reg; - - if (!pixman_op (reg, reg, hreg, pixman_region_union_o, TRUE, TRUE)) - { - ret = FALSE; - } - - if (hreg->extents.x1 < reg->extents.x1) - { - reg->extents.x1 = hreg->extents.x1; - } - - if (hreg->extents.y1 < reg->extents.y1) - { - reg->extents.y1 = hreg->extents.y1; - } - - if (hreg->extents.x2 > reg->extents.x2) - { - reg->extents.x2 = hreg->extents.x2; - } - - if (hreg->extents.y2 > reg->extents.y2) - { - reg->extents.y2 = hreg->extents.y2; - } - - FREE_DATA (hreg); - } - - num_ri -= half; - - if (!ret) - { - goto bail; - } - } - - *badreg = ri[0].reg; - - if (ri != stack_regions) - { - /* cppcheck-suppress autovarInvalidDeallocation */ - free (ri); - } - - GOOD (badreg); - return ret; - -bail: - for (i = 0; i < num_ri; i++) - { - FREE_DATA (&ri[i].reg); - } - - if (ri != stack_regions) - { - /* cppcheck-suppress autovarInvalidDeallocation */ - free (ri); - } - - return pixman_break (badreg); -} - /*====================================================================== * Region Subtraction *====================================================================*/ @@ -2167,447 +1615,6 @@ PREFIX (_subtract) (region_type_t *reg_d, * Region Inversion *====================================================================*/ -/*- - *----------------------------------------------------------------------- - * pixman_region_inverse -- - * Take a region and a box and return a region that is everything - * in the box but not in the region. The careful reader will note - * that this is the same as subtracting the region from the box... - * - * Results: - * TRUE. - * - * Side Effects: - * new_reg is overwritten. - * - *----------------------------------------------------------------------- - */ -PIXMAN_EXPORT pixman_bool_t -PREFIX (_inverse) (region_type_t *new_reg, /* Destination region */ - region_type_t *reg1, /* Region to invert */ - box_type_t *inv_rect) /* Bounding box for inversion */ -{ - region_type_t inv_reg; /* Quick and dirty region made from the - * bounding box */ - GOOD (reg1); - GOOD (new_reg); - - /* check for trivial rejects */ - if (PIXREGION_NIL (reg1) || !EXTENTCHECK (inv_rect, ®1->extents)) - { - if (PIXREGION_NAR (reg1)) - { - return pixman_break (new_reg); - } - - new_reg->extents = *inv_rect; - FREE_DATA (new_reg); - new_reg->data = (region_data_type_t *)NULL; - - return TRUE; - } - - /* Add those rectangles in region 1 that aren't in region 2, - * do yucky subtraction for overlaps, and - * just throw away rectangles in region 2 that aren't in region 1 - */ - inv_reg.extents = *inv_rect; - inv_reg.data = (region_data_type_t *)NULL; - if (!pixman_op (new_reg, &inv_reg, reg1, pixman_region_subtract_o, TRUE, FALSE)) - { - return FALSE; - } - - /* - * Can't alter new_reg's extents before we call pixman_op because - * it might be one of the source regions and pixman_op depends - * on the extents of those regions being unaltered. Besides, this - * way there's no checking against rectangles that will be nuked - * due to coalescing, so we have to examine fewer rectangles. - */ - pixman_set_extents (new_reg); - GOOD (new_reg); - return TRUE; -} - -/* In time O(log n), locate the first box whose y2 is greater than y. - * Return @end if no such box exists. - */ -static box_type_t * -find_box_for_y (box_type_t *begin, box_type_t *end, int y) -{ - box_type_t *mid; - - if (end == begin) - { - return end; - } - - if (end - begin == 1) - { - if (begin->y2 > y) - { - return begin; - } - else - { - return end; - } - } - - mid = begin + (end - begin) / 2; - if (mid->y2 > y) - { - /* If no box is found in [begin, mid], the function - * will return @mid, which is then known to be the - * correct answer. - */ - return find_box_for_y (begin, mid, y); - } - else - { - return find_box_for_y (mid, end, y); - } -} - -/* - * rect_in(region, rect) - * This routine takes a pointer to a region and a pointer to a box - * and determines if the box is outside/inside/partly inside the region. - * - * The idea is to travel through the list of rectangles trying to cover the - * passed box with them. Anytime a piece of the rectangle isn't covered - * by a band of rectangles, part_out is set TRUE. Any time a rectangle in - * the region covers part of the box, part_in is set TRUE. The process ends - * when either the box has been completely covered (we reached a band that - * doesn't overlap the box, part_in is TRUE and part_out is false), the - * box has been partially covered (part_in == part_out == TRUE -- because of - * the banding, the first time this is true we know the box is only - * partially in the region) or is outside the region (we reached a band - * that doesn't overlap the box at all and part_in is false) - */ -PIXMAN_EXPORT pixman_region_overlap_t -PREFIX (_contains_rectangle) (region_type_t *region, - box_type_t *prect) -{ - box_type_t *pbox; - box_type_t *pbox_end; - int part_in, part_out; - int numRects; - int x, y; - - GOOD (region); - - numRects = PIXREGION_NUMRECTS (region); - - /* useful optimization */ - if (!numRects || !EXTENTCHECK (®ion->extents, prect)) - { - return (PIXMAN_REGION_OUT); - } - - if (numRects == 1) - { - /* We know that it must be PIXMAN_REGION_IN or PIXMAN_REGION_PART */ - if (SUBSUMES (®ion->extents, prect)) - { - return (PIXMAN_REGION_IN); - } - else - { - return (PIXMAN_REGION_PART); - } - } - - part_out = FALSE; - part_in = FALSE; - - /* (x,y) starts at upper left of rect, moving to the right and down */ - x = prect->x1; - y = prect->y1; - - /* can stop when both part_out and part_in are TRUE, or we reach prect->y2 */ - for (pbox = PIXREGION_BOXPTR (region), pbox_end = pbox + numRects; - pbox != pbox_end; - pbox++) - { - /* getting up to speed or skipping remainder of band */ - if (pbox->y2 <= y) - { - if ((pbox = find_box_for_y (pbox, pbox_end, y)) == pbox_end) - { - break; - } - } - - if (pbox->y1 > y) - { - part_out = TRUE; /* missed part of rectangle above */ - if (part_in || (pbox->y1 >= prect->y2)) - { - break; - } - y = pbox->y1; /* x guaranteed to be == prect->x1 */ - } - - if (pbox->x2 <= x) - { - continue; /* not far enough over yet */ - } - - if (pbox->x1 > x) - { - part_out = TRUE; /* missed part of rectangle to left */ - if (part_in) - { - break; - } - } - - if (pbox->x1 < prect->x2) - { - part_in = TRUE; /* definitely overlap */ - if (part_out) - { - break; - } - } - - if (pbox->x2 >= prect->x2) - { - y = pbox->y2; /* finished with this band */ - if (y >= prect->y2) - { - break; - } - x = prect->x1; /* reset x out to left again */ - } - else - { - /* - * Because boxes in a band are maximal width, if the first box - * to overlap the rectangle doesn't completely cover it in that - * band, the rectangle must be partially out, since some of it - * will be uncovered in that band. part_in will have been set true - * by now... - */ - part_out = TRUE; - break; - } - } - - if (part_in) - { - if (y < prect->y2) - { - return PIXMAN_REGION_PART; - } - else - { - return PIXMAN_REGION_IN; - } - } - else - { - return PIXMAN_REGION_OUT; - } -} - -/* PREFIX(_translate) (region, x, y) - * translates in place - */ - -PIXMAN_EXPORT void -PREFIX (_translate) (region_type_t *region, int x, int y) -{ - overflow_int_t x1, x2, y1, y2; - int nbox; - box_type_t *pbox; - - GOOD (region); - region->extents.x1 = x1 = region->extents.x1 + x; - region->extents.y1 = y1 = region->extents.y1 + y; - region->extents.x2 = x2 = region->extents.x2 + x; - region->extents.y2 = y2 = region->extents.y2 + y; - - if (((x1 - PIXMAN_REGION_MIN) | (y1 - PIXMAN_REGION_MIN) | (PIXMAN_REGION_MAX - x2) | (PIXMAN_REGION_MAX - y2)) >= 0) - { - if (region->data && (nbox = region->data->numRects)) - { - for (pbox = PIXREGION_BOXPTR (region); nbox--; pbox++) - { - pbox->x1 += x; - pbox->y1 += y; - pbox->x2 += x; - pbox->y2 += y; - } - } - return; - } - - if (((x2 - PIXMAN_REGION_MIN) | (y2 - PIXMAN_REGION_MIN) | (PIXMAN_REGION_MAX - x1) | (PIXMAN_REGION_MAX - y1)) <= 0) - { - region->extents.x2 = region->extents.x1; - region->extents.y2 = region->extents.y1; - FREE_DATA (region); - region->data = pixman_region_empty_data; - return; - } - - if (x1 < PIXMAN_REGION_MIN) - { - region->extents.x1 = PIXMAN_REGION_MIN; - } - else if (x2 > PIXMAN_REGION_MAX) - { - region->extents.x2 = PIXMAN_REGION_MAX; - } - - if (y1 < PIXMAN_REGION_MIN) - { - region->extents.y1 = PIXMAN_REGION_MIN; - } - else if (y2 > PIXMAN_REGION_MAX) - { - region->extents.y2 = PIXMAN_REGION_MAX; - } - - if (region->data && (nbox = region->data->numRects)) - { - box_type_t *pbox_out; - - for (pbox_out = pbox = PIXREGION_BOXPTR (region); nbox--; pbox++) - { - pbox_out->x1 = x1 = pbox->x1 + x; - pbox_out->y1 = y1 = pbox->y1 + y; - pbox_out->x2 = x2 = pbox->x2 + x; - pbox_out->y2 = y2 = pbox->y2 + y; - - if (((x2 - PIXMAN_REGION_MIN) | (y2 - PIXMAN_REGION_MIN) | - (PIXMAN_REGION_MAX - x1) | (PIXMAN_REGION_MAX - y1)) <= 0) - { - region->data->numRects--; - continue; - } - - if (x1 < PIXMAN_REGION_MIN) - { - pbox_out->x1 = PIXMAN_REGION_MIN; - } - else if (x2 > PIXMAN_REGION_MAX) - { - pbox_out->x2 = PIXMAN_REGION_MAX; - } - - if (y1 < PIXMAN_REGION_MIN) - { - pbox_out->y1 = PIXMAN_REGION_MIN; - } - else if (y2 > PIXMAN_REGION_MAX) - { - pbox_out->y2 = PIXMAN_REGION_MAX; - } - - pbox_out++; - } - - if (pbox_out != pbox) - { - if (region->data->numRects == 1) - { - region->extents = *PIXREGION_BOXPTR (region); - FREE_DATA (region); - region->data = (region_data_type_t *)NULL; - } - else - { - pixman_set_extents (region); - } - } - } - - GOOD (region); -} - -PIXMAN_EXPORT void -PREFIX (_reset) (region_type_t *region, box_type_t *box) -{ - GOOD (region); - - critical_if_fail (GOOD_RECT (box)); - - region->extents = *box; - - FREE_DATA (region); - - region->data = NULL; -} - -PIXMAN_EXPORT void -PREFIX (_clear) (region_type_t *region) -{ - GOOD (region); - FREE_DATA (region); - - region->extents = *pixman_region_empty_box; - region->data = pixman_region_empty_data; -} - -/* box is "return" value */ -PIXMAN_EXPORT int -PREFIX (_contains_point) (region_type_t *region, - int x, int y, - box_type_t *box) -{ - box_type_t *pbox, *pbox_end; - int numRects; - - GOOD (region); - numRects = PIXREGION_NUMRECTS (region); - - if (!numRects || !INBOX (®ion->extents, x, y)) - { - return (FALSE); - } - - if (numRects == 1) - { - if (box) - { - *box = region->extents; - } - - return (TRUE); - } - - pbox = PIXREGION_BOXPTR (region); - pbox_end = pbox + numRects; - - pbox = find_box_for_y (pbox, pbox_end, y); - - for (; pbox != pbox_end; pbox++) - { - if ((y < pbox->y1) || (x < pbox->x1)) - { - break; /* missed it */ - } - - if (x >= pbox->x2) - { - continue; /* not there yet */ - } - - if (box) - { - *box = *pbox; - } - - return (TRUE); - } - - return (FALSE); -} - PIXMAN_EXPORT int PREFIX (_not_empty) (region_type_t *region) { @@ -2624,166 +1631,3 @@ PREFIX (_extents) (region_type_t *region) return (®ion->extents); } -/* - * Clip a list of scanlines to a region. The caller has allocated the - * space. FSorted is non-zero if the scanline origins are in ascending order. - * - * returns the number of new, clipped scanlines. - */ - -PIXMAN_EXPORT pixman_bool_t -PREFIX (_selfcheck) (region_type_t *reg) -{ - int i, numRects; - - if ((reg->extents.x1 > reg->extents.x2) || - (reg->extents.y1 > reg->extents.y2)) - { - return FALSE; - } - - numRects = PIXREGION_NUMRECTS (reg); - if (!numRects) - { - return ((reg->extents.x1 == reg->extents.x2) && - (reg->extents.y1 == reg->extents.y2) && - (reg->data->size || (reg->data == pixman_region_empty_data))); - } - else if (numRects == 1) - { - return (!reg->data); - } - else - { - box_type_t *pbox_p, *pbox_n; - box_type_t box; - - pbox_p = PIXREGION_RECTS (reg); - box = *pbox_p; - box.y2 = pbox_p[numRects - 1].y2; - pbox_n = pbox_p + 1; - - for (i = numRects; --i > 0; pbox_p++, pbox_n++) - { - if ((pbox_n->x1 >= pbox_n->x2) || - (pbox_n->y1 >= pbox_n->y2)) - { - return FALSE; - } - - if (pbox_n->x1 < box.x1) - { - box.x1 = pbox_n->x1; - } - - if (pbox_n->x2 > box.x2) - { - box.x2 = pbox_n->x2; - } - - if ((pbox_n->y1 < pbox_p->y1) || - ((pbox_n->y1 == pbox_p->y1) && - ((pbox_n->x1 < pbox_p->x2) || (pbox_n->y2 != pbox_p->y2)))) - { - return FALSE; - } - } - - return ((box.x1 == reg->extents.x1) && - (box.x2 == reg->extents.x2) && - (box.y1 == reg->extents.y1) && - (box.y2 == reg->extents.y2)); - } -} - -PIXMAN_EXPORT pixman_bool_t -PREFIX (_init_rects) (region_type_t *region, - const box_type_t *boxes, int count) -{ - box_type_t *rects; - int displacement; - int i; - - /* if it's 1, then we just want to set the extents, so call - * the existing method. */ - if (count == 1) - { - PREFIX (_init_rect) (region, - boxes[0].x1, - boxes[0].y1, - boxes[0].x2 - boxes[0].x1, - boxes[0].y2 - boxes[0].y1); - return TRUE; - } - - PREFIX (_init) (region); - - /* if it's 0, don't call pixman_rect_alloc -- 0 rectangles is - * a special case, and causing pixman_rect_alloc would cause - * us to leak memory (because the 0-rect case should be the - * static pixman_region_empty_data data). - */ - if (count == 0) - { - return TRUE; - } - - if (!pixman_rect_alloc (region, count)) - { - return FALSE; - } - - rects = PIXREGION_RECTS (region); - - /* Copy in the rects */ - memcpy (rects, boxes, sizeof(box_type_t) * count); - region->data->numRects = count; - - /* Eliminate empty and malformed rectangles */ - displacement = 0; - - for (i = 0; i < count; ++i) - { - box_type_t *box = &rects[i]; - - if (box->x1 >= box->x2 || box->y1 >= box->y2) - { - displacement++; - } - else if (displacement) - { - rects[i - displacement] = rects[i]; - } - } - - region->data->numRects -= displacement; - - /* If eliminating empty rectangles caused there - * to be only 0 or 1 rectangles, deal with that. - */ - if (region->data->numRects == 0) - { - FREE_DATA (region); - PREFIX (_init) (region); - - return TRUE; - } - - if (region->data->numRects == 1) - { - region->extents = rects[0]; - - FREE_DATA (region); - region->data = NULL; - - GOOD (region); - - return TRUE; - } - - /* Validate */ - region->extents.x1 = region->extents.x2 = 0; - - return validate (region); -} - diff --git a/common/pixman-region16.c b/common/pixman-region16.c index 76f0903b..c30b4d59 100644 --- a/common/pixman-region16.c +++ b/common/pixman-region16.c @@ -68,7 +68,7 @@ typedef signed int overflow_int_t; #define critical_if_fail(expr) -int _pixman_log_error(const char *func, const char *format, ...) +static int _pixman_log_error(const char *func, const char *format, ...) { return 0; } diff --git a/common/ssl_calls.c b/common/ssl_calls.c index c53afde5..70d2d7c8 100644 --- a/common/ssl_calls.c +++ b/common/ssl_calls.c @@ -1525,7 +1525,7 @@ ssl_get_protocols_from_string(const char *str, long *ssl_protocols) /*****************************************************************************/ const char -*get_openssl_version() +*get_openssl_version(void) { #if OPENSSL_VERSION_NUMBER < 0x10100000L return SSLeay_version(SSLEAY_VERSION); diff --git a/common/ssl_calls.h b/common/ssl_calls.h index 01b67406..5b9c1e7f 100644 --- a/common/ssl_calls.h +++ b/common/ssl_calls.h @@ -108,7 +108,7 @@ ssl_get_cipher_name(const struct ssl_tls *ssl); int ssl_get_protocols_from_string(const char *str, long *ssl_protocols); const char * -get_openssl_version(); +get_openssl_version(void); tintptr ssl_get_rwo(const struct ssl_tls *ssl); diff --git a/common/trans.c b/common/trans.c index b0358c3b..780b4c52 100644 --- a/common/trans.c +++ b/common/trans.c @@ -38,7 +38,7 @@ #define CONNECT_DELAY_ON_FAIL_MS 2000 /*****************************************************************************/ -int +static int trans_tls_recv(struct trans *self, char *ptr, int len) { if (self->tls == NULL) @@ -49,7 +49,7 @@ trans_tls_recv(struct trans *self, char *ptr, int len) } /*****************************************************************************/ -int +static int trans_tls_send(struct trans *self, const char *data, int len) { if (self->tls == NULL) @@ -60,7 +60,7 @@ trans_tls_send(struct trans *self, const char *data, int len) } /*****************************************************************************/ -int +static int trans_tls_can_recv(struct trans *self, int sck, int millis) { if (self->tls == NULL) @@ -71,21 +71,21 @@ trans_tls_can_recv(struct trans *self, int sck, int millis) } /*****************************************************************************/ -int +static int trans_tcp_recv(struct trans *self, char *ptr, int len) { return g_tcp_recv(self->sck, ptr, len, 0); } /*****************************************************************************/ -int +static int trans_tcp_send(struct trans *self, const char *data, int len) { return g_tcp_send(self->sck, data, len, 0); } /*****************************************************************************/ -int +static int trans_tcp_can_recv(struct trans *self, int sck, int millis) { return g_sck_can_recv(sck, millis); @@ -235,7 +235,7 @@ trans_get_wait_objs_rw(struct trans *self, tbus *robjs, int *rcount, } /*****************************************************************************/ -int +static int trans_send_waiting(struct trans *self, int block) { struct stream *temp_s; diff --git a/configure.ac b/configure.ac index 3a470ab3..11b2b85e 100644 --- a/configure.ac +++ b/configure.ac @@ -206,6 +206,7 @@ AX_GCC_FUNC_ATTRIBUTE([format]) AX_TYPE_SOCKLEN_T AX_CFLAGS_WARN_ALL AX_APPEND_COMPILE_FLAGS([-Wwrite-strings]) +AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes], ,[-Werror]) AM_COND_IF([LINUX], [AX_APPEND_COMPILE_FLAGS([-Werror])]) # bsd has warnings that have not been fixed yet diff --git a/fontutils/fv1.c b/fontutils/fv1.c index a532c966..72826a12 100644 --- a/fontutils/fv1.c +++ b/fontutils/fv1.c @@ -231,7 +231,7 @@ fv1_file_free(struct fv1_file *fv1) } /*****************************************************************************/ -int +static int write_stream(int fd, struct stream *s) { const char *p = s->data; diff --git a/libxrdp/xrdp_caps.c b/libxrdp/xrdp_caps.c index dcb754e2..7570968a 100644 --- a/libxrdp/xrdp_caps.c +++ b/libxrdp/xrdp_caps.c @@ -427,7 +427,7 @@ xrdp_caps_process_input(struct xrdp_rdp *self, struct stream *s, /*****************************************************************************/ /* get the type of client brush cache */ -int +static int xrdp_caps_process_brushcache(struct xrdp_rdp *self, struct stream *s, int len) { @@ -471,7 +471,7 @@ xrdp_caps_process_glyphcache(struct xrdp_rdp *self, struct stream *s, } /*****************************************************************************/ -int +static int xrdp_caps_process_offscreen_bmpcache(struct xrdp_rdp *self, struct stream *s, int len) { @@ -497,7 +497,7 @@ xrdp_caps_process_offscreen_bmpcache(struct xrdp_rdp *self, struct stream *s, } /*****************************************************************************/ -int +static int xrdp_caps_process_rail(struct xrdp_rdp *self, struct stream *s, int len) { int i32; diff --git a/libxrdp/xrdp_fastpath.c b/libxrdp/xrdp_fastpath.c index 682c6015..325bee61 100644 --- a/libxrdp/xrdp_fastpath.c +++ b/libxrdp/xrdp_fastpath.c @@ -49,14 +49,6 @@ xrdp_fastpath_delete(struct xrdp_fastpath *self) g_free(self); } -/*****************************************************************************/ -/* returns error */ -int -xrdp_fastpath_reset(struct xrdp_fastpath *self) -{ - return 0; -} - /*****************************************************************************/ int xrdp_fastpath_recv(struct xrdp_fastpath *self, struct stream *s) diff --git a/libxrdp/xrdp_mcs.c b/libxrdp/xrdp_mcs.c index 62221159..10e32d68 100644 --- a/libxrdp/xrdp_mcs.c +++ b/libxrdp/xrdp_mcs.c @@ -878,7 +878,7 @@ xrdp_mcs_out_domain_params(struct xrdp_mcs *self, struct stream *s, * with ConnectGCCPDU, ConferenceCreateResponse, * and [MS-RDPBCGR] Server Data Blocks as user data. */ -int +static int xrdp_mcs_out_gcc_data(struct xrdp_sec *self) { struct stream *s; @@ -1490,7 +1490,7 @@ xrdp_mcs_send(struct xrdp_mcs *self, struct stream *s, int chan) * Internal help function to close the socket * @param self */ -void +static void close_rdp_socket(struct xrdp_mcs *self) { if (self->iso_layer != 0) diff --git a/libxrdp/xrdp_orders_rail.c b/libxrdp/xrdp_orders_rail.c index daac1455..1d3ad586 100644 --- a/libxrdp/xrdp_orders_rail.c +++ b/libxrdp/xrdp_orders_rail.c @@ -20,6 +20,7 @@ #include #endif +#include "xrdp_orders_rail.h" #include "libxrdp.h" #include "ms-rdpegdi.h" #include "xrdp_rail.h" diff --git a/libxrdp/xrdp_sec.c b/libxrdp/xrdp_sec.c index f2d1a4d4..71c9b9ee 100644 --- a/libxrdp/xrdp_sec.c +++ b/libxrdp/xrdp_sec.c @@ -2511,7 +2511,7 @@ xrdp_sec_process_mcs_data_monitors(struct xrdp_sec *self, struct stream *s) /*****************************************************************************/ /* Process a [MS-RDPBCGR] TS_UD_CS_MONITOR_EX message. reads the client monitor's extended data */ -int +static int xrdp_sec_process_mcs_data_monitors_ex(struct xrdp_sec *self, struct stream *s) { int flags; @@ -2755,7 +2755,7 @@ xrdp_sec_in_mcs_data(struct xrdp_sec *self) /*****************************************************************************/ /* returns error */ -int +static int xrdp_sec_init_rdp_security(struct xrdp_sec *self) { switch (self->rdp_layer->client_info.crypt_level) diff --git a/mc/mc.c b/mc/mc.c index e1efc4dd..1b018ef1 100644 --- a/mc/mc.c +++ b/mc/mc.c @@ -27,7 +27,7 @@ /*****************************************************************************/ /* return error */ -int +static int lib_mod_start(struct mod *mod, int w, int h, int bpp) { LOG_DEVEL(LOG_LEVEL_TRACE, "in lib_mod_start"); @@ -40,7 +40,7 @@ lib_mod_start(struct mod *mod, int w, int h, int bpp) /******************************************************************************/ /* return error */ -int +static int lib_mod_connect(struct mod *mod) { LOG_DEVEL(LOG_LEVEL_TRACE, "in lib_mod_connect"); @@ -50,7 +50,7 @@ lib_mod_connect(struct mod *mod) /******************************************************************************/ /* return error */ -int +static int lib_mod_event(struct mod *mod, int msg, long param1, long param2, long param3, long param4) { @@ -61,7 +61,7 @@ lib_mod_event(struct mod *mod, int msg, long param1, long param2, /******************************************************************************/ /* return error */ -int +static int lib_mod_signal(struct mod *mod) { LOG_DEVEL(LOG_LEVEL_TRACE, "in lib_mod_signal"); @@ -71,7 +71,7 @@ lib_mod_signal(struct mod *mod) /******************************************************************************/ /* return error */ -int +static int lib_mod_end(struct mod *mod) { return 0; @@ -79,7 +79,7 @@ lib_mod_end(struct mod *mod) /******************************************************************************/ /* return error */ -int +static int lib_mod_set_param(struct mod *mod, const char *name, const char *value) { return 0; diff --git a/neutrinordp/xrdp-color.c b/neutrinordp/xrdp-color.c index b0f94c7c..b93bebb3 100644 --- a/neutrinordp/xrdp-color.c +++ b/neutrinordp/xrdp-color.c @@ -27,6 +27,8 @@ #include "os_calls.h" #include "string_calls.h" +#include "xrdp-color.h" + char * convert_bitmap(int in_bpp, int out_bpp, char *bmpdata, int width, int height, int *palette) diff --git a/neutrinordp/xrdp-neutrinordp.c b/neutrinordp/xrdp-neutrinordp.c index 6574c3fa..b33bd042 100644 --- a/neutrinordp/xrdp-neutrinordp.c +++ b/neutrinordp/xrdp-neutrinordp.c @@ -2041,7 +2041,7 @@ lfreerdp_pre_connect(freerdp *instance) } /*****************************************************************************/ -void +static void lrail_WindowCreate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo, WINDOW_STATE_ORDER *window_state) { @@ -2122,7 +2122,7 @@ lrail_WindowCreate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo, } /*****************************************************************************/ -void +static void lrail_WindowUpdate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo, WINDOW_STATE_ORDER *window_state) { @@ -2131,7 +2131,7 @@ lrail_WindowUpdate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo, } /*****************************************************************************/ -void +static void lrail_WindowDelete(rdpContext *context, WINDOW_ORDER_INFO *orderInfo) { struct mod *mod; @@ -2142,7 +2142,7 @@ lrail_WindowDelete(rdpContext *context, WINDOW_ORDER_INFO *orderInfo) } /*****************************************************************************/ -void +static void lrail_WindowIcon(rdpContext *context, WINDOW_ORDER_INFO *orderInfo, WINDOW_ICON_ORDER *window_icon) { @@ -2168,7 +2168,7 @@ lrail_WindowIcon(rdpContext *context, WINDOW_ORDER_INFO *orderInfo, } /*****************************************************************************/ -void +static void lrail_WindowCachedIcon(rdpContext *context, WINDOW_ORDER_INFO *orderInfo, WINDOW_CACHED_ICON_ORDER *window_cached_icon) { @@ -2183,7 +2183,7 @@ lrail_WindowCachedIcon(rdpContext *context, WINDOW_ORDER_INFO *orderInfo, } /*****************************************************************************/ -void +static void lrail_NotifyIconCreate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo, NOTIFY_ICON_STATE_ORDER *notify_icon_state) { @@ -2240,7 +2240,7 @@ lrail_NotifyIconCreate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo, } /*****************************************************************************/ -void +static void lrail_NotifyIconUpdate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo, NOTIFY_ICON_STATE_ORDER *notify_icon_state) { @@ -2249,7 +2249,7 @@ lrail_NotifyIconUpdate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo, } /*****************************************************************************/ -void +static void lrail_NotifyIconDelete(rdpContext *context, WINDOW_ORDER_INFO *orderInfo) { struct mod *mod; @@ -2261,7 +2261,7 @@ lrail_NotifyIconDelete(rdpContext *context, WINDOW_ORDER_INFO *orderInfo) } /*****************************************************************************/ -void +static void lrail_MonitoredDesktop(rdpContext *context, WINDOW_ORDER_INFO *orderInfo, MONITORED_DESKTOP_ORDER *monitored_desktop) { @@ -2293,7 +2293,7 @@ lrail_MonitoredDesktop(rdpContext *context, WINDOW_ORDER_INFO *orderInfo, } /*****************************************************************************/ -void +static void lrail_NonMonitoredDesktop(rdpContext *context, WINDOW_ORDER_INFO *orderInfo) { struct mod *mod; diff --git a/sesman/chansrv/audin.c b/sesman/chansrv/audin.c index 951cf88a..4574a5b9 100644 --- a/sesman/chansrv/audin.c +++ b/sesman/chansrv/audin.c @@ -32,6 +32,7 @@ #include "log.h" #include "xrdp_constants.h" #include "fifo.h" +#include "audin.h" #define MSG_SNDIN_VERSION 1 #define MSG_SNDIN_FORMATS 2 diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index 80f0a231..d3a32165 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -894,7 +894,7 @@ process_message(void) /*****************************************************************************/ /* returns error */ -int +static int my_trans_data_in(struct trans *trans) { struct stream *s = (struct stream *)NULL; @@ -938,7 +938,7 @@ my_trans_data_in(struct trans *trans) } /*****************************************************************************/ -struct trans * +static struct trans * get_api_trans_from_chan_id(int chan_id) { return g_drdynvcs[chan_id].xrdp_api_trans; @@ -1038,7 +1038,7 @@ my_api_data(int chan_id, char *data, int bytes) * called when WTSVirtualChannelWrite() is invoked in xrdpapi.c * ******************************************************************************/ -int +static int my_api_trans_data_in(struct trans *trans) { struct stream *s; @@ -1172,7 +1172,7 @@ my_api_trans_data_in(struct trans *trans) } /*****************************************************************************/ -int +static int my_trans_conn_in(struct trans *trans, struct trans *new_trans) { if (trans == 0) @@ -1209,7 +1209,7 @@ my_trans_conn_in(struct trans *trans, struct trans *new_trans) * called when WTSVirtualChannelOpenEx is invoked in xrdpapi.c * ******************************************************************************/ -int +static int my_api_trans_conn_in(struct trans *trans, struct trans *new_trans) { struct xrdp_api_data *ad; @@ -1377,7 +1377,7 @@ api_con_trans_list_remove_all(void) } /*****************************************************************************/ -THREAD_RV THREAD_CC +static THREAD_RV THREAD_CC channel_thread_loop(void *in_val) { tbus objs[32]; @@ -1538,7 +1538,7 @@ child_signal_handler(void) } /*****************************************************************************/ -void +static void segfault_signal_handler(int sig) { LOG_DEVEL(LOG_LEVEL_ERROR, "segfault_signal_handler: entered......."); diff --git a/sesman/chansrv/chansrv_fuse.c b/sesman/chansrv/chansrv_fuse.c index c89af18b..9692b46f 100644 --- a/sesman/chansrv/chansrv_fuse.c +++ b/sesman/chansrv/chansrv_fuse.c @@ -413,21 +413,21 @@ static unsigned int format_user_info(char *dest, unsigned int len, const char *format); /*****************************************************************************/ -int +static int load_fuse_config(void) { return 0; } /*****************************************************************************/ -XFUSE_HANDLE * +static XFUSE_HANDLE * xfuse_handle_create() { return g_new0(XFUSE_HANDLE, 1); } /*****************************************************************************/ -void +static void xfuse_handle_delete(XFUSE_HANDLE *self) { if (self == NULL) @@ -443,14 +443,14 @@ xfuse_handle_delete(XFUSE_HANDLE *self) } /*****************************************************************************/ -uint64_t +static uint64_t xfuse_handle_to_fuse_handle(XFUSE_HANDLE *self) { return (uint64_t) (tintptr) self; } /*****************************************************************************/ -XFUSE_HANDLE * +static XFUSE_HANDLE * xfuse_handle_from_fuse_handle(uint64_t handle) { return (XFUSE_HANDLE *) (tintptr) handle; diff --git a/sesman/chansrv/devredir.c b/sesman/chansrv/devredir.c index 1a1df6da..c4edbdb2 100644 --- a/sesman/chansrv/devredir.c +++ b/sesman/chansrv/devredir.c @@ -191,10 +191,11 @@ devredir_deinit(void) /*****************************************************************************/ +#ifdef USE_DEVEL_LOGGING /* * Convert a COMPLETION_TYPE to a string */ -const char *completion_type_to_str(enum COMPLETION_TYPE cid) +static const char *completion_type_to_str(enum COMPLETION_TYPE cid) { return (cid == CID_CREATE_DIR_REQ) ? "CID_CREATE_DIR_REQ" : @@ -213,6 +214,7 @@ const char *completion_type_to_str(enum COMPLETION_TYPE cid) (cid == CID_SETATTR) ? "CID_SETATTR" : /* default */ ""; }; +#endif /*****************************************************************************/ diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index 0a1b78e0..40d47dc1 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -360,7 +360,7 @@ rail_deinit(void) return 0; } -int +static int rail_startup(void) { int dummy; @@ -565,7 +565,7 @@ rail_close_window(int window_id) } /*****************************************************************************/ -void +static void my_timeout(void *data) { LOG_DEVEL(LOG_LEVEL_DEBUG, "my_timeout: g_got_focus %d", g_got_focus); @@ -1327,7 +1327,7 @@ rail_destroy_window(Window window_id) } /*****************************************************************************/ -static int +int rail_show_window(Window window_id, int show_state) { int flags; @@ -1510,7 +1510,7 @@ rail_create_window(Window window_id, Window owner_id) /*****************************************************************************/ /* returns 0, event handled, 1 unhandled */ -int +static int rail_configure_request_window(XConfigureRequestEvent *config) { int num_window_rects = 1; @@ -1714,8 +1714,9 @@ rail_configure_request_window(XConfigureRequestEvent *config) } /*****************************************************************************/ +#if 0 /* returns 0, event handled, 1 unhandled */ -int +static int rail_configure_window(XConfigureEvent *config) { int num_window_rects = 1; @@ -1796,6 +1797,7 @@ rail_configure_window(XConfigureEvent *config) free_stream(s); return 0; } +#endif /*****************************************************************************/ static int diff --git a/sesman/chansrv/smartcard_pcsc.c b/sesman/chansrv/smartcard_pcsc.c index cfce6dbb..3fb78b1f 100644 --- a/sesman/chansrv/smartcard_pcsc.c +++ b/sesman/chansrv/smartcard_pcsc.c @@ -51,6 +51,7 @@ #include "trans.h" #include "chansrv.h" #include "list.h" +#include "smartcard_pcsc.h" #if PCSC_STANDIN @@ -147,7 +148,7 @@ get_uds_client_by_id(int uds_client_id) } /*****************************************************************************/ -struct pcsc_context * +static struct pcsc_context * get_pcsc_context_by_app_context(struct pcsc_uds_client *uds_client, tui32 app_context) { @@ -175,7 +176,7 @@ get_pcsc_context_by_app_context(struct pcsc_uds_client *uds_client, } /*****************************************************************************/ -struct pcsc_card * +static struct pcsc_card * get_pcsc_card_by_app_card(struct pcsc_uds_client *uds_client, tui32 app_card, struct pcsc_context **acontext) { @@ -441,7 +442,7 @@ scard_pcsc_check_wait_objs(void) /*****************************************************************************/ /* returns error */ -int +static int scard_process_establish_context(struct trans *con, struct stream *in_s) { int dwScope; @@ -525,7 +526,7 @@ scard_function_establish_context_return(void *user_data, /*****************************************************************************/ /* returns error */ -int +static int scard_process_release_context(struct trans *con, struct stream *in_s) { int hContext; @@ -601,7 +602,7 @@ struct pcsc_list_readers /*****************************************************************************/ /* returns error */ -int +static int scard_process_list_readers(struct trans *con, struct stream *in_s) { int hContext; @@ -662,7 +663,7 @@ scard_process_list_readers(struct trans *con, struct stream *in_s) * The string is guaranteed to have at least the returned number of NULL * characters in it */ -unsigned int +static unsigned int count_multistring_elements(const char *str, unsigned int len) { unsigned int rv = 0; @@ -822,7 +823,7 @@ scard_function_list_readers_return(void *user_data, /*****************************************************************************/ /* returns error */ -int +static int scard_process_connect(struct trans *con, struct stream *in_s) { int hContext; @@ -925,7 +926,7 @@ scard_function_connect_return(void *user_data, /*****************************************************************************/ /* returns error */ -int +static int scard_process_disconnect(struct trans *con, struct stream *in_s) { int hCard; @@ -995,7 +996,7 @@ scard_function_disconnect_return(void *user_data, /*****************************************************************************/ /* returns error */ -int +static int scard_process_begin_transaction(struct trans *con, struct stream *in_s) { int hCard; @@ -1065,7 +1066,7 @@ scard_function_begin_transaction_return(void *user_data, /*****************************************************************************/ /* returns error */ -int +static int scard_process_end_transaction(struct trans *con, struct stream *in_s) { int hCard; @@ -1157,7 +1158,7 @@ struct pcsc_transmit /*****************************************************************************/ /* returns error */ -int +static int scard_process_transmit(struct trans *con, struct stream *in_s) { int hCard; @@ -1298,7 +1299,7 @@ scard_function_transmit_return(void *user_data, /*****************************************************************************/ /* returns error */ -int +static int scard_process_control(struct trans *con, struct stream *in_s) { int hCard; @@ -1400,7 +1401,7 @@ struct pcsc_status /*****************************************************************************/ /* returns error */ -int +static int scard_process_status(struct trans *con, struct stream *in_s) { int hCard; @@ -1588,7 +1589,7 @@ scard_function_status_return(void *user_data, /*****************************************************************************/ /* returns error */ -int +static int scard_process_get_status_change(struct trans *con, struct stream *in_s) { int index; @@ -1725,7 +1726,7 @@ scard_function_get_status_change_return(void *user_data, /*****************************************************************************/ /* returns error */ -int +static int scard_process_cancel(struct trans *con, struct stream *in_s) { int hContext; @@ -1811,7 +1812,7 @@ int scard_function_reconnect_return(void *user_data, /*****************************************************************************/ /* returns error */ -int +static int scard_process_msg(struct trans *con, struct stream *in_s, int command) { int rv; @@ -1906,7 +1907,7 @@ scard_process_msg(struct trans *con, struct stream *in_s, int command) /*****************************************************************************/ /* returns error */ -int +static int my_pcsc_trans_data_in(struct trans *trans) { struct stream *s; @@ -1933,7 +1934,7 @@ my_pcsc_trans_data_in(struct trans *trans) /*****************************************************************************/ /* got a new connection from libpcsclite */ -int +static int my_pcsc_trans_conn_in(struct trans *trans, struct trans *new_trans) { struct pcsc_uds_client *uds_client; diff --git a/sesman/sesexec/session.c b/sesman/sesexec/session.c index f9c40820..11ec979d 100644 --- a/sesman/sesexec/session.c +++ b/sesman/sesexec/session.c @@ -155,7 +155,7 @@ session_data_free(struct session_data *session_data) * @param len the allocated len for outstr * @return */ -char * +static char * dumpItemsToString(struct list *self, char *outstr, int len) { int index; @@ -557,7 +557,7 @@ fork_child( } /******************************************************************************/ -enum scp_screate_status +static enum scp_screate_status session_start_wrapped(struct login_info *login_info, const struct session_parameters *s, struct session_data *sd) diff --git a/sesman/sesexec/xauth.c b/sesman/sesexec/xauth.c index a7e788bf..d2a7c4b7 100644 --- a/sesman/sesexec/xauth.c +++ b/sesman/sesexec/xauth.c @@ -28,6 +28,7 @@ #endif #include +#include "xauth.h" #include "log.h" #include "os_calls.h" #include "string_calls.h" diff --git a/sesman/tools/tools_common.c b/sesman/tools/tools_common.c index 3dd82c4a..674ba69e 100644 --- a/sesman/tools/tools_common.c +++ b/sesman/tools/tools_common.c @@ -29,6 +29,7 @@ #include "config_ac.h" #endif +#include "tools_common.h" #include "trans.h" #include "os_calls.h" #include "scp.h" diff --git a/tests/common/test_list_calls.c b/tests/common/test_list_calls.c index 0082b4e9..63d83966 100644 --- a/tests/common/test_list_calls.c +++ b/tests/common/test_list_calls.c @@ -147,10 +147,6 @@ START_TEST(test_list__simple_strdup_multi) } END_TEST -int -split_string_append_fragment(const char **start, const char *end, - struct list *list); - START_TEST(test_list__append_fragment) { struct list *l = list_create(); diff --git a/tests/libxrdp/test_xrdp_sec_process_mcs_data_monitors.c b/tests/libxrdp/test_xrdp_sec_process_mcs_data_monitors.c index 64cda1eb..27d83422 100644 --- a/tests/libxrdp/test_xrdp_sec_process_mcs_data_monitors.c +++ b/tests/libxrdp/test_xrdp_sec_process_mcs_data_monitors.c @@ -11,7 +11,7 @@ struct xrdp_sec *sec_layer; struct xrdp_rdp *rdp_layer; struct xrdp_session *session; -void setup(void) +static void setup(void) { rdp_layer = (struct xrdp_rdp *)g_malloc(sizeof(struct xrdp_rdp), 1); session = (struct xrdp_session *)g_malloc(sizeof(struct xrdp_session), 1); @@ -22,7 +22,7 @@ void setup(void) sec_layer->rdp_layer = rdp_layer; } -void teardown(void) +static void teardown(void) { g_free(sec_layer); g_free(session); diff --git a/tests/memtest/libmem.c b/tests/memtest/libmem.c index 2aa2e04d..960eadc3 100644 --- a/tests/memtest/libmem.c +++ b/tests/memtest/libmem.c @@ -7,6 +7,7 @@ #include #include +#include "libmem.h" #include "log.h" #define ALIGN_BY 32 diff --git a/tests/xrdp/test_bitmap_load.c b/tests/xrdp/test_bitmap_load.c index 885da025..f0fa163c 100644 --- a/tests/xrdp/test_bitmap_load.c +++ b/tests/xrdp/test_bitmap_load.c @@ -48,11 +48,11 @@ static int WHITE = COLOR24RGB(255, 255, 255); /* Time to allow some large bitmap test suites to run on slower platforms */ #define LARGE_BM_TEST_SUITE_TIMEOUT 10 -void setup(void) +static void setup(void) { } -void teardown(void) +static void teardown(void) { } diff --git a/tests/xrdp/test_xrdp_region.c b/tests/xrdp/test_xrdp_region.c index 12418932..8756e09b 100644 --- a/tests/xrdp/test_xrdp_region.c +++ b/tests/xrdp/test_xrdp_region.c @@ -61,6 +61,8 @@ static pixman_box16_t test_box = 0, 0, 100, 100 }; +// cmocka requires this to be externally linkable +extern pixman_box16_t *__wrap_pixman_region_extents(pixman_region16_t *region); pixman_box16_t *__wrap_pixman_region_extents(pixman_region16_t *region) { check_expected_ptr(region); @@ -107,6 +109,8 @@ static void test_xrdp_region_get_bounds__happy_path(void **state) g_free(rect); } +// cmocka requires this to be externally linkable +extern pixman_bool_t __wrap_pixman_region_not_empty(pixman_region16_t *region); pixman_bool_t __wrap_pixman_region_not_empty(pixman_region16_t *region) { check_expected_ptr(region); diff --git a/tools/devel/tcp_proxy/main.c b/tools/devel/tcp_proxy/main.c index 66dd9f31..137a64ee 100644 --- a/tools/devel/tcp_proxy/main.c +++ b/tools/devel/tcp_proxy/main.c @@ -299,14 +299,14 @@ usage(void) /*****************************************************************************/ -void +static void proxy_shutdown(int sig) { LOG(LOG_LEVEL_INFO, "shutting down"); g_terminated = 1; } -void +static void clear_counters(int sig) { LOG(LOG_LEVEL_DEBUG, "cleared counters at: local_io_count: %d remote_io_count: %d", diff --git a/vnc/vnc.c b/vnc/vnc.c index ce53fbfc..09de00d2 100644 --- a/vnc/vnc.c +++ b/vnc/vnc.c @@ -444,7 +444,7 @@ resize_server_to_client_layout(struct vnc *v) } /*****************************************************************************/ -int +static int lib_mod_event(struct vnc *v, int msg, long param1, long param2, long param3, long param4) { @@ -619,7 +619,7 @@ lib_mod_event(struct vnc *v, int msg, long param1, long param2, } //****************************************************************************** -int +static int get_pixel_safe(char *data, int x, int y, int width, int height, int bpp) { int start = 0; @@ -688,7 +688,7 @@ get_pixel_safe(char *data, int x, int y, int width, int height, int bpp) } /******************************************************************************/ -void +static void set_pixel_safe(char *data, int x, int y, int width, int height, int bpp, int pixel) { @@ -747,7 +747,7 @@ set_pixel_safe(char *data, int x, int y, int width, int height, int bpp, } /******************************************************************************/ -int +static int split_color(int pixel, int *r, int *g, int *b, int bpp, int *palette) { if (bpp == 8) @@ -786,7 +786,7 @@ split_color(int pixel, int *r, int *g, int *b, int bpp, int *palette) } /******************************************************************************/ -int +static int make_color(int r, int g, int b, int bpp) { if (bpp == 24) @@ -1229,7 +1229,7 @@ lib_framebuffer_waiting_for_resize_confirm(struct vnc *v) } /******************************************************************************/ -int +static int lib_framebuffer_update(struct vnc *v) { char *d1; @@ -1249,9 +1249,9 @@ lib_framebuffer_update(struct vnc *v) int srcy; unsigned int encoding; int pixel; - int r; - int g; - int b; + int r = 0; + int g = 0; + int b = 0; int error; int need_size; struct stream *s; @@ -1418,7 +1418,7 @@ lib_framebuffer_update(struct vnc *v) } /******************************************************************************/ -int +static int lib_palette_update(struct vnc *v) { struct stream *s; @@ -1474,7 +1474,7 @@ lib_palette_update(struct vnc *v) } /******************************************************************************/ -int +static int lib_bell_trigger(struct vnc *v) { int error; @@ -1484,7 +1484,7 @@ lib_bell_trigger(struct vnc *v) } /******************************************************************************/ -int +static int lib_mod_signal(struct vnc *v) { return 0; @@ -1543,7 +1543,7 @@ lib_mod_process_message(struct vnc *v, struct stream *s) } /******************************************************************************/ -int +static int lib_mod_start(struct vnc *v, int w, int h, int bpp) { v->server_begin_update(v); @@ -1591,7 +1591,7 @@ lib_data_in(struct trans *trans) /* return error */ -int +static int lib_mod_connect(struct vnc *v) { char cursor_data[32 * (32 * 3)]; @@ -2001,7 +2001,7 @@ lib_mod_connect(struct vnc *v) } /******************************************************************************/ -int +static int lib_mod_end(struct vnc *v) { if (v->vnc_desktop != 0) @@ -2052,7 +2052,7 @@ init_client_layout(struct vnc *v, } /******************************************************************************/ -int +static int lib_mod_set_param(struct vnc *v, const char *name, const char *value) { if (g_strcasecmp(name, "username") == 0) @@ -2111,7 +2111,7 @@ lib_mod_set_param(struct vnc *v, const char *name, const char *value) /******************************************************************************/ /* return error */ -int +static int lib_mod_get_wait_objs(struct vnc *v, tbus *read_objs, int *rcount, tbus *write_objs, int *wcount, int *timeout) { @@ -2131,7 +2131,7 @@ lib_mod_get_wait_objs(struct vnc *v, tbus *read_objs, int *rcount, /******************************************************************************/ /* return error */ -int +static int lib_mod_check_wait_objs(struct vnc *v) { int rv; @@ -2153,7 +2153,7 @@ lib_mod_check_wait_objs(struct vnc *v) /******************************************************************************/ /* return error */ -int +static int lib_mod_frame_ack(struct vnc *v, int flags, int frame_id) { return 0; @@ -2161,7 +2161,7 @@ lib_mod_frame_ack(struct vnc *v, int flags, int frame_id) /******************************************************************************/ /* return error */ -int +static int lib_mod_suppress_output(struct vnc *v, int suppress, int left, int top, int right, int bottom) { @@ -2189,7 +2189,7 @@ lib_mod_suppress_output(struct vnc *v, int suppress, /******************************************************************************/ /* return error */ -int +static int lib_mod_server_version_message(struct vnc *v) { return 0; @@ -2197,7 +2197,7 @@ lib_mod_server_version_message(struct vnc *v) /******************************************************************************/ /* return error */ -int +static int lib_mod_server_monitor_resize(struct vnc *v, int width, int height, int num_monitors, const struct monitor_info *monitors, @@ -2226,7 +2226,7 @@ lib_mod_server_monitor_resize(struct vnc *v, int width, int height, /******************************************************************************/ /* return error */ -int +static int lib_mod_server_monitor_full_invalidate(struct vnc *v, int param1, int param2) { return 0; diff --git a/vnc/vnc_clip.c b/vnc/vnc_clip.c index 364bdff7..8054a242 100644 --- a/vnc/vnc_clip.c +++ b/vnc/vnc_clip.c @@ -804,7 +804,7 @@ vnc_clip_exit(struct vnc *v) /******************************************************************************/ -int +static int vnc_clip_process_eclip_pdu(struct vnc *v, struct stream *s) { int type; diff --git a/xrdp/Makefile.am b/xrdp/Makefile.am index 3e11f4ee..69658a2b 100644 --- a/xrdp/Makefile.am +++ b/xrdp/Makefile.am @@ -56,6 +56,7 @@ xrdp_SOURCES = \ xrdp_listen.c \ xrdp_login_wnd.c \ xrdp_mm.c \ + xrdp_mm.h \ xrdp_painter.c \ xrdp_process.c \ xrdp_region.c \ diff --git a/xrdp/xrdp_egfx.c b/xrdp/xrdp_egfx.c index 101b27ba..7c5b76de 100644 --- a/xrdp/xrdp_egfx.c +++ b/xrdp/xrdp_egfx.c @@ -40,6 +40,7 @@ #include "xrdp_egfx.h" #include "libxrdp.h" #include "xrdp_channel.h" +#include "xrdp_mm.h" #include #define MAX_PART_SIZE 0xFFFF @@ -928,10 +929,6 @@ xrdp_egfx_open_response(intptr_t id, int chan_id, int creation_status) return 0; } -int -advance_resize_state_machine(struct xrdp_mm *mm, - enum display_resize_state new_state); - /******************************************************************************/ /* from client */ static int diff --git a/xrdp/xrdp_listen.c b/xrdp/xrdp_listen.c index 51e53446..7981e7cc 100644 --- a/xrdp/xrdp_listen.c +++ b/xrdp/xrdp_listen.c @@ -140,7 +140,7 @@ xrdp_listen_delete_done_pro(struct xrdp_listen *self) /*****************************************************************************/ /* i can't get stupid in_val to work, hum using global var for now */ -THREAD_RV THREAD_CC +static THREAD_RV THREAD_CC xrdp_process_run(void *in_val) { struct xrdp_process *process; diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 61e097e6..034d63a9 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -21,6 +21,7 @@ #if defined(HAVE_CONFIG_H) #include #endif +#include "xrdp_mm.h" #include "xrdp.h" #include "log.h" #include "string_calls.h" @@ -1489,7 +1490,7 @@ xrdp_mm_egfx_frame_ack(void *user, uint32_t queue_depth, int frame_id, } /******************************************************************************/ -int +static int egfx_initialize(struct xrdp_mm *self) { LOG_DEVEL(LOG_LEVEL_TRACE, "egfx_initialize"); @@ -1988,7 +1989,7 @@ dynamic_monitor_process_queue(struct xrdp_mm *self) } /******************************************************************************/ -int +static int dynamic_monitor_initialize(struct xrdp_mm *self) { struct xrdp_drdynvc_procs d_procs; diff --git a/xrdp/xrdp_mm.h b/xrdp/xrdp_mm.h new file mode 100644 index 00000000..80942314 --- /dev/null +++ b/xrdp/xrdp_mm.h @@ -0,0 +1,34 @@ +/** + * xrdp: A Remote Desktop Protocol server. + * + * Copyright (C) Jay Sorg 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * module manager + */ + +#ifndef _XRDP_MM_H +#define _XRDP_MM_H + +#include "arch.h" +#include "trans.h" +#include "list16.h" +#include "libxrdpinc.h" +#include "xrdp_types.h" + +int +advance_resize_state_machine(struct xrdp_mm *mm, + enum display_resize_state new_state); + +#endif diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 33c360e4..e77fdabd 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -289,7 +289,7 @@ xrdp_wm_pointer(struct xrdp_wm *self, char *data, char *mask, int x, int y, /*****************************************************************************/ /* returns error */ -int +static int xrdp_wm_load_pointer(struct xrdp_wm *self, char *file_name, char *data, char *mask, int *x, int *y) { diff --git a/xup/xup.c b/xup/xup.c index fc96c58f..18ec05ed 100644 --- a/xup/xup.c +++ b/xup/xup.c @@ -52,7 +52,7 @@ lib_send_copy(struct mod *mod, struct stream *s) /******************************************************************************/ /* return error */ -int +static int lib_mod_start(struct mod *mod, int w, int h, int bpp) { LOG_DEVEL(LOG_LEVEL_TRACE, "in lib_mod_start"); @@ -147,7 +147,7 @@ lib_data_in(struct trans *trans) /******************************************************************************/ /* return error */ -int +static int lib_mod_connect(struct mod *mod) { int error; @@ -257,7 +257,7 @@ lib_mod_connect(struct mod *mod) /******************************************************************************/ /* return error */ -int +static int lib_mod_event(struct mod *mod, int msg, tbus param1, tbus param2, tbus param3, tbus param4) { @@ -1230,7 +1230,7 @@ process_server_paint_rect_shmem_ex(struct mod *amod, struct stream *s) /******************************************************************************/ /* return error */ -int +static int process_server_egfx_shmfd(struct mod *amod, struct stream *s) { char *data; @@ -1814,7 +1814,7 @@ lib_mod_process_message(struct mod *mod, struct stream *s) /******************************************************************************/ /* return error */ -int +static int lib_mod_signal(struct mod *mod) { // no-op @@ -1823,7 +1823,7 @@ lib_mod_signal(struct mod *mod) /******************************************************************************/ /* return error */ -int +static int lib_mod_end(struct mod *mod) { if (mod->screen_shmem_pixels != 0) @@ -1836,7 +1836,7 @@ lib_mod_end(struct mod *mod) /******************************************************************************/ /* return error */ -int +static int lib_mod_set_param(struct mod *mod, const char *name, const char *value) { if (g_strcasecmp(name, "username") == 0) @@ -1865,7 +1865,7 @@ lib_mod_set_param(struct mod *mod, const char *name, const char *value) /******************************************************************************/ /* return error */ -int +static int lib_mod_get_wait_objs(struct mod *mod, tbus *read_objs, int *rcount, tbus *write_objs, int *wcount, int *timeout) { @@ -1882,7 +1882,7 @@ lib_mod_get_wait_objs(struct mod *mod, tbus *read_objs, int *rcount, /******************************************************************************/ /* return error */ -int +static int lib_mod_check_wait_objs(struct mod *mod) { int rv; @@ -1905,7 +1905,7 @@ lib_mod_check_wait_objs(struct mod *mod) /******************************************************************************/ /* return error */ -int +static int lib_mod_frame_ack(struct mod *amod, int flags, int frame_id) { LOG_DEVEL(LOG_LEVEL_TRACE, @@ -1916,7 +1916,7 @@ lib_mod_frame_ack(struct mod *amod, int flags, int frame_id) /******************************************************************************/ /* return error */ -int +static int lib_mod_suppress_output(struct mod *amod, int suppress, int left, int top, int right, int bottom) {