nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [nifi-minifi-cpp] bakaid commented on a change in pull request #613: Minificpp 927 Nanofi tailfile delimited processor
Date Wed, 17 Jul 2019 09:42:08 GMT
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_r304282476
 
 

 ##########
 File path: nanofi/ecu/tailfile_chunk.c
 ##########
 @@ -0,0 +1,105 @@
+/*
+ * 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/ecu.h"
+#include "core/flowfiles.h"
+#include <unistd.h>
+#include <errno.h>
+#include <limits.h>
+#include <signal.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+int main(int argc, char** argv) {
+
+    if (argc < 6) {
+        printf("Error: must run ./tailfile_chunk <file> <interval> <chunksize>
<nifi instance url> <remote port>\n");
+        exit(1);
+    }
+
+    char * file = argv[1];
+    char * interval = argv[2];
+    char * chunksize = argv[3];
+    char * instance_str = argv[4];
+    char * port_str = argv[5];
+
+    if (access(file, F_OK) == -1) {
+        printf("Error: %s doesn't exist!\n", file);
+        exit(1);
+    }
+
+    struct stat stats;
+    errno = 0;
+    int ret = stat(file, &stats);
+
+    if (ret == -1) {
+        printf("Error occurred while getting file status {file: %s, error: %s}\n", file,
strerror(errno));
+        exit(1);
+    }
+    // Check for file existence
+    if (S_ISDIR(stats.st_mode)){
+        printf("Error: %s is a directory!\n", file);
+        exit(1);
+    }
+
+    errno = 0;
+    unsigned long intrvl = strtol(interval, NULL, 10);
 
 Review comment:
   This (and all other similar instances) should be rewritten to `strtoul` like it was in
`nanofi/src/api/ecu.c`

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message