10 static size_t file_size(char *path
)
18 static char *file_read(char *path
)
24 size_t size
= file_size(path
);
26 fd
= open(path
, O_RDONLY
);
27 while ((c
= read(fd
, buf
+ n
, size
- n
)) > 0)
33 static int newlines(char *s
)
36 for (n
= 0; (s
= strchr(s
, '\n')); s
++, n
++);
40 struct quran
*quran_alloc(char *path
)
44 struct quran
*quran
= xmalloc(sizeof(struct quran
));
45 memset(quran
, 0, sizeof(quran
));
46 quran
->text
= file_read(path
);
47 nayas
= newlines(quran
->text
);
48 quran
->ayas
= xmalloc(sizeof(quran
->ayas
) * nayas
);
49 quran
->ayas
[0] = quran
->text
;
50 for (i
= 1; i
< nayas
; i
++)
51 quran
->ayas
[i
] = strchr(quran
->ayas
[i
- 1], '\n') + 1;
55 void quran_aya(struct quran
*quran
, char *buf
, size_t len
, int aya
)
57 char *s
= quran
->ayas
[aya
];
58 char *e
= strchr(s
, '\n');
63 buf
[buf
[n
- 1] == '\r' ? n
- 1 : n
] = '\0';
66 void quran_free(struct quran
*quran
)
74 7, 286, 200, 176, 120, 165, 206, 75, 129, 109,
75 123, 111, 43, 52, 99, 128, 111, 110, 98, 135,
76 112, 78, 118, 64, 77, 227, 93, 88, 69, 60,
77 34, 30, 73, 54, 45, 83, 182, 88, 75, 85,
78 54, 53, 89, 59, 37, 35, 38, 29, 18, 45,
79 60, 49, 62, 55, 78, 96, 29, 22, 24, 13,
80 14, 11, 11, 18, 12, 12, 30, 52, 52, 44,
81 28, 28, 20, 56, 40, 31, 50, 40, 46, 42,
82 29, 19, 36, 25, 22, 17, 19, 26, 30, 20,
83 15, 21, 11, 8, 8, 19, 5, 8, 8, 11,
84 11, 8, 3, 9, 5, 4, 7, 3, 6,
87 int sura_ayas(int sura
)
89 return ayas
[sura
- 1];
92 int sura_start(int sura
)
96 for (i
= 0; i
< sura
- 1; i
++)
101 int aya_num(int sura
, int aya
)
103 return sura_start(sura
) + aya
;
106 #define TMPNUM(sura, aya) (((sura) << 10) | (aya))
108 int juz_start(int sura
, int aya
)
110 switch (TMPNUM(sura
, aya
)) {
175 enum sajda
sajda_kind(int sura
, int aya
)
177 switch (TMPNUM(sura
, aya
)) {
184 case TMPNUM(17, 109):