aboutsummaryrefslogtreecommitdiff
path: root/src/calp.c
diff options
context:
space:
mode:
authorfoswret2026-08-15 12:05:08 -0500
committerfoswret2026-08-15 12:05:08 -0500
commit2fd20536872d24db4fe7507ed7da22db99bb7c14 (patch)
tree336581f5a471d6d5897c093d985fcc768881a27a /src/calp.c
parent5ead4f6c3d36557c56e27cf52835409d81ae6ed8 (diff)
Remove MagickWand dependencyHEADmaster
MagickWand too bloated for this application. Pull in ezini dependency, for future .ini file parsing.
Diffstat (limited to 'src/calp.c')
-rw-r--r--src/calp.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/calp.c b/src/calp.c
index 159f18d..50cff02 100644
--- a/src/calp.c
+++ b/src/calp.c
@@ -32,20 +32,30 @@ int main (void) {
int num_of_months = 12;
- char *months[num_of_months];
extern int days_in_month[12];
+ // Locale Setting
+ // --------------
+
char *week_names[7];
+ char *months[num_of_months];
- //const nl_item nl_abmons[12] = {ABMON_1, ABMON_2, ABMON_3, ABMON_4,
- // ABMON_5, ABMON_6, ABMON_7, ABMON_8,
- // ABMON_9, ABMON_10, ABMON_11, ABMON_12};
- const nl_item locale_months[12] = {MON_1, MON_2, MON_3, MON_4, MON_5, MON_6,
- MON_7, MON_8, MON_9, MON_10, MON_11, MON_12};
+ nl_item locale_months[12] =
- const nl_item locale_days[7] = {ABDAY_1, ABDAY_2, ABDAY_3, ABDAY_4,
+ nl_item locale_days[7] = {ABDAY_1, ABDAY_2, ABDAY_3, ABDAY_4,
ABDAY_5, ABDAY_6, ABDAY_7};
+ void generate_locale_months(nl_item *months[12]) {
+ locale_months = {MON_1, MON_2, MON_3, MON_4, MON_5, MON_6,
+ MON_7, MON_8, MON_9, MON_10, MON_11, MON_12};
+
+ setlocale(LC_ALL, "");
+
+ for (int i = 0; i < 12; i++) {
+ months[i] = nl_langinfo(locale_months[i]);
+ }
+ }
+
setlocale(LC_ALL, "");
for (int i = 0; i < 12; i++) {
@@ -85,7 +95,6 @@ int main (void) {
- // TBD: Add ability to choose filename
// Defaults to the year being generated
char filename[20];
snprintf(filename, sizeof(filename), "%d.pdf", year);
@@ -98,6 +107,9 @@ int main (void) {
+ // Extent Declaration
+ // ------------------
+
// Height and width of the paper
// .x and .y are empty
struct extents paper_extents = {
@@ -131,6 +143,8 @@ int main (void) {
};
+
+
// Position and width of the header
// Height is set dynamically, based on the size of
// the month grid
@@ -142,12 +156,13 @@ int main (void) {
// Program fails if the PDF backend isn't available
- if (!CAIRO_HAS_PDF_SURFACE) {
+ if (CAIRO_HAS_PDF_SURFACE == false) {
printf("Error: PDF backend not available.\n");
return 1;
}
- // Main surface and context are created
+ // Main surface and context are created, with the size being
+ // the paper
cairo_surface_t *surface =
cairo_pdf_surface_create(
filename,
@@ -183,12 +198,13 @@ int main (void) {
// Month generation loop
for (int i = 0; i < num_of_months; i++) {
- // Initialize month struct
+ // Initialize month struct, setting values
month.first_day = day_of_week(1, i + 1, year);
month.num_of_days = days_in_month[i];
month.month_position = i;
month.minimum_rows = calculate_minimum_rows(&month);
+ // Arbitrarily setting the distance between the month grid and the header
double month_header_spacing = margin * 3.0;
header_extents.height = paper_extents.height - month_header_spacing - ((month.minimum_rows + 1) * day_extents.height);
@@ -207,6 +223,7 @@ int main (void) {
+ // Fill header with blue color for visibility
set_color(ch, BLUE);
fill_bg(ch);