void print_sexpr(cell_t * list, int depth, file_io_t * out, file_io_t * err) { char buf[MAX_STR]; cell_t *tmp; if (list == NULL) { print_error("print_sexpr was passed a NULL!", err); return; } if (list->type == type_null) { print_space(depth + 1, out); print_string("Null\n", out); return; } else if (list->type == type_number) { print_space(depth + 1, out); sprintf(buf, "%d", list->car.i); print_string(buf, out); wrap_put(out, '\n'); } else if (list->type == type_str) { print_space(depth + 1, out); wrap_put(out, '"'); print_string(list->car.s, out); wrap_put(out, '"'); wrap_put(out, '\n'); return; } else if (list->type == type_symbol) { print_space(depth + 1, out); print_string(list->car.s, out); wrap_put(out, '\n'); return; } else if (list->type == type_list) { if (depth == 0) { print_string("(\n", out); } for (tmp = list; tmp != NULL; tmp = tmp->cdr.cell) { if (tmp->car.cell != NULL && tmp->type == type_list) { print_space(depth + 1, out); print_string("(\n", out); print_sexpr(tmp->car.cell, depth + 1, out, err); print_space(depth + 1, out); print_string(")\n", out); } if (tmp->type != type_list) { print_sexpr(tmp, depth + 1, out, err); } } if (depth == 0) { print_string(")\n", out); } } return; }
static void print_error(char *s, file_io_t * err) { /*fprintf(stderr, "(error \"%s\" \"%s\" %d)\n",(X),__FILE__,__LINE__); */ print_string("(error \"", err); print_string(s, err); print_string("\" " __FILE__ ")", err); /*PRINT LINE NUMBER */ (void)wrap_put(err, '\n'); }
void put(void * webpayRef, LPCTSTR name, LPCTSTR value) { debug_logging("put: [%d] %s=%s\n",webpayRef,name,value); if(wrap_put == NULL){ // Method not available fprintf(stderr, " wrap_put not available \r\n"); return; } if(webpayRef == NULL){ fprintf(stderr, "Error during Put: webpayRef is null. Ensure that newBundle returns valid webpayRef. \r\n"); return; } wrap_put(webpayRef,name,value); }
static void print_string(char *s, file_io_t * out) { int i; for (i = 0; s[i] != '\0'; i++) (void)wrap_put(out, s[i]); }
static void print_space(int depth, file_io_t * out) { int i; for (i = 0; i < ((depth * 2)); i++) (void)wrap_put(out, ' '); }