Beispiel #1
0
void qmail_finish(const char* sender)
{
  int status;

  close(msgfd);
  if(waitpid(inject_pid, &status, WUNTRACED) == -1)
    fail_temp("Failed to catch exit status of qmail-inject");
  if(!WIFEXITED(status))
    fail_temp("qmail-inject crashed");
  if(WEXITSTATUS(status))
    fail_temp("qmail-inject failed");

  write_envelope(sender);
  close(envfd);

  if(waitpid(queue_pid, &status, WUNTRACED) == -1)
    fail_temp("Failed to catch exit status of qmail-queue");
  if(!WIFEXITED(status))
    fail_temp("qmail-queue crashed");
  if(WEXITSTATUS(status))
    fail_temp("qmail-queue failed");

  if (!opt_quiet)
    msgf("{Sent response qp }d", queue_pid);
}
Beispiel #2
0
int
main (int argc, char **argv)
{
    struct bloch_sim *b = malloc(sizeof(*b));

    int option = 0;

    realtype p_0 = 0.0;
    realtype p_1 = 0.0;

    int num_cells = 9;

    int freq_write_flag = 0;
    char *freq_file_str;
    int env_write_flag = 0;
    char *env_file_str;
    // int param_write_flag;



    while ((option = getopt(argc, argv,"l:q:h:e:c:")) != -1)
    {
        switch (option)
        {
            case 'l' :
                p_0 = strtod(optarg, NULL);
                break;

            case 'q' :
                p_1 = strtod(optarg, NULL);
                break;

            case 'h' :
                freq_write_flag = 1;
                freq_file_str = optarg;
                break;

            case 'e' :
                env_write_flag = 1;
                env_file_str = optarg;
                break;

            case 'c':
                num_cells = atoi(optarg);

            default:
                //print_usage();
                break;
        }
    }


    initialize_bloch(b, p_0, p_1, num_cells);
    simulate_nmr_pulse(b);

    if (freq_write_flag)
    {
        FILE *freq_file = fopen(freq_file_str, "w");
        if (freq_file == NULL) {
            fprintf(stderr, "ERROR: failed to open frequency output file!\n");
            exit(1);
        }
        write_frequencies(b, freq_file);
        fclose(freq_file);
    }

    if (env_write_flag)
    {
        FILE *env_file = fopen(env_file_str, "w");
        if (env_file == NULL) {
            fprintf(stderr, "ERROR: failed to open envelope output file!\n");
            exit(1);
        }
        write_envelope(b, env_file);
        fclose(env_file);
    }

    free_bloch(b);
    return 0;
}