bakaid commented on a change in pull request #613: Minificpp 927 Nanofi tailfile delimited processor URL: https://github.com/apache/nifi-minifi-cpp/pull/613#discussion_r303881650
########## File path: nanofi/src/core/flowfiles.c ########## @@ -0,0 +1,98 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "api/nanofi.h" +#include "core/flowfiles.h" + +#include "utlist.h" +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +void add_flow_file_record(flow_file_list ** ff_list, flow_file_record * record) { + if (!record) return; + + struct flow_file_list * new_node = (struct flow_file_list *)malloc(sizeof(struct flow_file_list)); + new_node->ff_record = record; + LL_APPEND(*ff_list, new_node); +} + +void free_flow_file_list(flow_file_list ** ff_list) { + if (!*ff_list) return; + flow_file_list * el = NULL; + LL_FOREACH(*ff_list, el) { + if (el) { + free_flowfile(el->ff_record); + } + } +} + +flow_file_record * write_to_flow_file(char * buff, nifi_instance * instance, standalone_processor * proc) { Review comment: Since you are not modifying `buff`, it can be `const char*`. Having this interface (buff being a C string) prevents us from tailing files containing the `\0` character. In case of textual input, this should not be a problem, but in the case of chunked transfer I can imagine a use case where the users want to do it on a binary file. I think it might be worth considering moving this to a `const char* buff, size_t buff_size` interface, but it is not critical. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
