void publish_and_basic_get_message(const char *msg_to_publish) { amqp_connection_state_t connection_state = setup_connection_and_channel(); queue_declare(connection_state, test_queue_name); basic_publish(connection_state, msg_to_publish); uint64_t body_size; char *msg = basic_get(connection_state, test_queue_name, &body_size); assert(body_size == strlen(msg_to_publish)); assert(strncmp(msg_to_publish, msg, body_size) == 0); free(msg); close_and_destroy_connection(connection_state); }
int main(int argc, char *argv[]) { int ret = 1; char *basic_buf; int basic_len; /* Get options */ if (parse_cmdline(argc, argv)) { return ret; } /* Get length of binfile */ binlen = get_binlen(opt.binfile); if (binlen == 0) { fprintf(stderr, "Error: empty or non-existing BIN-file, giving up\n"); goto cleanup; } if (opt.scrfile) { if (get_binlen(opt.scrfile) != SCRLEN) { fprintf(stderr, "Error: wrong filesize on %s\n", opt.scrfile); goto cleanup; } } /* Open filepointers */ if (open_files()) { fprintf(stderr, "Error: could not open files, giving up\n"); goto cleanup; } snprintf(basenamez, opt.baselen + 1, "%s", opt.basename); if (!opt.no_basic) { /* Creater BASIC loader code */ if (create_basic_loader()) { fprintf(stderr, "Error: could not create BASIC loader, giving up\n"); } if (basic_get(&basic_buf, &basic_len)) { fprintf(stderr, "Error: could not create BASIC loader, giving up\n"); goto cleanup; } /* Write BASIC loader */ if (write_program(basic_buf, basic_len, "Loader")) { goto cleanup; } /* Write SCREEN$ data */ if (opt.scrfile) { if (write_code("Screen", scrfp, SCRLEN, SCRADDR)) { goto cleanup; } } } /* Write machine code from BIN-file */ if (write_code(basenamez, binfp, binlen, opt.load_address)) { goto cleanup; } /* Success */ printf("0 OK, 0:1 (%s)\n", opt.tapfile); ret = 0; cleanup: if (scrfp) fclose(scrfp); if (binfp) fclose(binfp); if (tapfp) fclose(tapfp); parse_cleanup(); return ret; }