1 /******************************************************************************* 2 * Copyright (c) 2013-2021, Andrés Martinelli <andmarti@gmail.com> * 3 * All rights reserved. * 4 * * 5 * This file is a part of SC-IM * 6 * * 7 * SC-IM is a spreadsheet program that is based on SC. The original authors * 8 * of SC are James Gosling and Mark Weiser, and mods were later added by * 9 * Chuck Martin. * 10 * * 11 * Redistribution and use in source and binary forms, with or without * 12 * modification, are permitted provided that the following conditions are met: * 13 * 1. Redistributions of source code must retain the above copyright * 14 * notice, this list of conditions and the following disclaimer. * 15 * 2. Redistributions in binary form must reproduce the above copyright * 16 * notice, this list of conditions and the following disclaimer in the * 17 * documentation and/or other materials provided with the distribution. * 18 * 3. All advertising materials mentioning features or use of this software * 19 * must display the following acknowledgement: * 20 * This product includes software developed by Andrés Martinelli * 21 * <andmarti@gmail.com>. * 22 * 4. Neither the name of the Andrés Martinelli nor the * 23 * names of other contributors may be used to endorse or promote products * 24 * derived from this software without specific prior written permission. * 25 * * 26 * THIS SOFTWARE IS PROVIDED BY ANDRES MARTINELLI ''AS IS'' AND ANY * 27 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * 28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * 29 * DISCLAIMED. IN NO EVENT SHALL ANDRES MARTINELLI BE LIABLE FOR ANY * 30 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * 31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;* 32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * 33 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * 35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 36 *******************************************************************************/ 37 38 /** 39 * \file file.h 40 * \author Andrés Martinelli <andmarti@gmail.com> 41 * \date 2017-07-18 42 * \brief Header file for file.c 43 */ 44 45 #include "freeze.h" 46 47 void erasedb(); 48 void loadrc(void); 49 int modcheck(); 50 int savefile(); 51 int writefile(char *fname, int r0, int c0, int rn, int cn, int verbose); 52 void write_fd(register FILE *f, int r0, int c0, int rn, int cn); 53 void write_cells(register FILE *f, int r0, int c0, int rn, int cn, int dr, int dc); 54 void write_marks(register FILE *f); 55 void write_franges(register FILE *f); 56 57 typedef enum { 58 SC_READFILE_ERROR = 0, 59 SC_READFILE_SUCCESS = 1, 60 SC_READFILE_DOESNTEXIST = 2 61 } sc_readfile_result; 62 sc_readfile_result readfile(char *fname, int eraseflg); 63 64 int file_exists(const char * fname); 65 char * findhome(char *path); 66 int backup_file(char *path); 67 FILE * openfile(char *fname, int *rpid, int *rfd); 68 void closefile(FILE *f, int pid, int rfd); 69 void print_options(FILE *f); 70 int import_csv(char * fname, char d); 71 int import_markdown(char * fname); 72 void do_export(int r0, int c0, int rn, int cn); 73 void export_delim(char * fname, char coldelim, int r0, int c0, int rn, int cn, int verbose); 74 void export_plain(char * fname, int r0, int c0, int rn, int cn); 75 void export_markdown(char * fname, int r0, int c0, int rn, int cn); 76 void export_latex(char * fname, int r0, int c0, int rn, int cn, int verbose); 77 void unspecial(FILE * f, char * str, int delim); 78 int max_length(FILE * f); 79 int count_lines(FILE * f); 80 int plugin_exists(char * name, int len, char * path); 81 void * do_autobackup(); 82 void handle_backup(); 83 void remove_backup(char * file); 84 int backup_exists(char * file); 85 void openfile_nested(char * file); 86 void openfile_under_cursor(int r, int c); 87