summaryrefslogtreecommitdiff
path: root/src/common.c
blob: f6c13275a5bc83514fa8096dcd2e15bed4d7a01c (plain)
    1 /**
    2  * This CGI program renders the oper.io blog
    3  * Copyright (C) 2019 Aaron Ball <nullspoon@oper.io>
    4  *
    5  * This program is free software: you can redistribute it and/or modify
    6  * it under the terms of the GNU General Public License as published by
    7  * the Free Software Foundation, either version 3 of the License, or
    8  * (at your option) any later version.
    9  *
   10  * This program is distributed in the hope that it will be useful,
   11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13  * GNU General Public License for more details.
   14  *
   15  * You should have received a copy of the GNU General Public License
   16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
   17  */
   18 #include "common.h"
   19 
   20 int catfile(char* path) {
   21   char c = 0;
   22   FILE* fd = fopen(path, "r");
   23   if(!fd)
   24     return 2;
   25 
   26   while((c = fgetc(fd)) != EOF)
   27     printf("%c", c);
   28 
   29   fclose(fd);
   30   return 0;
   31 }
   32 
   33 
   34 int file_exists(char*  path) {
   35   FILE* fd;
   36   fd = fopen(path, "r");
   37   if(!fd)
   38     return 2;
   39   fclose(fd);
   40   return 1;
   41 }

Generated by cgit