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 struct quran
*quran_alloc(char *path
)
35 struct quran
*quran
= xmalloc(sizeof(struct quran
));
36 memset(quran
, 0, sizeof(quran
));
37 quran
->text
= file_read(path
);
41 void quran_aya(struct quran
*quran
, char *buf
, size_t len
, int aya
)
44 char *s
= quran
->text
;
47 for (i
= 0; i
< aya
; i
++)
48 s
= strchr(s
, '\n') + 1;
57 void quran_free(struct quran
*quran
)
64 7, 286, 200, 176, 120, 165, 206, 75, 129, 109,
65 123, 111, 43, 52, 99, 128, 111, 110, 98, 135,
66 112, 78, 118, 64, 77, 227, 93, 88, 69, 60,
67 34, 30, 73, 54, 45, 83, 182, 88, 75, 85,
68 54, 53, 89, 59, 37, 35, 38, 29, 18, 45,
69 60, 49, 62, 55, 78, 96, 29, 22, 24, 13,
70 14, 11, 11, 18, 12, 12, 30, 52, 52, 44,
71 28, 28, 20, 56, 40, 31, 50, 40, 46, 42,
72 29, 19, 36, 25, 22, 17, 19, 26, 30, 20,
73 15, 21, 11, 8, 8, 19, 5, 8, 8, 11,
74 11, 8, 3, 9, 5, 4, 7, 3, 6,
77 int sura_ayas(int sura
)
79 return ayas
[sura
- 1];
82 int sura_start(int sura
)
86 for (i
= 0; i
< sura
- 1; i
++)
91 int aya_num(int sura
, int aya
)
93 return sura_start(sura
) + aya
;