mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-12 11:44:13 +02:00
Version19.263
This commit is contained in:
parent
623799d144
commit
f5334808b2
6
Makefile
6
Makefile
|
@ -47,9 +47,9 @@ OBJS = swad_account.o swad_action.o swad_agenda.o swad_alert.o \
|
||||||
swad_icon.o swad_ID.o swad_indicator.o swad_info.o swad_institution.o \
|
swad_icon.o swad_ID.o swad_indicator.o swad_info.o swad_institution.o \
|
||||||
swad_institution_config.o \
|
swad_institution_config.o \
|
||||||
swad_language.o swad_layout.o swad_link.o swad_log.o swad_logo.o \
|
swad_language.o swad_layout.o swad_link.o swad_log.o swad_logo.o \
|
||||||
swad_mail.o swad_main.o swad_maintenance.o swad_map.o swad_mark.o \
|
swad_MAC.o swad_mail.o swad_main.o swad_maintenance.o swad_map.o \
|
||||||
swad_match.o swad_match_print.o swad_match_result.o swad_media.o \
|
swad_mark.o swad_match.o swad_match_print.o swad_match_result.o \
|
||||||
swad_menu.o swad_message.o swad_MFU.o \
|
swad_media.o swad_menu.o swad_message.o swad_MFU.o \
|
||||||
swad_network.o swad_nickname.o swad_notice.o swad_notification.o \
|
swad_network.o swad_nickname.o swad_notice.o swad_notification.o \
|
||||||
swad_pagination.o swad_parameter.o swad_password.o swad_photo.o \
|
swad_pagination.o swad_parameter.o swad_password.o swad_photo.o \
|
||||||
swad_place.o swad_plugin.o swad_privacy.o swad_profile.o \
|
swad_place.o swad_plugin.o swad_privacy.o swad_profile.o \
|
||||||
|
|
225
swad_MAC.c
Normal file
225
swad_MAC.c
Normal file
|
@ -0,0 +1,225 @@
|
||||||
|
// swad_MAC.c: MAC addresses
|
||||||
|
|
||||||
|
/*
|
||||||
|
SWAD (Shared Workspace At a Distance),
|
||||||
|
is a web platform developed at the University of Granada (Spain),
|
||||||
|
and used to support university teaching.
|
||||||
|
|
||||||
|
This file is part of SWAD core.
|
||||||
|
Copyright (C) 1999-2020 Antonio Cañas Vargas
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********************************** Headers **********************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#include <stddef.h> // For NULL
|
||||||
|
|
||||||
|
#include "swad_action.h"
|
||||||
|
#include "swad_database.h"
|
||||||
|
#include "swad_form.h"
|
||||||
|
#include "swad_HTML.h"
|
||||||
|
#include "swad_parameter.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************** External global variables from others modules ****************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************************** Private constants *****************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#define MAC_NUM_BYTES 6
|
||||||
|
#define MAC_LENGTH_MAC_ADDRESS (MAC_NUM_BYTES * 3 - 1) // xx:xx:xx:xx:xx:xx
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************************* Private types *******************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/* Parameters used in forms to edit MAC address */
|
||||||
|
struct MAC_Params
|
||||||
|
{
|
||||||
|
long Cod; // Code (i.e. room code)
|
||||||
|
char MAC[MAC_LENGTH_MAC_ADDRESS + 1]; // MAC address
|
||||||
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************************** Private variables *****************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************************** Private prototypes ****************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void MAC_PutParams (void *Args);
|
||||||
|
static void MAC_PutFormToEditMACAddress (Act_Action_t NextAction,const char *Anchor,
|
||||||
|
void (*FuncParams) (void *Args),void *Args);
|
||||||
|
|
||||||
|
static void MAC_MACnumToMACstr (unsigned long long MACnum,char MACstr[MAC_LENGTH_MAC_ADDRESS + 1]);
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/**************** Put hidden parameters to edit a MAC address ****************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void MAC_PutParams (void *Args)
|
||||||
|
{
|
||||||
|
if (Args)
|
||||||
|
{
|
||||||
|
Par_PutHiddenParamLong (NULL,"Cod",((struct MAC_Params *) Args)->Cod);
|
||||||
|
Par_PutHiddenParamString (NULL,"MAC",((struct MAC_Params *) Args)->MAC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************************ Put form to edit a MAC address *********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void MAC_PutFormToEditMACAddress (Act_Action_t NextAction,const char *Anchor,
|
||||||
|
void (*FuncParams) (void *Args),void *Args)
|
||||||
|
{
|
||||||
|
/* Form to enter a new MAC address */
|
||||||
|
Frm_StartFormAnchor (NextAction,Anchor);
|
||||||
|
FuncParams (Args);
|
||||||
|
HTM_INPUT_TEXT ("NewMAC",MAC_LENGTH_MAC_ADDRESS,((struct MAC_Params *) Args)->MAC,
|
||||||
|
HTM_SUBMIT_ON_CHANGE,
|
||||||
|
"size=\"8\"");
|
||||||
|
Frm_EndForm ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************************ List several MAC addresses *************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void MAC_ListMACAddresses (unsigned NumMACs,MYSQL_RES **mysql_res)
|
||||||
|
{
|
||||||
|
MYSQL_ROW row;
|
||||||
|
unsigned NumMAC;
|
||||||
|
unsigned long long MACnum;
|
||||||
|
char MACstr[MAC_LENGTH_MAC_ADDRESS + 1];
|
||||||
|
|
||||||
|
/***** Write the MAC addresses *****/
|
||||||
|
for (NumMAC = 0;
|
||||||
|
NumMAC < NumMACs;
|
||||||
|
NumMAC++)
|
||||||
|
{
|
||||||
|
/* Get next MAC address */
|
||||||
|
row = mysql_fetch_row (*mysql_res);
|
||||||
|
|
||||||
|
/* Write break line */
|
||||||
|
if (NumMAC)
|
||||||
|
HTM_BR ();
|
||||||
|
|
||||||
|
/* Write MAC address (row[0]) */
|
||||||
|
if (sscanf (row[0],"%llu",&MACnum) == 1)
|
||||||
|
{
|
||||||
|
MAC_MACnumToMACstr (MACnum,MACstr);
|
||||||
|
HTM_Txt (MACstr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Free structure that stores the query result *****/
|
||||||
|
DB_FreeMySQLResult (mysql_res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************************ List several MAC addresses *************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void MAC_EditMACAddresses (long Cod,const char *Anchor,
|
||||||
|
unsigned NumMACs,MYSQL_RES **mysql_res)
|
||||||
|
{
|
||||||
|
MYSQL_ROW row;
|
||||||
|
unsigned NumMAC;
|
||||||
|
unsigned long long MACnum;
|
||||||
|
struct MAC_Params Params;
|
||||||
|
|
||||||
|
/***** Write the forms to enter the MAC addresses *****/
|
||||||
|
for (NumMAC = 0;
|
||||||
|
NumMAC < NumMACs;
|
||||||
|
NumMAC++)
|
||||||
|
{
|
||||||
|
/* Get next MAC address */
|
||||||
|
row = mysql_fetch_row (*mysql_res);
|
||||||
|
|
||||||
|
/* Write MAC address (row[0]) */
|
||||||
|
if (sscanf (row[0],"%llu",&MACnum) == 1)
|
||||||
|
{
|
||||||
|
Params.Cod = Cod; // Code (i.e. room code)
|
||||||
|
MAC_MACnumToMACstr (MACnum,Params.MAC); // Current MAC address
|
||||||
|
MAC_PutFormToEditMACAddress (ActChgRooMAC,Anchor,
|
||||||
|
MAC_PutParams,&Params);
|
||||||
|
|
||||||
|
/* Write break line */
|
||||||
|
HTM_BR ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Form to enter a new MAC address */
|
||||||
|
Params.Cod = Cod; // Code (i.e. room code)
|
||||||
|
Params.MAC[0] = '\0'; // Current MAC address
|
||||||
|
MAC_PutFormToEditMACAddress (ActChgRooMAC,Anchor,
|
||||||
|
MAC_PutParams,&Params);
|
||||||
|
|
||||||
|
/***** Free structure that stores the query result *****/
|
||||||
|
DB_FreeMySQLResult (mysql_res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/****************** Get MAC address as a number from a form ******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned long long MAC_GetMACnumFromForm (const char *ParamName)
|
||||||
|
{
|
||||||
|
char MACstr[MAC_LENGTH_MAC_ADDRESS * Str_MAX_BYTES_PER_CHAR + 1];
|
||||||
|
unsigned long long MAC[MAC_NUM_BYTES];
|
||||||
|
unsigned long long MACnum;
|
||||||
|
|
||||||
|
/***** Get parameter *****/
|
||||||
|
Par_GetParToText (ParamName,MACstr,MAC_LENGTH_MAC_ADDRESS * Str_MAX_BYTES_PER_CHAR);
|
||||||
|
|
||||||
|
if (MACstr[0]) // Not empty
|
||||||
|
{
|
||||||
|
/***** Try to scan it in xx:xx:xx:xx:xx:xx format (where x are hexadecimal digits) *****/
|
||||||
|
if (sscanf (MACstr,"%02llx:%02llx:%02llx:%02llx:%02llx:%02llx",
|
||||||
|
&MAC[0],&MAC[1],&MAC[2],&MAC[3],&MAC[4],&MAC[5]) == MAC_NUM_BYTES)
|
||||||
|
return (MAC[0] << (CHAR_BIT * 5)) +
|
||||||
|
(MAC[1] << (CHAR_BIT * 4)) +
|
||||||
|
(MAC[2] << (CHAR_BIT * 3)) +
|
||||||
|
(MAC[3] << (CHAR_BIT * 2)) +
|
||||||
|
(MAC[4] << (CHAR_BIT * 1)) +
|
||||||
|
(MAC[5] << (CHAR_BIT * 0));
|
||||||
|
|
||||||
|
/***** Try to scan it in xxxxxxxxxxxx format (where x are hexadecimal digits) ******/
|
||||||
|
if (sscanf (MACstr,"%llx",&MACnum) == 1)
|
||||||
|
return MACnum;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/**** Convert from MAC as a number to string in xx:xx:xx:xx:xx:xx format *****/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void MAC_MACnumToMACstr (unsigned long long MACnum,char MACstr[MAC_LENGTH_MAC_ADDRESS + 1])
|
||||||
|
{
|
||||||
|
snprintf (MACstr,MAC_LENGTH_MAC_ADDRESS + 1,"%02x:%02x:%02x:%02x:%02x:%02x",
|
||||||
|
(unsigned char) ((MACnum >> (CHAR_BIT * 5)) & ((1 << CHAR_BIT) - 1)),
|
||||||
|
(unsigned char) ((MACnum >> (CHAR_BIT * 4)) & ((1 << CHAR_BIT) - 1)),
|
||||||
|
(unsigned char) ((MACnum >> (CHAR_BIT * 3)) & ((1 << CHAR_BIT) - 1)),
|
||||||
|
(unsigned char) ((MACnum >> (CHAR_BIT * 2)) & ((1 << CHAR_BIT) - 1)),
|
||||||
|
(unsigned char) ((MACnum >> (CHAR_BIT * 1)) & ((1 << CHAR_BIT) - 1)),
|
||||||
|
(unsigned char) ((MACnum >> (CHAR_BIT * 0)) & ((1 << CHAR_BIT) - 1)));
|
||||||
|
}
|
44
swad_MAC.h
Normal file
44
swad_MAC.h
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
// swad_MAC.h: MAC addresses
|
||||||
|
|
||||||
|
#ifndef _SWAD_MAC
|
||||||
|
#define _SWAD_MAC
|
||||||
|
/*
|
||||||
|
SWAD (Shared Workspace At a Distance in Spanish),
|
||||||
|
is a web platform developed at the University of Granada (Spain),
|
||||||
|
and used to support university teaching.
|
||||||
|
|
||||||
|
This file is part of SWAD core.
|
||||||
|
Copyright (C) 1999-2020 Antonio Cañas Vargas
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********************************** Headers **********************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************************** Public types and constants ***********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************************** Public prototypes *****************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void MAC_ListMACAddresses (unsigned NumMACs,MYSQL_RES **mysql_res);
|
||||||
|
void MAC_EditMACAddresses (long Cod,const char *Anchor,
|
||||||
|
unsigned NumMACs,MYSQL_RES **mysql_res);
|
||||||
|
|
||||||
|
unsigned long long MAC_GetMACnumFromForm (const char *ParamName);
|
||||||
|
|
||||||
|
#endif
|
|
@ -555,7 +555,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
|
||||||
En OpenSWAD:
|
En OpenSWAD:
|
||||||
ps2pdf source.ps destination.pdf
|
ps2pdf source.ps destination.pdf
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 19.262 (2020-09-01)"
|
#define Log_PLATFORM_VERSION "SWAD 19.263 (2020-09-02)"
|
||||||
#define CSS_FILE "swad19.253.css"
|
#define CSS_FILE "swad19.253.css"
|
||||||
#define JS_FILE "swad19.254.js"
|
#define JS_FILE "swad19.254.js"
|
||||||
/*
|
/*
|
||||||
|
@ -573,6 +573,7 @@ TODO: Que al generar un examen s
|
||||||
TODO: Create module swad_test_result
|
TODO: Create module swad_test_result
|
||||||
"sudo apt install webp" en Ubuntu, y "yum install libwebp libwebp-tools" en CentOS, para decodificar imágenes Web/ug reportado por Javier Fernández Baldomero.
|
"sudo apt install webp" en Ubuntu, y "yum install libwebp libwebp-tools" en CentOS, para decodificar imágenes Web/ug reportado por Javier Fernández Baldomero.
|
||||||
|
|
||||||
|
Version 19.263 : Sep 02, 2020 New module swad_MAC for MAC addresses. (304364 lines)
|
||||||
Version 19.262 : Sep 01, 2020 Edition of MAC addresses in listing of rooms. (304239 lines)
|
Version 19.262 : Sep 01, 2020 Edition of MAC addresses in listing of rooms. (304239 lines)
|
||||||
Version 19.261 : Sep 01, 2020 MAC addresses are printed in listing of rooms. (304103 lines)
|
Version 19.261 : Sep 01, 2020 MAC addresses are printed in listing of rooms. (304103 lines)
|
||||||
Version 19.260.3: Aug 30, 2020 Fixed bug in API function answerMatchQuestion. Reported by Sergio Díaz Rueda. (304010 lines)
|
Version 19.260.3: Aug 30, 2020 Fixed bug in API function answerMatchQuestion. Reported by Sergio Díaz Rueda. (304010 lines)
|
||||||
|
|
121
swad_room.c
121
swad_room.c
|
@ -35,6 +35,7 @@
|
||||||
#include "swad_form.h"
|
#include "swad_form.h"
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
#include "swad_HTML.h"
|
#include "swad_HTML.h"
|
||||||
|
#include "swad_MAC.h"
|
||||||
#include "swad_room.h"
|
#include "swad_room.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -122,8 +123,6 @@ static struct Roo_Room *Roo_EditingRoom = NULL; // Static variable to keep the r
|
||||||
static void Roo_GetAndListMACAddresses (long RooCod);
|
static void Roo_GetAndListMACAddresses (long RooCod);
|
||||||
static void Roo_GetAndEditMACAddresses (long RooCod,const char *Anchor);
|
static void Roo_GetAndEditMACAddresses (long RooCod,const char *Anchor);
|
||||||
static unsigned Roo_GetMACAddresses (long RooCod,MYSQL_RES **mysql_res);
|
static unsigned Roo_GetMACAddresses (long RooCod,MYSQL_RES **mysql_res);
|
||||||
static void Roo_MACnumToMACstr (unsigned long long MACnum,char MACstr[17 + 1]);
|
|
||||||
unsigned long long Roo_GetMACnum (const char *ParamName);
|
|
||||||
|
|
||||||
static Roo_Order_t Roo_GetParamRoomOrder (void);
|
static Roo_Order_t Roo_GetParamRoomOrder (void);
|
||||||
static bool Roo_CheckIfICanCreateRooms (void);
|
static bool Roo_CheckIfICanCreateRooms (void);
|
||||||
|
@ -326,37 +325,13 @@ void Roo_SeeRooms (void)
|
||||||
static void Roo_GetAndListMACAddresses (long RooCod)
|
static void Roo_GetAndListMACAddresses (long RooCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned NumMACs;
|
unsigned NumMACs;
|
||||||
unsigned NumMAC;
|
|
||||||
unsigned long long MACnum;
|
|
||||||
char MACstr[17 + 1];
|
|
||||||
|
|
||||||
/***** Get MAC addresses from database *****/
|
/***** Get MAC addresses from database *****/
|
||||||
NumMACs = Roo_GetMACAddresses (RooCod,&mysql_res);
|
NumMACs = Roo_GetMACAddresses (RooCod,&mysql_res);
|
||||||
|
|
||||||
/***** Write the MAC addresses *****/
|
/***** Write the MAC addresses *****/
|
||||||
for (NumMAC = 0;
|
MAC_ListMACAddresses (NumMACs,&mysql_res);
|
||||||
NumMAC < NumMACs;
|
|
||||||
NumMAC++)
|
|
||||||
{
|
|
||||||
/* Get next MAC address */
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
|
|
||||||
/* Write break line */
|
|
||||||
if (NumMAC)
|
|
||||||
HTM_BR ();
|
|
||||||
|
|
||||||
/* Write MAC address (row[0]) */
|
|
||||||
if (sscanf (row[0],"%llu",&MACnum) == 1)
|
|
||||||
{
|
|
||||||
Roo_MACnumToMACstr (MACnum,MACstr);
|
|
||||||
HTM_Txt (MACstr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -366,50 +341,13 @@ static void Roo_GetAndListMACAddresses (long RooCod)
|
||||||
static void Roo_GetAndEditMACAddresses (long RooCod,const char *Anchor)
|
static void Roo_GetAndEditMACAddresses (long RooCod,const char *Anchor)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned NumMACs;
|
unsigned NumMACs;
|
||||||
unsigned NumMAC;
|
|
||||||
unsigned long long MACnum;
|
|
||||||
char MACstr[17 + 1];
|
|
||||||
|
|
||||||
/***** Get MAC addresses from database *****/
|
/***** Get MAC addresses from database *****/
|
||||||
NumMACs = Roo_GetMACAddresses (RooCod,&mysql_res);
|
NumMACs = Roo_GetMACAddresses (RooCod,&mysql_res);
|
||||||
|
|
||||||
/***** Write the MAC addresses *****/
|
/***** Write the MAC addresses *****/
|
||||||
for (NumMAC = 0;
|
MAC_EditMACAddresses (RooCod,Anchor,NumMACs,&mysql_res);
|
||||||
NumMAC < NumMACs;
|
|
||||||
NumMAC++)
|
|
||||||
{
|
|
||||||
/* Get next MAC address */
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
|
|
||||||
/* Write MAC address (row[0]) */
|
|
||||||
if (sscanf (row[0],"%llu",&MACnum) == 1)
|
|
||||||
{
|
|
||||||
Frm_StartFormAnchor (ActChgRooMAC,Anchor);
|
|
||||||
Roo_PutParamRooCod (RooCod);
|
|
||||||
Roo_MACnumToMACstr (MACnum,MACstr);
|
|
||||||
Par_PutHiddenParamString (NULL,"OldMAC",MACstr);
|
|
||||||
HTM_INPUT_TEXT ("NewMAC",17,MACstr,
|
|
||||||
HTM_SUBMIT_ON_CHANGE,
|
|
||||||
"size=\"8\"");
|
|
||||||
Frm_EndForm ();
|
|
||||||
|
|
||||||
/* Write break line */
|
|
||||||
HTM_BR ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* New MAC address */
|
|
||||||
Frm_StartFormAnchor (ActChgRooMAC,Anchor);
|
|
||||||
Roo_PutParamRooCod (RooCod);
|
|
||||||
HTM_INPUT_TEXT ("NewMAC",17,"",
|
|
||||||
HTM_SUBMIT_ON_CHANGE,
|
|
||||||
"size=\"8\"");
|
|
||||||
Frm_EndForm ();
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -427,21 +365,6 @@ static unsigned Roo_GetMACAddresses (long RooCod,MYSQL_RES **mysql_res)
|
||||||
RooCod);
|
RooCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/****** Get and list for edition the MAC addresses associated to a room ******/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
static void Roo_MACnumToMACstr (unsigned long long MACnum,char MACstr[17 + 1])
|
|
||||||
{
|
|
||||||
snprintf (MACstr,17 + 1,"%02x:%02x:%02x:%02x:%02x:%02x",
|
|
||||||
(unsigned char) ((MACnum >> 40) & 0xff),
|
|
||||||
(unsigned char) ((MACnum >> 32) & 0xff),
|
|
||||||
(unsigned char) ((MACnum >> 24) & 0xff),
|
|
||||||
(unsigned char) ((MACnum >> 16) & 0xff),
|
|
||||||
(unsigned char) ((MACnum >> 8) & 0xff),
|
|
||||||
(unsigned char) ((MACnum ) & 0xff));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/**************************** Change MAC of a room ***************************/
|
/**************************** Change MAC of a room ***************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -456,14 +379,14 @@ void Roo_ChangeMAC (void)
|
||||||
|
|
||||||
/***** Get parameters from form *****/
|
/***** Get parameters from form *****/
|
||||||
/* Get room code */
|
/* Get room code */
|
||||||
if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) == -1L)
|
if ((Roo_EditingRoom->RooCod = Par_GetParToLong ("Cod")) == -1L)
|
||||||
Lay_ShowErrorAndExit ("Code of room is missing.");
|
Lay_ShowErrorAndExit ("Code of room is missing.");
|
||||||
|
|
||||||
/* Get the old MAC address of the room */
|
/* Get the old MAC address of the room */
|
||||||
OldMAC = Roo_GetMACnum ("OldMAC");
|
OldMAC = MAC_GetMACnumFromForm ("MAC");
|
||||||
|
|
||||||
/* Get the new MAC address of the room */
|
/* Get the new MAC address of the room */
|
||||||
NewMAC = Roo_GetMACnum ("NewMAC");
|
NewMAC = MAC_GetMACnumFromForm ("NewMAC");
|
||||||
|
|
||||||
/***** Get data of the room from database *****/
|
/***** Get data of the room from database *****/
|
||||||
Roo_GetDataOfRoomByCod (Roo_EditingRoom);
|
Roo_GetDataOfRoomByCod (Roo_EditingRoom);
|
||||||
|
@ -483,38 +406,6 @@ void Roo_ChangeMAC (void)
|
||||||
Roo_EditingRoom->MAC = NewMAC;
|
Roo_EditingRoom->MAC = NewMAC;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/****************** Get MAC address as a number from a form ******************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
unsigned long long Roo_GetMACnum (const char *ParamName)
|
|
||||||
{
|
|
||||||
char MACstr[17 * Str_MAX_BYTES_PER_CHAR + 1];
|
|
||||||
unsigned long long MAC[6 + 1];
|
|
||||||
unsigned long long MACnum;
|
|
||||||
|
|
||||||
/***** Get parameter *****/
|
|
||||||
Par_GetParToText (ParamName,MACstr,17 * Str_MAX_BYTES_PER_CHAR);
|
|
||||||
|
|
||||||
if (MACstr[0]) // Not empty
|
|
||||||
{
|
|
||||||
/***** Try to scan it in xx:xx:xx:xx:xx:xx format (where x are hexadecimal digits) *****/
|
|
||||||
if (sscanf (MACstr,"%02llx:%02llx:%02llx:%02llx:%02llx:%02llx",&MAC[0],&MAC[1],&MAC[2],&MAC[3],&MAC[4],&MAC[5]) == 6)
|
|
||||||
return (MAC[0] << 40) +
|
|
||||||
(MAC[1] << 32) +
|
|
||||||
(MAC[2] << 24) +
|
|
||||||
(MAC[3] << 16) +
|
|
||||||
(MAC[4] << 8) +
|
|
||||||
MAC[5];
|
|
||||||
|
|
||||||
/***** Try to scan it in xxxxxxxxxxxx format (where x are hexadecimal digits) ******/
|
|
||||||
if (sscanf (MACstr,"%llx",&MACnum) == 1)
|
|
||||||
return MACnum;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*********** Get parameter with the type or order in list of rooms ***********/
|
/*********** Get parameter with the type or order in list of rooms ***********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user