Skip to content

Commit

Permalink
You can now back out of entering network details and cancel joining a…
Browse files Browse the repository at this point in the history
… network
  • Loading branch information
Root User committed Apr 28, 2020
1 parent 9907a41 commit d5f11b6
Show file tree
Hide file tree
Showing 51 changed files with 1,570 additions and 512 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
VERSION=1.0
VERSION=1.2
CC=gcc
LIBS= -lUseful -lz -lcrypto -lssl
LIBS= libUseful-4/libUseful.a
FLAGS=-g -O2 -DVERSION=\"$(VERSION)\"

OBJ=common.o net.o runcommand.o iw.o wireless_tools.o wpa_supplicant.o wifi.o interactive.o settings.o

all: $(OBJ)
all: $(OBJ) libUseful-4/libUseful.a
$(CC) $(FLAGS) -oterm_wifi $(OBJ) main.c $(LIBS)

libUseful-4/libUseful.a:
Expand Down
51 changes: 12 additions & 39 deletions config.log
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ running configure, to aid debugging if configure makes a mistake.
It was created by configure, which was
generated by GNU Autoconf 2.69. Invocation command line was

$ ./configure -with-system-libuseful --enable-ssl
$ ./configure

## --------- ##
## Platform. ##
## --------- ##

hostname = DEFAULT
hostname = DellM6400
uname -m = x86_64
uname -r = 5.1.15-64
uname -r = 5.6.5-64
uname -s = Linux
uname -v = #1 SMP Mon Jul 1 14:00:23 BST 2019
uname -v = #6 SMP Sun Apr 19 22:31:45 BST 2020

/usr/bin/uname -p = unknown
/bin/uname -X = unknown
Expand Down Expand Up @@ -69,7 +69,7 @@ PATH: /opt/rust-1.36.0/bin
PATH: /opt/sound-studio/bin
PATH: /opt/tcl-8.6.9/bin
PATH: /opt/tiffprogs-4.0.8/bin
PATH: /opt/wine-4.9/bin
PATH: /opt/wine-5.5/bin
PATH: /opt/xboinc_client-7.14.2/bin


Expand Down Expand Up @@ -252,26 +252,6 @@ configure: failed program was:
configure:3188: gcc -c -g -O2 conftest.c >&5
configure:3188: $? = 0
configure:3196: result: 64
configure:3291: checking for OpenSSLVerifyCallback in -lUseful
configure:3316: gcc -o conftest -g -O2 conftest.c -lUseful -lssl -lcrypto -lz >&5
configure:3316: $? = 0
configure:3325: result: yes
configure:3328: checking for SSL_new in -lssl
configure:3353: gcc -o conftest -g -O2 conftest.c -lssl -lcrypto -lz >&5
configure:3353: $? = 0
configure:3362: result: yes
configure:3373: checking for ERR_load_CRYPTO_strings in -lcrypto
configure:3398: gcc -o conftest -g -O2 conftest.c -lcrypto -lz -lssl >&5
configure:3398: $? = 0
configure:3407: result: yes
configure:3418: checking for inflate in -lz
configure:3443: gcc -o conftest -g -O2 conftest.c -lz -lcrypto -lssl >&5
configure:3443: $? = 0
configure:3452: result: yes
configure:3466: checking for GetToken in -lUseful
configure:3491: gcc -o conftest -g -O2 conftest.c -lUseful -lz -lcrypto -lssl >&5
configure:3491: $? = 0
configure:3500: result: yes
configure:3705: creating ./config.status

## ---------------------- ##
Expand All @@ -287,9 +267,11 @@ generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_COMMANDS =
$ ./config.status

on DEFAULT
on DellM6400

config.status:725: creating Makefile
configure:4776: === configuring in libUseful-4 (/home/colum/work/term_wifi/libUseful-4)
configure:4839: running /bin/sh ./configure --disable-option-checking '--prefix=/usr/local' --cache-file=/dev/null --srcdir=.

## ---------------- ##
## Cache variables. ##
Expand All @@ -315,11 +297,6 @@ ac_cv_env_host_alias_value=
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_header_stdc=yes
ac_cv_lib_Useful_GetToken=yes
ac_cv_lib_Useful_OpenSSLVerifyCallback=yes
ac_cv_lib_crypto_ERR_load_CRYPTO_strings=yes
ac_cv_lib_ssl_SSL_new=yes
ac_cv_lib_z_inflate=yes
ac_cv_objext=o
ac_cv_path_EGREP='/bin/grep -E'
ac_cv_path_GREP=/bin/grep
Expand All @@ -339,7 +316,7 @@ CC='gcc'
CFLAGS='-g -O2'
CPP='gcc -E'
CPPFLAGS=''
DEFS='-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -D_FILE_OFFSET_BITS=64 -DHAVE_LIBSSL=1 -DHAVE_LIBCRYPTO=1 -DHAVE_LIBZ=1 -DHAVE_LIBUSEFUL=1'
DEFS='-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -D_FILE_OFFSET_BITS=64'
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
Expand All @@ -348,7 +325,7 @@ EXEEXT=''
GREP='/bin/grep'
LDFLAGS=''
LIBOBJS=''
LIBS='-lUseful -lz -lcrypto -lssl '
LIBS=''
LTLIBOBJS=''
OBJEXT='o'
PACKAGE_BUGREPORT=''
Expand All @@ -360,7 +337,7 @@ PACKAGE_VERSION=''
PATH_SEPARATOR=':'
SET_MAKE=''
SHELL='/bin/sh'
STATIC_LIBS=''
STATIC_LIBS='libUseful-4/libUseful.a'
ac_ct_CC='gcc'
bindir='${exec_prefix}/bin'
build_alias=''
Expand All @@ -385,7 +362,7 @@ program_transform_name='s,x,x,'
psdir='${docdir}'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
subdirs=''
subdirs=' libUseful-4'
sysconfdir='${prefix}/etc'
target_alias=''

Expand All @@ -402,9 +379,5 @@ target_alias=''
#define PACKAGE_URL ""
#define STDC_HEADERS 1
#define _FILE_OFFSET_BITS 64
#define HAVE_LIBSSL 1
#define HAVE_LIBCRYPTO 1
#define HAVE_LIBZ 1
#define HAVE_LIBUSEFUL 1

configure: exit 0
14 changes: 7 additions & 7 deletions config.status
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ $config_files
Report bugs to the package provider."

ac_cs_config="'-with-system-libuseful' '--enable-ssl'"
ac_cs_config=""
ac_cs_version="\
config.status
configured by ./configure, generated by GNU Autoconf 2.69,
Expand All @@ -427,7 +427,7 @@ Copyright (C) 2012 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."

ac_pwd='/home/colum/term_wifi'
ac_pwd='/home/colum/work/term_wifi'
srcdir='.'
test -n "$AWK" || AWK=awk
# The default lists apply if the user does not specify any file.
Expand Down Expand Up @@ -495,7 +495,7 @@ if $ac_cs_silent; then
fi

if $ac_cs_recheck; then
set X /bin/sh './configure' '-with-system-libuseful' '--enable-ssl' $ac_configure_extra_args --no-create --no-recursion
set X /bin/sh './configure' $ac_configure_extra_args --no-create --no-recursion
shift
$as_echo "running CONFIG_SHELL=/bin/sh $*" >&6
CONFIG_SHELL='/bin/sh'
Expand Down Expand Up @@ -583,8 +583,8 @@ echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
cat >>"$ac_tmp/subs1.awk" <<\_ACAWK &&
S["LTLIBOBJS"]=""
S["LIBOBJS"]=""
S["subdirs"]=""
S["STATIC_LIBS"]=""
S["subdirs"]=" libUseful-4"
S["STATIC_LIBS"]="libUseful-4/libUseful.a"
S["EGREP"]="/bin/grep -E"
S["GREP"]="/bin/grep"
S["CPP"]="gcc -E"
Expand All @@ -599,12 +599,12 @@ S["CC"]="gcc"
S["target_alias"]=""
S["host_alias"]=""
S["build_alias"]=""
S["LIBS"]="-lUseful -lz -lcrypto -lssl "
S["LIBS"]=""
S["ECHO_T"]=""
S["ECHO_N"]="-n"
S["ECHO_C"]=""
S["DEFS"]="-DPACKAGE_NAME=\\\"\\\" -DPACKAGE_TARNAME=\\\"\\\" -DPACKAGE_VERSION=\\\"\\\" -DPACKAGE_STRING=\\\"\\\" -DPACKAGE_BUGREPORT=\\\"\\\" -DPACKAGE_URL=\\\"\\\" -DSTDC_HEADERS=1"\
" -D_FILE_OFFSET_BITS=64 -DHAVE_LIBSSL=1 -DHAVE_LIBCRYPTO=1 -DHAVE_LIBZ=1 -DHAVE_LIBUSEFUL=1"
" -D_FILE_OFFSET_BITS=64"
S["mandir"]="${datarootdir}/man"
S["localedir"]="${datarootdir}/locale"
S["libdir"]="${exec_prefix}/lib"
Expand Down
82 changes: 70 additions & 12 deletions interactive.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,44 +87,91 @@ NetDestroy(Net);
}


void InteractiveQueryNetConfig(TNetDev *Dev, TNet *Net)
int InteractiveQueryNetConfig(TNetDev *Dev, TNet *Net)
{
char *Tempstr=NULL;

TerminalClear(StdIO);
TerminalCursorMove(StdIO, 0, 0);
TerminalPutStr("~M~w Please enter config for wireless network~>~0", StdIO);
TerminalPutStr("~M~w Please enter config for wireless network~>~0\n", StdIO);
TerminalPutStr("~e Double-escape to cancel and return to network select~0\n\n", StdIO);

TerminalCursorMove(StdIO, 0, 2);

if (Net->Flags & NET_ENCRYPTED)
{

Net->UserID=TerminalReadPrompt(Net->UserID, "Username (blank for none): ", 0, StdIO);
if (Net->UserID==NULL)
{
TerminalClear(StdIO);
Destroy(Tempstr);
return(FALSE);
}

StripCRLF(Net->UserID);
TerminalPutStr("\n", StdIO);


Net->Key=TerminalReadPrompt(Net->Key, "Key/password: ", 0, StdIO);
StripCRLF(Net->Key);
if (Net->Key==NULL)
{
TerminalClear(StdIO);
Destroy(Tempstr);
return(FALSE);
}


StripCRLF(Net->Key);
TerminalPutStr("\n", StdIO);
}



Net->Address=TerminalReadPrompt(Net->Address, "Address (blank for DHCP): ", 0, StdIO);
if (Net->Address==NULL)
{
TerminalClear(StdIO);
Destroy(Tempstr);
return(FALSE);
}

StripCRLF(Net->Address);
TerminalPutStr("\n", StdIO);

if (StrValid(Net->Address))
{
TerminalPutStr("\n", StdIO);

Net->Netmask=TerminalReadPrompt(Net->Netmask, "Netmask: ", 0, StdIO);
if (Net->Netmask==NULL)
{
TerminalClear(StdIO);
Destroy(Tempstr);
return(FALSE);
}

StripCRLF(Net->Netmask);

TerminalPutStr("\n", StdIO);

Net->Gateway=TerminalReadPrompt(Net->Gateway, "Gateway: ", 0, StdIO);
StripCRLF(Net->Gateway);
if (Net->Gateway==NULL)
{
TerminalClear(StdIO);
Destroy(Tempstr);
return(FALSE);
}

StripCRLF(Net->Gateway);
TerminalPutStr("\n", StdIO);

Net->DNSServer=TerminalReadPrompt(Net->DNSServer, "DNS Server: ", 0, StdIO);
if (Net->DNSServer==NULL)
{
TerminalClear(StdIO);
Destroy(Tempstr);
return(FALSE);
}

StripCRLF(Net->DNSServer);
}
else Net->Address=CopyStr(Net->Address, "dhcp");
Expand All @@ -133,6 +180,12 @@ else Net->Address=CopyStr(Net->Address, "dhcp");
TerminalPutStr("\n", StdIO);
TerminalPutStr("\n", StdIO);
Tempstr=TerminalReadPrompt(Tempstr, "Save for future use? Y/n: ", 0, StdIO);
if (Tempstr==NULL)
{
TerminalClear(StdIO);
return(FALSE);
}

StripLeadingWhitespace(Tempstr);
StripTrailingWhitespace(Tempstr);

Expand All @@ -141,13 +194,21 @@ if (StrValid(Tempstr) && (tolower(Tempstr[0])=='y') ) SettingsSaveNet(Net);

TerminalClear(StdIO);
Destroy(Tempstr);

return(TRUE);
}



void InteractiveJoinNetwork(TNetDev *Dev, TNet *Conf, STREAM *Out)
{
TNet *Net;

if (! StrValid(Conf->Address))
{
if (! InteractiveQueryNetConfig(Dev, Conf)) return;
}

Net=(TNet *) calloc(1, sizeof(TNet));

InteractiveTitleBar(Dev, "~M~w joining network");
Expand Down Expand Up @@ -238,14 +299,11 @@ while (1)
Net=(TNet *) Curr->Item;

SettingsConfigureNet(Net);
if (! StrValid(Net->Address))
{
InteractiveQueryNetConfig(Dev, Net);
InteractiveWifiMenuUpdate(Menu);
TerminalMenuDraw(Menu);
}

InteractiveJoinNetwork(Dev, Net, StdIO);
InteractiveWifiMenuUpdate(Menu);
TerminalMenuDraw(Menu);

}
}
}
Expand Down
9 changes: 9 additions & 0 deletions libUseful-4/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: c

os:
- linux
- osx

compiler:
- clang
- gcc
32 changes: 32 additions & 0 deletions libUseful-4/Array.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "includes.h"
#include "Array.h"

void **ArrayAdd(void **Array, void *Item)
{
void *ptr;
int count=0;

if (! Array) Array=calloc(10, sizeof(void *));
else
{
for (ptr=*Array; ptr !=NULL; ptr++)
{
count++;
}
}

Array=realloc(Array, (count+10) * sizeof(void *));
Array[count]=Item;
Array[count+1]=NULL;
return(Array);
}


void ArrayDestroy(void **Array, ARRAY_ITEM_DESTROY_FUNC DestroyFunc)
{
void **ptr;

for (ptr=Array; *ptr != NULL; ptr++) DestroyFunc(*ptr);
if (Array != NULL) free(Array);
}

Loading

0 comments on commit d5f11b6

Please sign in to comment.