Hi,
I am trying to wrote a wrapper for UCI library calls for changing wireless configuration.
This is my wrapper .c file
#include <stdio.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <uci.h>
void main ()
{
printf ("You are in UCI API APPLICATION FILE\n");
char path[]="wireless.@wifi-iface[0].mode";
char buffer[80];
struct uci_ptr ptr;
struct uci_context *c = uci_alloc_context();
if(!c) return;
if ((uci_lookup_ptr(c, &ptr, path, true) != UCI_OK) ||
(ptr.o==NULL || ptr.o->v.string==NULL))
{
uci_free_context(c);
return;
}
if(ptr.flags & UCI_LOOKUP_COMPLETE)
strcpy(buffer, ptr.o->v.string);
printf("%s\n", buffer);
// setting UCI values
// -----------------------------------------------------------
// this will set the value to 1234
ptr.value = "1234";
if ((uci_set(c, &ptr) != UCI_OK) ||
(ptr.o == NULL || ptr.o->v.string == NULL ))
{
uci_free_context(c);
return;
}
// commit your changes to make sure that UCI values are saved
if (uci_commit(c, &ptr.p, false) != UCI_OK)
{
uci_free_context(c);
uci_perror(c,"UCI Error");
return;
}
uci_free_context(c);
return;
}
#ifdef __cplusplus
}
#endif
My changes are getting reflected in file but how to apply those changes.
Please can anyone help me in this.
Thanks in advance.