2 * cnoor - a small framebuffer Quran viewer
4 * Copyright (C) 2009-2015 Ali Gholami Rudi <ali at rudi dot ir>
6 * This program is released under the Modified BSD license.
16 #define LENGTH(vars) (sizeof(vars) / sizeof(vars[0]))
18 static char *adigs
[] = {"٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"};
20 static char *arabic_number(int n
)
27 digs
[ndigs
++] = n
% 10;
31 for (i
= 0; i
< ndigs
; i
++)
32 strcat(buf
, adigs
[digs
[i
]]);
36 static void ins_sura(struct quran
*quran
, struct quran
*trans
, int sura
)
39 int start
= sura_start(sura
);
40 int ayas
= sura_ayas(sura
);
42 for (i
= 0; i
< ayas
; i
++) {
43 int juz
= juz_start(sura
, i
+ 1);
44 int sajda
= sajda_kind(sura
, i
+ 1);
47 sprintf(buf
, " %s\n", arabic_number(juz
));
48 txtwin_append(buf
, FONT_JUZ
);
50 quran_aya(quran
, buf
, LENGTH(buf
), start
+ i
);
51 txtwin_append(buf
, FONT_QURAN
);
52 sprintf(buf
, " %s ", arabic_number(i
+ 1));
53 txtwin_append(buf
, FONT_NUM
);
54 if (sajda
!= SAJDA_NONE
) {
55 char *s
= sajda
== SAJDA_RECOM
? "*" : "**";
56 txtwin_append(s
, FONT_SAJDA
);
59 quran_aya(trans
, buf
, LENGTH(buf
), start
+ i
);
60 txtwin_append("\n", NULL
);
61 txtwin_append(buf
, FONT_TRANS
);
63 txtwin_append("\n\n", NULL
);
71 struct quran
*trans
= NULL
;
72 sprintf(name
, "%d(%s)", sura
, sura_name(sura
));
73 quran
= quran_alloc(QURAN_PATH
);
75 trans
= quran_alloc(TRANS_PATH
);
77 ins_sura(quran
, trans
, sura
);
86 int main(int argc
, char **argv
)
89 if (argc
== 1 || !strcmp(argv
[1], "-h")) {
90 printf("usage: %s sura_number\n", argv
[0]);
94 if (sura
<= 0 || sura
> 114) {
95 fprintf(stderr
, "cnoor: invalid sura number\n");