Example #1
0
extern "C" void delete_file (char *pathname, struct client client) {
  struct decafs_file_stat file_info;
  uint32_t num_chunks = 0, request_id = get_new_request_id();

  // If the file doesn't exist
  if ((decafs_file_sstat (pathname, &file_info, client)) < 0) {
    // TODO halli check if this change is correct
    // old call
    //if (send_delete_result (client, 0, FILE_NOT_FOUND) < 0) {
    if (send_remove_result (client, FILE_NOT_FOUND) < 0) {
      printf ("\tDelete result could not reach client.\n");
    }
    return;
  }

  if (get_exclusive_lock (client, file_info.file_id) < 0) {
    // TODO halli check if this change is correct
    // old call
    //if (send_delete_result (client, 0, FILE_IN_USE) < 0) {
    if (send_remove_result (client, FILE_IN_USE) < 0) {
      printf ("\tDelete result could not reach client.\n");
    }
    return;
  }

  // Save the request id.
  active_delete_requests[request_id] = request_info (client, file_info.file_id);
  printf ("(request: %d) processing delete file %s\n", request_id, pathname);
  num_chunks = process_delete_file (request_id, file_info.file_id);

  assert (delete_request_exists (request_id));
  active_delete_requests[request_id].chunks_expected = num_chunks;
  check_delete_complete(request_id);
}
Example #2
0
int main(int argc, char **argv)
{
	int ret;

	if ((ret = gnutls_global_init()) < 0) {
		fprintf(stderr, "global_init: %s\n", gnutls_strerror(ret));
		exit(1);
	}

	optionProcess(&ocsptoolOptions, argc, argv);

	gnutls_global_set_log_function(tls_log_func);
	gnutls_global_set_log_level(OPT_VALUE_DEBUG);

	if (HAVE_OPT(OUTFILE)) {
		outfile = fopen(OPT_ARG(OUTFILE), "wb");
		if (outfile == NULL) {
			fprintf(stderr, "%s\n", OPT_ARG(OUTFILE));
			exit(1);
		}
	} else
		outfile = stdout;

	if (HAVE_OPT(INFILE)) {
		infile = fopen(OPT_ARG(INFILE), "rb");
		if (infile == NULL) {
			fprintf(stderr, "%s\n", OPT_ARG(INFILE));
			exit(1);
		}
	} else
		infile = stdin;

	if (ENABLED_OPT(INDER))
		encoding = GNUTLS_X509_FMT_DER;
	else
		encoding = GNUTLS_X509_FMT_PEM;

	if (HAVE_OPT(REQUEST_INFO))
		request_info();
	else if (HAVE_OPT(RESPONSE_INFO))
		response_info();
	else if (HAVE_OPT(GENERATE_REQUEST))
		generate_request(NULL);
	else if (HAVE_OPT(VERIFY_RESPONSE))
		verify_response(NULL);
	else if (HAVE_OPT(ASK))
		ask_server(OPT_ARG(ASK));
	else {
		USAGE(1);
	}

	return 0;
}