commit f0409fe23769c21aa950424745a95def9f22d1c3
parent cdb6c36776ccc776926e26629dd13a03cef31585
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 27 Jul 2017 16:25:54 +0200
Remove the the solsplit post process
Diffstat:
| D | src/solsplit.c | | | 107 | ------------------------------------------------------------------------------- |
1 file changed, 0 insertions(+), 107 deletions(-)
diff --git a/src/solsplit.c b/src/solsplit.c
@@ -1,107 +0,0 @@
-/* Copyright (C) |Meso|Star> 2017
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#define _ISOC99_SOURCE /* snprintf support */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int
-main(int argc, char** argv)
-{
- char* c = NULL;
- char* str = NULL;
- char* buf = NULL;
- FILE* input = stdin;
- FILE* output = NULL;
- float azim = -1; /* Azimuth angle of the sun direction */
- float elev = -1; /* Elevation angle of the sun direction */
- int bufsz = 32;
- int strsz = 32;
- int err = 0;
- int n = 0;
-
- /* Helper macros */
- #define MALLOC(Mem, Sz) { \
- if(!((Mem) = malloc(Sz))) { \
- fprintf(stderr, "Memory error.\n"); \
- goto error; \
- } \
- } (void)0
- #define REALLOC(Mem, Sz) { \
- if(!((Mem) = realloc((Mem), (Sz)))) { \
- fprintf(stderr, "Memory error.\n"); \
- goto error; \
- } \
- } (void)0
-
- /* Load the submitted file if provided on the command line */
- if(argc > 1 && !(input = fopen(argv[1], "r"))) {
- fprintf(stderr, "Cannot open the file `%s'.\n", argv[1]);
- goto error;
- }
-
- MALLOC(buf, bufsz); /* Buffer that stores the input lines */
- MALLOC(str, strsz); /* Temporary string */
-
- while(fgets(buf, (int)bufsz, input)) { /* Read the input line */
-
- /* Ensure that the whole line is read */
- while(!strrchr(buf,'\n') && !feof(input)) {
- REALLOC(buf, (bufsz*=2));
- c = fgets(buf+strlen(buf), (int)bufsz-strlen(buf), input);
- }
-
- /* Remove the carriage return */
- if((c=strrchr(buf, '\n'))) *c = '\0';
-
- if(!strcmp(buf, "#--- No Sun direction")) {
- azim = elev = -1;
- } else if(!strncmp(buf, "#--- Sun direction:", 19)) {
- n = sscanf(buf+5, "Sun direction: %f %f (%*f %*f %*f)", &azim, &elev);
- if(n != 2) {
- fprintf(stderr, "Could not parse `%s'.\n", buf);
- goto error;
- }
- } else if(!strncmp(buf, "g ", 2)) {
- for(;;) {
- n = (azim < 0 || elev < 0)
- ? snprintf(str, strsz, "%s.obj", buf+2)
- : snprintf(str, strsz, "%g-%g-%s.obj", azim, elev, buf+2);
- if(n < strsz) break;
- REALLOC(str, (strsz*=2));
- }
- if(!output && !(output = fopen(str, "w"))) {
- fprintf(stderr, "Could not open '%s'.\n", str);
- goto error;
- }
- } else if(!strcmp(buf, "---")) {
- if(output) fclose(output);
- output = NULL;
- }
- if(output) fprintf(output, "%s\n", buf);
- }
-
-exit:
- if(str) free(str);
- if(buf) free(buf);
- if(output) fclose(output);
- if(input && input!=stdin) fclose(input);
- return err;
-error:
- err = 1;
- goto exit;
-}
-