afify / azan (public) (License: MIT) (since 2020-03-08) (hash sha1)
azan is a simple muslim prayers notifier for unix-like systems.
List of commits:
Subject Hash Author Date (UTC)
[fix] create_cache bug, clean Makefile *.log 7d998c3f864fe07102b3fa07f83ea754159a9927 Hassan Afify 2019-09-24 05:38:39
[feat] argument options, next_fajr 4cd6ef1633f3e5cd3afe36be70e9c718911e701d Hassan Afify 2019-09-23 09:38:57
[doc] Update CONTRIBUTING, README & man page a16565d0b498313a8df232d3e2f5e7c1367dc191 Hassan Afify 2019-09-22 10:23:25
[doc] Update CONTRIBUTING, README & man page 0b978479fbe5d6e626a55a5ac78231393a267025 Hassan Afify 2019-09-22 10:23:25
[feat] Edit Makefile, Add config.def.h, config.mk c9e13a7b6dcc00894620f5788c04f4afba0f59d4 Hassan Afify 2019-09-21 17:11:34
[fix] Replace CODE_STYLE with CONTRIBUTING.md be2b91ef8d73aea536bc45446808633561d8afd9 Hassan Afify 2019-09-21 11:14:30
[feat] Edit Makefile, azan.c 538877a4311572caa1ddb88ffd0bac5e0b4379bc Hassan Afify 2019-09-20 12:59:05
[feat] Edit Makefile f41f74a524feb96228eb35a77a336862d5ca958c Hassan Afify 2019-09-19 05:04:00
[feat] Self Calcutation 1be712f454adda33c8a182a4478a3abf5dba6745 Hassan Afify 2019-09-17 08:11:15
[init] Initial Commit 2654768d0412e07cf7aa4b78a41b125aeceab82e Hassan Afify 2019-09-04 01:44:23
Commit 7d998c3f864fe07102b3fa07f83ea754159a9927 - [fix] create_cache bug, clean Makefile *.log
* create_cache
- problem: create cache dir argument was full_path.
- solution: create function (get_cache_dir).

* next fajr bug
- problem: for loop i<5
- solution: i<6

- Makefile
- add *.log in clean command
Author: Hassan Afify
Author date (UTC): 2019-09-24 05:38
Committer name: Hassan Afify
Committer date (UTC): 2019-09-24 05:38
Parent(s): ea4bf7df17f40de0fa69935d2ad117926867e1ba
Signing key: 0F6CD1196B2A5658
Tree: 7cbcd464edbd12f14d7e09a96317949f74ea1c21
File Lines added Lines deleted
Makefile 1 1
azan.c 45 35
azan.h 1 0
File Makefile changed (mode: 100644) (index 431b21e..2735d65)
... ... azan: $(OBJ)
28 28 $(CC) -o $@ $(OBJ) $(STLDFLAGS) $(CC) -o $@ $(OBJ) $(STLDFLAGS)
29 29
30 30 clean: clean:
31 rm -f $(OBJ) azan
31 rm -f $(OBJ) azan *.log
32 32
33 33 install: azan install: azan
34 34 mkdir -p $(DESTDIR)$(PREFIX)/bin mkdir -p $(DESTDIR)$(PREFIX)/bin
File azan.c changed (mode: 100644) (index 51156dc..bed1c2a)
... ... create_cache_file(time_t t, char* full_path)
325 325
326 326 /* Create Cache File if doesn't exists'*/ /* Create Cache File if doesn't exists'*/
327 327 if (file_exist(full_path) < 0){ if (file_exist(full_path) < 0){
328 // FIXME: if dir with same name(must get file type filter)
328 329 /* Equation of Time */ /* Equation of Time */
329 330 double julian_date = convert_gregorian_to_julian(year, month, day); double julian_date = convert_gregorian_to_julian(year, month, day);
330 331 double D = 0; double D = 0;
331 332 double equation_of_time = get_equation_time(julian_date, &D); double equation_of_time = get_equation_time(julian_date, &D);
332 333
333 334 /* Today's Prayers time */ /* Today's Prayers time */
334 // FIXME 3 minutes less (duhr = 15 should be 18)
335 // FIXME 3 minutes less (duhr = 15 should be 18)
335 336 double duhr = get_duhr(time_zone, longitude, equation_of_time); double duhr = get_duhr(time_zone, longitude, equation_of_time);
336 337 double sunrise = get_sunrise(duhr, latitude, altitude, D); double sunrise = get_sunrise(duhr, latitude, altitude, D);
337 // TODO fajr sunrise
338 // fajr = get_fajr(true_noon, sunset_prev, sunrise, loc, &coord);
338 // TODO fajr sunrise
339 // fajr = get_fajr(true_noon, sunset_prev, sunrise, loc, &coord);
339 340 double fajr = get_fajr(duhr, latitude, D, fajr_angle); double fajr = get_fajr(duhr, latitude, D, fajr_angle);
340 341 double maghrib = get_maghrib(duhr, latitude, altitude, D); double maghrib = get_maghrib(duhr, latitude, altitude, D);
341 342 //TODO isha next sunrise //TODO isha next sunrise
 
... ... create_cache_file(time_t t, char* full_path)
345 346
346 347
347 348 /* Convert prayer times to unix timestamp */ /* Convert prayer times to unix timestamp */
348 static time_t prayer_array[6];
349 prayer_array[0] = convert_today_double_to_timet(fajr, day);
350 prayer_array[1] = convert_today_double_to_timet(duhr, day);
351 prayer_array[2] = convert_today_double_to_timet(asr, day);
352 prayer_array[3] = convert_today_double_to_timet(maghrib, day);
353 prayer_array[4] = convert_today_double_to_timet(isha, day);
354 prayer_array[5] = convert_today_double_to_timet(fajr, day+1);
355
356 /* Create cache dir if not exists*/
357 (void)mkdir(full_path, 0700);
358
359 /* Create cache file */
360 FILE* fpointer;
361 fpointer = fopen(full_path, "w");
362 chmod(full_path, 00400); /* Change permission to read only*/
363 // (void)puts(full_path);
364
365 if (fpointer == NULL) {
366 printf("[Error] opening lp cache file.\n");
367 exit(EXIT_FAILURE);
368 }
349 static time_t prayer_array[6];
350 prayer_array[0] = convert_today_double_to_timet(fajr, day);
351 prayer_array[1] = convert_today_double_to_timet(duhr, day);
352 prayer_array[2] = convert_today_double_to_timet(asr, day);
353 prayer_array[3] = convert_today_double_to_timet(maghrib, day);
354 prayer_array[4] = convert_today_double_to_timet(isha, day);
355 prayer_array[5] = convert_today_double_to_timet(fajr, day+1);
356
357 /* Create cache dir if not exists*/
358 char* cache_dir = get_cache_dir();
359 (void)mkdir(cache_dir, 0700);
360
361 /* Create cache file */
362 FILE* fpointer;
363 fpointer = fopen(full_path, "w");
364 chmod(full_path, 00400); /* Change permission to read only*/
365 if (fpointer == NULL) {
366 printf("[Error] opening lp cache file.\n");
367 exit(EXIT_FAILURE);
368 }
369 369
370 370 fprintf(fpointer, "%ld\n%ld\n%ld\n%ld\n%ld\n%ld", fprintf(fpointer, "%ld\n%ld\n%ld\n%ld\n%ld\n%ld",
371 371 (long)prayer_array[0], (long)prayer_array[0],
 
... ... create_cache_file(time_t t, char* full_path)
376 376 (long)prayer_array[5] (long)prayer_array[5]
377 377 ); );
378 378
379 (void)fclose(fpointer);
379 (void)fclose(fpointer);
380 380 } }
381 381
382 382 return 0; return 0;
 
... ... print_next_prayer(time_t current_time, char* azan_cache_file)
440 440 exit(EXIT_FAILURE); exit(EXIT_FAILURE);
441 441 } }
442 442
443 for (int i=0; i<5; i++) {
443 for (int i=0; i<6; i++) {
444 444 if (azan_array[i] > current_time){ if (azan_array[i] > current_time){
445 445 double left_seconds = difftime(azan_array[i], current_time); double left_seconds = difftime(azan_array[i], current_time);
446 446 char prayer_first_letter = conv_prayer_int_to_char(i); char prayer_first_letter = conv_prayer_int_to_char(i);
 
... ... conv_prayer_int_to_char(int pray_numb)
507 507 return result; return result;
508 508 } }
509 509
510 static char*
511 get_cache_dir(void)
512 {
513 size_t max_dir_name = 128;
514 char* user_home = getenv("HOME");
515 char* cache_dir;
516 cache_dir = calloc(128, sizeof(char));
517
518 if (user_home == NULL) {
519 printf("Error, allocating memory [ Line %d ]\n", __LINE__);
520 exit(EXIT_FAILURE);
521 }
522 (void)snprintf(cache_dir, max_dir_name, "%s/.cache/azan", user_home);
523
524 return cache_dir;
525 }
526
510 527 static char* static char*
511 528 get_cache_file_name(time_t t) get_cache_file_name(time_t t)
512 529 { {
 
... ... get_cache_file_name(time_t t)
517 534 int year = current_date.tm_year + 1900; int year = current_date.tm_year + 1900;
518 535
519 536 size_t max_file_name = 128; size_t max_file_name = 128;
520 static char cache_dir[128];
537 char* cache_dir = get_cache_dir();
521 538 static char azan_cache_file[128]; static char azan_cache_file[128];
522 539
523 /* Get Home dir */
524 char* user_home = getenv("HOME");
525 if (user_home == NULL) {
526 printf("Error, allocating memory [ Line %d ]\n", __LINE__);
527 exit(EXIT_FAILURE);
528 }
529 (void)snprintf(cache_dir, max_file_name, "%s/.cache/azan", user_home);
530 540 (void)snprintf(azan_cache_file, max_file_name, "azan_%.2i-%.2i-%i.txt", (void)snprintf(azan_cache_file, max_file_name, "azan_%.2i-%.2i-%i.txt",
531 541 day, month, year); day, month, year);
532 542
 
... ... main(int argc, char *argv[])
583 593 if (argc > 1) { if (argc > 1) {
584 594 switch (c) { switch (c) {
585 595 case 'v': case 'v':
586 puts("azan-"VERSION);
596 (void)puts("azan-"VERSION);
587 597 break; break;
588 598 case 'n': case 'n':
589 599 send_notification(full_path); send_notification(full_path);
File azan.h changed (mode: 100644) (index 72dfd20..4195b9c)
... ... static int print_next_prayer(time_t current_time, char* azan_cache_file);
47 47 static int print_all_prayers(char* azan_cache_file); static int print_all_prayers(char* azan_cache_file);
48 48 static char conv_prayer_int_to_char(int pray_numb); static char conv_prayer_int_to_char(int pray_numb);
49 49 static char* get_cache_file_name(time_t t); static char* get_cache_file_name(time_t t);
50 static char* get_cache_dir(void);
50 51 static void send_notification(char* azan_cache_file); static void send_notification(char* azan_cache_file);
51 52
52 53 // static Prayer todays_prayers[6] = { // static Prayer todays_prayers[6] = {
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/afify/azan

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/afify/azan

Clone this repository using git:
git clone git://git.rocketgit.com/user/afify/azan

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main