@@ -371,14 +371,14 @@ use libc::c_uint;
371
371
///
372
372
/// // handling error and printing the result.
373
373
/// if (!tcmb_evds_c_is_error(data_result)) { printf("\nNO ERROR!\n"); };
374
- ///
375
- /// fwrite(data_result.output_ptr, data_result.string_capacity, 1, stdout);
376
- /// fflush(stdout);
377
- ///
378
374
/// printf("\nError: %s", tcmb_evds_c_is_error(data_result) ? "true" : "false");
379
- ///
380
- ///
381
- /// free(data_result.output_ptr);
375
+ ///
376
+ /// char* data_result_message = calloc(data_result.string_capacity, sizeof(char));
377
+ /// memmove(data_result_message, data_result.output_ptr, data_result.string_capacity * sizeof(char));
378
+ ///
379
+ /// printf("%s", data_result_message);
380
+ ///
381
+ /// free(data_result_message);
382
382
///
383
383
/// return 0;
384
384
/// }
@@ -498,15 +498,19 @@ pub extern "C" fn tcmb_evds_c_get_data(
498
498
///
499
499
///
500
500
/// // handling error and printing the result.
501
- /// if (advanced_data_result.error_type == NoError) { printf("\nNO ERROR!\n"); };
502
- ///
503
- /// fwrite(advanced_data_result.output_ptr, advanced_data_result.string_capacity, 1, stdout);
504
- /// fflush(stdout);
505
- ///
501
+ /// if (!tcmb_evds_c_is_error(advanced_data_result)) { printf("\nNO ERROR!\n"); };
506
502
/// printf("\nError: %s", tcmb_evds_c_is_error(advanced_data_result) ? "true" : "false");
507
- ///
503
+ ///
504
+ /// char* advanced_data_result_message = calloc(advanced_data_result.string_capacity, sizeof(char));
505
+ /// memmove(
506
+ /// advanced_data_result_message,
507
+ /// advanced_data_result.output_ptr,
508
+ /// advanced_data_result.string_capacity * sizeof(char)
509
+ /// );
508
510
///
509
- /// free(advanced_data_result.output_ptr);
511
+ /// printf("%s", advanced_data_result_message);
512
+ ///
513
+ /// free(advanced_data_result_message);
510
514
///
511
515
/// return 0;
512
516
/// }
@@ -633,7 +637,7 @@ pub extern "C" fn tcmb_evds_c_get_advanced_data(
633
637
///
634
638
///
635
639
/// // requesting data.
636
- /// TcmbEvdsResult data_group_result =
640
+ /// TcmbEvdsResult data_group =
637
641
/// tcmb_evds_c_get_data_group(
638
642
/// data_group,
639
643
/// date,
@@ -644,15 +648,15 @@ pub extern "C" fn tcmb_evds_c_get_advanced_data(
644
648
///
645
649
///
646
650
/// // handling error and printing the result.
647
- /// if (data_group_result.error_type == NoError ) { printf("\nNO ERROR!\n"); };
648
- ///
649
- /// fwrite(data_group_result.output_ptr, data_group_result.string_capacity, 1, stdout);
650
- /// fflush(stdout );
651
- ///
652
- /// printf("\nError: %s", tcmb_evds_c_is_error(data_group_result) ? "true" : "false");
653
- ///
651
+ /// if (!tcmb_evds_c_is_error(data_group) ) { printf("\nNO ERROR!\n"); };
652
+ /// printf("\nError: %s", tcmb_evds_c_is_error(data_group) ? "true" : "false");
653
+ ///
654
+ /// char* data_group_message = calloc(data_group.string_capacity, sizeof(char) );
655
+ /// memmove(data_group_message, data_group.output_ptr, data_group.string_capacity * sizeof(char));
656
+ ///
657
+ /// printf("%s", data_group_message);
654
658
///
655
- /// free(data_group_result.output_ptr );
659
+ /// free(data_group_message );
656
660
///
657
661
/// return 0;
658
662
/// }
@@ -743,14 +747,15 @@ pub extern "C" fn tcmb_evds_c_get_data_group(
743
747
///
744
748
///
745
749
/// // handling error and printing the result.
746
- /// if (categories.error_type == NoError) { printf("\nNO ERROR!\n"); };
747
- ///
748
- /// fwrite(categories.output_ptr, categories.string_capacity, 1, stdout);
749
- ///
750
+ /// if (!tcmb_evds_c_is_error(categories)) { printf("\nNO ERROR!\n"); };
750
751
/// printf("\nError: %s", tcmb_evds_c_is_error(categories) ? "true" : "false");
752
+ ///
753
+ /// char* categories_message = calloc(categories.string_capacity, sizeof(char));
754
+ /// memmove(categories_message, categories.output_ptr, categories.string_capacity * sizeof(char));
755
+ ///
756
+ /// printf("%s", categories_message);
751
757
///
752
- ///
753
- /// free(categories.output_ptr);
758
+ /// free(categories_message);
754
759
///
755
760
/// return 0;
756
761
/// }
@@ -815,19 +820,30 @@ pub extern "C" fn tcmb_evds_c_get_categories(
815
820
///
816
821
///
817
822
/// // requesting data.
818
- /// TcmbEvdsResult advanced_data_group = tcmb_evds_c_get_advanced_data_group(mode, code, api_key, return_format, ascii_mode);
823
+ /// TcmbEvdsResult advanced_data_group =
824
+ /// tcmb_evds_c_get_advanced_data_group(
825
+ /// mode,
826
+ /// code,
827
+ /// api_key,
828
+ /// return_format,
829
+ /// ascii_mode
830
+ /// );
819
831
///
820
832
///
821
833
/// // handling error and printing the result.
822
- /// if (advanced_data_group.error_type == NoError) { printf("\nNO ERROR!\n"); };
823
- ///
824
- /// fwrite(advanced_data_group.output_ptr, advanced_data_group.string_capacity, 1, stdout);
825
- /// fflush(stdout);
826
- ///
834
+ /// if (!tcmb_evds_c_is_error(advanced_data_group)) { printf("\nNO ERROR!\n"); };
827
835
/// printf("\nError: %s", tcmb_evds_c_is_error(advanced_data_group) ? "true" : "false");
836
+ ///
837
+ /// char* advanced_data_group_message = calloc(advanced_data_group.string_capacity, sizeof(char));
838
+ /// memmove(
839
+ /// advanced_data_group_message,
840
+ /// advanced_data_group.output_ptr,
841
+ /// advanced_data_group.string_capacity * sizeof(char)
842
+ /// );
843
+ ///
844
+ /// printf("%s", advanced_data_group_message);
828
845
///
829
- ///
830
- /// free(advanced_data_group.output_ptr);
846
+ /// free(advanced_data_group_message);
831
847
///
832
848
/// return 0;
833
849
/// }
@@ -902,15 +918,15 @@ pub extern "C" fn tcmb_evds_c_get_advanced_data_group(
902
918
///
903
919
///
904
920
/// // handling error and printing the result.
905
- /// if (series_list.error_type == NoError) { printf("\nNO ERROR!\n"); };
906
- ///
907
- /// fwrite(series_list.output_ptr, series_list.string_capacity, 1, stdout);
908
- /// fflush(stdout);
909
- ///
921
+ /// if (!tcmb_evds_c_is_error(series_list)) { printf("\nNO ERROR!\n"); };
910
922
/// printf("\nError: %s", tcmb_evds_c_is_error(series_list) ? "true" : "false");
923
+ ///
924
+ /// char* series_list_message = calloc(series_list.string_capacity, sizeof(char));
925
+ /// memmove(series_list_message, series_list.output_ptr, series_list.string_capacity * sizeof(char));
926
+ ///
927
+ /// printf("%s", series_list_message);
911
928
///
912
- ///
913
- /// free(series_list.output_ptr);
929
+ /// free(series_list_message);
914
930
///
915
931
/// return 0;
916
932
/// }
@@ -956,9 +972,6 @@ pub extern "C" fn tcmb_evds_c_get_series_list(
956
972
///
957
973
/// // handling error.
958
974
/// printf("\nError: %s", tcmb_evds_c_is_error(series_list) ? "true" : "false");
959
- ///
960
- ///
961
- /// free(series_list.output_ptr);
962
975
/// ```
963
976
#[ no_mangle]
964
977
pub extern "C" fn tcmb_evds_c_is_error ( result : TcmbEvdsResult ) -> bool {
0 commit comments