Merge pull request #9 from lakinduakash/dev-1

Add util.c
This commit is contained in:
Lakindu Akash 2019-04-16 02:49:10 +05:30 committed by GitHub
commit fe65be0722
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 16 deletions

View File

@ -10,7 +10,7 @@ include_directories(${X11_INCLUDE_DIRS})
set(CMAKE_C_STANDARD 99)
set (CMAKE_CXX_STANDARD 11)
add_executable(wihotspot ui/main.c ui/h_prop.c ui/h_prop.h ui/ui.c ui/ui.h ui/read_config.cpp ui/read_config.h)
add_executable(wihotspot ui/main.c ui/h_prop.c ui/h_prop.h ui/ui.c ui/ui.h ui/read_config.cpp ui/read_config.h ui/util.c ui/util.h)
target_link_libraries(${PROJECT_NAME} ${GTK_LIBRARIES} ${X11_LIBRARIES} config)

View File

@ -199,6 +199,10 @@
<object class="GtkProgressBar" id="progress_bar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">10</property>
<property name="margin_right">10</property>
<property name="margin_top">1</property>
<property name="margin_bottom">1</property>
<property name="pulse_step">0.20000000000000001</property>
</object>
<packing>

View File

@ -11,6 +11,7 @@
#include "h_prop.h"
#include "ui.h"
#include "read_config.h"
#include "util.h"
#define BUFSIZE 1024
#define AP_ENABLED "AP-ENABLED"
@ -282,19 +283,6 @@ void* init_running_info(){
return 0;
}
int find_str(char *find, const char **array, int length) {
int i;
for ( i = 0; i < length; i++ ) {
if (strcmp(array[i], find) == 0) {
return i;
}
}
return -1;
}
static void *run_create_hp_shell(void *cmd) {

View File

@ -20,8 +20,6 @@ static void* run_create_hp_shell(void *cmd);
void init_interface_list();
static int find_str(char *find, const char **array, int length);
void* init_running_info();
static gboolean update_progress_in_timeout (gpointer pbar);

20
src/ui/util.c Normal file
View File

@ -0,0 +1,20 @@
//
// Created by lakinduakash on 16/04/19.
//
#include <string.h>
#include "util.h"
int find_str(char *find, const char **array, int length) {
int i;
for ( i = 0; i < length; i++ ) {
if (strcmp(array[i], find) == 0) {
return i;
}
}
return -1;
}

10
src/ui/util.h Normal file
View File

@ -0,0 +1,10 @@
//
// Created by lakinduakash on 16/04/19.
//
#ifndef WIHOTSPOT_UTIL_H
#define WIHOTSPOT_UTIL_H
int find_str(char *find, const char **array, int length);
#endif //WIHOTSPOT_UTIL_H