void ethpanel_free(eth_panel** pnl) { if(pnl && *pnl) { EXALT_FREE((*pnl)->interface); EXALT_FREE(*pnl); } }
/** * @brief Load the configuration of an interface from the configuration file * @param file the configuration file * @param udi the hal udi of the interface * @return Returns the state */ Exalt_Connection* exalt_eth_conn_load(const char* file, const char* udi) { Exalt_Eth_Save *s = _exalt_eet_eth_load(file, udi); EXALT_ASSERT_RETURN(s!=NULL); Exalt_Connection *c = s->connection; EXALT_FREE(s->driver); EXALT_FREE(s); return c; }
/** * @brief free the dns list * @param t the dns list * @param nb_dns the number of dns */ void exalt_dns_free_list(char** t, int nb_dns) { int i; if(!t) { fprintf(stderr,"dns_free_list(): t == null !\n"); } for(i=0;i<nb_dns;i++) EXALT_FREE(t[i]); EXALT_FREE(t); }
/** * @brief Load the state (up/down) of an interface from the configuration file * @param file the configuration file * @param udi the hal udi of the interface * @return Returns the state */ Exalt_Enum_State exalt_eth_state_load(const char* file, const char* udi) { Exalt_Eth_Save *s = _exalt_eet_eth_load(file, udi); EXALT_ASSERT_RETURN(s!=NULL); Exalt_Enum_State st = s->state; EXALT_FREE(s->driver); exalt_conn_free(s->connection); EXALT_FREE(s); return st; }
/* * @brief execute a regular expression * @param r the Exalt_Regex * @return Return 1 if the regular expression is found int the request string, else 0 */ int exalt_regex_execute(Exalt_Regex* r) { int err; regex_t preg; int nmatch; int match; regmatch_t *pmatch = NULL; if(r==NULL) return -1; exalt_regex_clear_result(r); err = regcomp (&preg, r->str_regex, REG_EXTENDED); if (err != 0) return 0; nmatch = preg.re_nsub + 1; pmatch = (regmatch_t*)malloc (sizeof (regmatch_t) * nmatch); if (pmatch) { match = regexec (&preg, r->str_request, nmatch, pmatch, 0); r->nmatch = nmatch; regfree (&preg); if (match == 0) { unsigned int i ; r->res = (char**)malloc(sizeof(char*) * r->nmatch); for(i=0;i<r->nmatch;i++) { int start = pmatch[i].rm_so; int end = pmatch[i].rm_eo; size_t size = end - start; r->res[i] = (char*)malloc (sizeof (char) * (size + 1)); EXALT_ASSERT_ADV(r->res[i],EXALT_FREE(pmatch);return 0,"r->res[i] failed"); strncpy (r->res[i], &(r->str_request[start]), size); r->res[i][size] = '\0'; } EXALT_FREE(pmatch); return 1; } else if (match == REG_NOMATCH)
/** * @brief Load the driver of an <ireless interface from the configuration file * @param file the configuration file * @param udi the hal udi of the interface * @return Returns the state */ char* exalt_eth_driver_load(const char* file, const char* udi) { Exalt_Eth_Save *s = _exalt_eet_eth_load(file, udi); EXALT_ASSERT_RETURN(s!=NULL); char* driver = s->driver; exalt_conn_free(s->connection); EXALT_FREE(s); return driver; }
void generalpanel_free(general_panel** pnl) { if(pnl && *pnl) { dnspanel_free(&(*pnl)->dns); bootpanel_free(&(*pnl)->boot); aboutpanel_free(&(*pnl)->about); EXALT_FREE(*pnl); } }
void waiting_iface_free(Boot_Process_List** l) { EXALT_ASSERT_RETURN_VOID(l!=NULL); EXALT_ASSERT_RETURN_VOID((*l)!=NULL); //evas_list_free() doesn't free the data, we free them { Evas_List* levas = (*l)->l; while(levas) { Boot_Process_Elt* data = evas_list_data(levas); EXALT_FREE(data->interface); EXALT_FREE(data); levas = evas_list_next(levas); } } evas_list_free((*l)->l); EXALT_FREE(*l); }
void ethpanel_set_eth(eth_panel* pnl, char* interface) { char name[100]; char *str; EXALT_ASSERT_RETURN_VOID(pnl!=NULL); EXALT_ASSERT_RETURN_VOID(interface!=NULL); sprintf(name,_("Network card: %s"),interface); EXALT_FREE(pnl->interface); pnl->interface = strdup(interface); ewl_border_label_set(EWL_BORDER(pnl->frame),name); str = exalt_dbus_eth_get_ip(exalt_conn,interface); ewl_text_text_set(EWL_TEXT(pnl->entry_ip),str); EXALT_FREE(str); str = exalt_dbus_eth_get_netmask(exalt_conn, interface); ewl_text_text_set(EWL_TEXT(pnl->entry_mask),str); EXALT_FREE(str); str = exalt_dbus_eth_get_gateway(exalt_conn, interface); ewl_text_text_set(EWL_TEXT(pnl->entry_gateway),str); EXALT_FREE(str); if(exalt_dbus_eth_is_dhcp(exalt_conn, interface)) ewl_radiobutton_checked_set(EWL_RADIOBUTTON(pnl->check_dhcp), TRUE); else ewl_radiobutton_checked_set(EWL_RADIOBUTTON(pnl->check_static), TRUE); str = exalt_dbus_eth_get_cmd(exalt_conn, interface); ewl_text_text_set(EWL_TEXT(pnl->entry_cmd),str); EXALT_FREE(str); ethpanel_disabled_set(pnl); }
void exalt_conf_free(Exalt_Configuration** conf) { Exalt_Configuration *c; EXALT_ASSERT_RETURN_VOID(conf!=NULL); c = *conf; EXALT_ASSERT_RETURN_VOID(c!=NULL); eina_stringshare_del(c->ip); eina_stringshare_del(c->gateway); eina_stringshare_del(c->netmask); eina_stringshare_del(c->cmd_after_apply); exalt_conf_network_free( &( c->network)); EXALT_FREE(c); }
void bootpanel_free(boot_panel** pnl) { if(pnl) EXALT_FREE(*pnl); }
int exalt_eth_save_autoload(exalt_ethernet* eth) { FILE* fr,*fw; char buf[1024]; char regexp[1024]; char* res = NULL; exalt_regex * r; if(!eth) { fprintf(stderr,"exalt_eth_save_autoload(): eth==null ! \n"); return -1; } if(!exalt_eth_save_file_exist(CONF_FILE)) if(exalt_eth_save_file_create(CONF_FILE,NULL)==-1) { fprintf(stderr,"exalt_eth_save_autoload(): error can't create the file! \n"); return -1; } exalt_eth_save_file_create(FILE_TEMP,NULL); //copy the conf file in the temp file fw = fopen(FILE_TEMP,"w"); fr = fopen(CONF_FILE,"r"); while(fgets(buf,1024,fr)) fprintf(fw,buf); fclose(fw); fclose(fr); //remove the current autoload for this card if it is present fr = fopen(FILE_TEMP,"r"); fw = fopen(CONF_FILE,"w"); sprintf(regexp,REGEXP_SAVE_DEBIAN_IS_AUTO_ETH, exalt_eth_get_name(eth)); r = exalt_regex_create("",regexp,0); while(fgets(buf,1024,fr)) { exalt_regex_set_request(r,buf); if( exalt_regex_execute(r) && r->nmatch>0 ) { res = str_remove(buf,exalt_eth_get_name(eth)); if(res) { exalt_regex_set_request(r,res); exalt_regex_set_regex(r,REGEXP_SAVE_DEBIAN_IS_AUTO_ALONE); if(!exalt_regex_execute(r)) fprintf(fw,res); EXALT_FREE(res) exalt_regex_set_regex(r,REGEXP_SAVE_DEBIAN_IS_AUTO_ETH); } } else fprintf(fw,buf); } if(exalt_eth_is_activate(eth)) fprintf(fw,"auto %s\n",exalt_eth_get_name(eth)); fclose(fw); fclose(fr); exalt_regex_free(&r); return 1; }
/** * @brief change the regular expression * @param r the Exalt_Regex * @param str_regex the new regular expression */ void exalt_regex_set_regex(Exalt_Regex* r,const char* str_regex) { EXALT_FREE(r->str_regex); r->str_regex = strdup(str_regex); }
/** * @brief change the request string * @param r the Exalt_Regex * @param str_request the new request string */ void exalt_regex_set_request(Exalt_Regex* r,const char* str_request) { EXALT_FREE(r->str_request); r->str_request = strdup(str_request); }