| 886 | } |
| 887 | |
| 888 | static inline int |
| 889 | process_file_args(const char *key, const char *value, void *extra_args) |
| 890 | { |
| 891 | ARK_PMD_LOG(DEBUG, "key = %s, value = %s\n", |
| 892 | key, value); |
| 893 | char *args = (char *)extra_args; |
| 894 | |
| 895 | /* Open the configuration file */ |
| 896 | FILE *file = fopen(value, "r"); |
| 897 | char line[ARK_MAX_ARG_LEN]; |
| 898 | int size = 0; |
| 899 | int first = 1; |
| 900 | |
| 901 | if (file == NULL) { |
| 902 | ARK_PMD_LOG(ERR, "Unable to open " |
| 903 | "config file %s\n", value); |
| 904 | return -1; |
| 905 | } |
| 906 | |
| 907 | while (fgets(line, sizeof(line), file)) { |
| 908 | size += strlen(line); |
| 909 | if (size >= ARK_MAX_ARG_LEN) { |
| 910 | ARK_PMD_LOG(ERR, "Unable to parse file %s args, " |
| 911 | "parameter list is too long\n", value); |
| 912 | fclose(file); |
| 913 | return -1; |
| 914 | } |
| 915 | if (first) { |
| 916 | strncpy(args, line, ARK_MAX_ARG_LEN); |
| 917 | first = 0; |
| 918 | } else { |
| 919 | strncat(args, line, ARK_MAX_ARG_LEN); |
| 920 | } |
| 921 | } |
| 922 | ARK_PMD_LOG(DEBUG, "file = %s\n", args); |
| 923 | fclose(file); |
| 924 | return 0; |
| 925 | } |
| 926 | |
| 927 | static int |
| 928 | eth_ark_check_args(struct ark_adapter *ark, const char *params) |