M7350v7_en_gpl

This commit is contained in:
T
2024-09-09 08:59:52 +00:00
parent f75098198c
commit 46ba6f09ec
1372 changed files with 1231198 additions and 1184 deletions

View File

@ -0,0 +1,25 @@
LOCAL_PATH := $(call my-dir)
#########################
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := webs.c
LOCAL_MODULE := webs
LOCAL_CFLAGS := -Os -Wall $(CFLAGS) #-DCONFIG_NEW_SCRIPT
LOCAL_C_INCLUDES:=$(LOCAL_PATH)/../include
include $(BUILD_EXECUTABLE)
#########################
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := flash.c
LOCAL_MODULE := flash
LOCAL_CFLAGS := -Os -Wall $(CFLAGS)
LOCAL_C_INCLUDES:=$(LOCAL_PATH)/../include
include $(BUILD_EXECUTABLE)

View File

@ -0,0 +1,31 @@
INCS = -I$(TOP_USERS_DIR)/include
CFLAGS := -Os -Wall $(CFLAGS) $(INCS)
LDFLAGS += -g -s
#CC = $(CROSS_COMPILE)gcc
#AR = $(CROSS_COMPILE)ar
CFLAGS += -DCONFIG_IEEE80211W
#CFLAGS += -DCONFIG_NEW_SCRIPT
all: webs flash
webs: webs.o
$(CC) -o $@ $^ $(LDFLAGS)
cp -p ./webs ../bin/
flash: flash.o
$(CC) -o $@ $^ $(LDFLAGS)
cp -p ./flash ../bin/
clean:
rm -f *.o webs flash

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,121 @@
/*
*/
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/stat.h>
#include "rtk_arch.h"
static int isDaemon=0;
static char *pidfile=(TOP_CONFIG_DIR "/run/webs.pid");
#define REINIT_WEB_FILE (WIFI_WPS_TMP_DIR "/reinit_web")
void get_wifi_script_dir(char *path, size_t size)
{
FILE *fp;
char *pstr;
struct stat statbuf;
int len = 0;
fp = fopen(WIFI_CONFIG_ROOT_DIR "/wifi_script_dir", "r");
if (fp) {
pstr = fgets(path, size, fp);
fclose(fp);
if (pstr) {
len = strlen(path);
if ((len > 0) && ('\n' == path[len-1])) {
--len;
path[len] = '\0';
}
if (stat(path, &statbuf) == -1) { // dir not exist
len = 0;
}
}
}
if (0 == len) {
strncpy(path, WIFI_SCRIPT_DIR, size);
}
}
void sigHandler_autoconf(int signo)
{
char tmpbuf[256]={0};
struct stat status;
int reinit=1;
printf("<<Got Sig and Will Check Do init.sh:%d>>\n",signo);
if (stat(REINIT_WEB_FILE, &status) == 0) { // file existed
unlink(REINIT_WEB_FILE);
reinit = 0;
}
if (reinit) { // re-init system
printf("<<Got Sig and Do init.sh>>\n");
#ifdef CONFIG_NEW_SCRIPT
get_wifi_script_dir(tmpbuf, sizeof(tmpbuf));
strncat(tmpbuf, "/../my_test.sh wps_restart", sizeof(tmpbuf)-strlen(tmpbuf)-1);
#else
get_wifi_script_dir(tmpbuf, sizeof(tmpbuf));
strncat(tmpbuf, "/init.sh", sizeof(tmpbuf)-strlen(tmpbuf)-1);
#endif
system(tmpbuf);
}
}
void init_signals(void)
{
struct sigaction sa;
sa.sa_flags = SA_NODEFER;
sigemptyset(&sa.sa_mask);
sa.sa_handler = sigHandler_autoconf;
sigaction(SIGUSR1, &sa, NULL);
//sigaction(SIGTERM, &sa, NULL);
}
int main(int argc, char *argv[])
{
int i;
char line[20];
FILE *fp;
for(i=1; i<argc; i++)
{
if(argv[i][0]!='-')
{
fprintf(stderr, "%s: Unknown option\n", argv[i]);
}
else switch(argv[i][1])
{
case 'x':
isDaemon = 1;
break;
default:
fprintf(stderr, "%s: Unknown option\n", argv[i]);
}
}
if(isDaemon==1){
if (daemon(0, 1) == -1) {
perror("webs fork error");
return 0;
}
}
init_signals();
setsid();
sprintf(line, "%d\n", getpid());
if ((fp = fopen(pidfile, "w")) == NULL) {
printf("open file error:%s\n",pidfile);
return -1;
}
fwrite(line, strlen(line), 1, fp);
fclose(fp);
for (;;) {
sleep(5);
}
return 0;
}