static void patch_rect (cairo_pattern_t *pattern, double x0, double y0, double x1, double y1, double radius, double r, double g, double b, double a) { patch_arc (pattern, x0, y0, -M_PI, -M_PI/2, radius, r, g, b, a); patch_arc (pattern, x1, y0, -M_PI/2, 0, radius, r, g, b, a); patch_arc (pattern, x1, y1, 0, M_PI/2, radius, r, g, b, a); patch_arc (pattern, x0, y1, M_PI/2, M_PI, radius, r, g, b, a); patch_line (pattern, x0, y0, x1, y0, radius, r, g, b, a); patch_line (pattern, x1, y0, x1, y1, radius, r, g, b, a); patch_line (pattern, x1, y1, x0, y1, radius, r, g, b, a); patch_line (pattern, x0, y1, x0, y0, radius, r, g, b, a); }
int build_payload_from_template( JOB_DATA *job_data ) { FILE *tpl; if ( !job_data->templatefile ) return -1; tpl = fopen( job_data->templatefile, "r" ); if ( tpl == NULL ) { ERR( "Could not open template file '%s'\n", job_data->templatefile ); return -1; } /* if */ while ( !feof ( tpl ) ) { const char *delim = "="; char line[1024]; char *k, *v; if ( fgets( line, sizeof( line ), tpl ) == NULL ) { if ( !feof( tpl ) ) { ERR( "Error reading from data file '%s'\n", job_data->datafile ); fclose( tpl ); return -1; } /* if */ break; } /* if */ strip_crlf( line ); k = strtok( line, delim ); v = strtok( NULL, delim ); if ( k && v ) { unsigned char patched[MAXFIELDLENGTH]; int len; len = patch_line( k, v, patched, MAXFIELDLENGTH ); if ( len > 0 ) { append_to_payload( job_data, patched, len ); } else { ERR( "Ooops patch error: Param: '%s' value to patch in: '%s'.\n", k, v ); } /* if */ } /* if */ } /* while */ fclose( tpl ); return 0; } /* build_payload_from_template */