/* Authored by abakh To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see . */ #include #include #include #include #include #include "config.h" #define FOPEN_FAIL -10 typedef signed char byte; FILE* score_file; byte score_write(const char* path, long wscore, byte save_to_num){// only saves the top 10, returns the place in the chart score_file=fopen(path,"r"); if(!score_file){ score_file=fopen(path,"w"); if(!score_file){ return FOPEN_FAIL; } } char name_buff[save_to_num][60]; long score_buff[save_to_num]; memset(name_buff,0,save_to_num*60*sizeof(char) ); memset(score_buff,0,save_to_num*sizeof(long) ); long scanned_score =0; char scanned_name[60]={0}; byte location=0; while( fscanf(score_file,"%59s : %ld\n",scanned_name,&scanned_score) == 2 && location=scores_count || wscore>=score_buff[i]) ){ fprintf(score_file,"%s : %ld\n",getenv("USER"),wscore); ret=i; wrote_it=1; } if(i