Created
July 25, 2015 06:06
-
-
Save rplantiko/19448d6a0ab903566344 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "fcgi_stdio.h" | |
#include <unistd.h> | |
#include <setjmp.h> | |
#include <stdbool.h> | |
#include "../../swisseph/src/swephexp.h" | |
const char* EPHE_PATH = "/usr/swisseph/ephe"; | |
const int MAXLEN_EPHE_PATH = 132; | |
const double SWIEPH_START = 625614.927151; | |
const double SWIEPH_END = 2813641.5; | |
typedef struct { | |
double jd,lon,lat; | |
bool jd_given, lon_given, lat_given; | |
int iflag; | |
int * planets; | |
int nplanets; | |
char house_system; | |
char *error; // Points to result.error | |
bool debug; | |
} query; | |
typedef struct { | |
double* ppos; | |
int nppos; | |
double hpos[13]; | |
char warning[255]; | |
char error[255]; // Served via THROW | |
} result; | |
const query EMPTY_QUERY = {}; | |
const result EMPTY_RESULT = {}; | |
void parse( char* querystring, query *qdata); | |
void analyze_parameter( char*par, query *qdata ); | |
void parse_planets(char* input, query* q); | |
void parse_house_system(char* input, query* q); | |
int parse_csv_integers(char* input, int** numbers, char* error); | |
void compute( query *q, result* r ); | |
void compute_houses(query* q, result* r); | |
void compute_planets(query* q, result* r); | |
void print_numbers( double* numbers, int n); | |
void output(query* q, result* r); | |
void do_header(); | |
void init_request(query *q, result *r); | |
void initializations( char* ephepath ); | |
// try/catch emulation, | |
// idea borrowed from http://www.di.unipi.it/~nids/docs/longjump_try_trow_catch.html | |
jmp_buf _state; | |
#define TRY if (setjmp(_state)==0) | |
#define CATCH else | |
#define THROW(errmsg,...) { if (errmsg) sprintf(errmsg,__VA_ARGS__); longjmp(_state, 1); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment