removed trailing whitespaces
This commit is contained in:
parent
3c8904acc6
commit
581bcaba54
71 changed files with 771 additions and 771 deletions
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -32,20 +32,20 @@ int serial_port_open(const char* device) {
|
|||
int bits;
|
||||
struct termios config;
|
||||
memset(&config, 0, sizeof(config));
|
||||
|
||||
|
||||
int fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
if (fd < 0) {
|
||||
printf("error: open(%s): %s\n", device, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// set RTS
|
||||
ioctl(fd, TIOCMGET, &bits);
|
||||
bits |= TIOCM_RTS;
|
||||
ioctl(fd, TIOCMSET, &bits);
|
||||
|
||||
|
||||
tcgetattr( fd, &config ) ;
|
||||
|
||||
|
||||
// set 8-N-1
|
||||
config.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
|
||||
config.c_oflag &= ~OPOST;
|
||||
|
@ -56,23 +56,23 @@ int serial_port_open(const char* device) {
|
|||
// set speed to 9600 baud
|
||||
cfsetispeed( &config, B9600);
|
||||
cfsetospeed( &config, B9600);
|
||||
|
||||
|
||||
tcsetattr(fd, TCSANOW, &config);
|
||||
return fd;
|
||||
}
|
||||
|
||||
void transport_receiver(unsigned char *buffer, size_t buffer_len) {
|
||||
|
||||
|
||||
// the buffer contains the whole message, with transport escape sequences.
|
||||
// these escape sequences are stripped here.
|
||||
// these escape sequences are stripped here.
|
||||
sml_file *file = sml_file_parse(buffer + 8, buffer_len - 16);
|
||||
// the sml file is parsed now
|
||||
|
||||
|
||||
// read here some values ..
|
||||
|
||||
|
||||
// this prints some information about the file
|
||||
sml_file_print(file);
|
||||
|
||||
|
||||
// free the malloc'd memory
|
||||
sml_file_free(file);
|
||||
}
|
||||
|
@ -82,12 +82,12 @@ int main(int argc, char **argv) {
|
|||
// serial device. Adjust as needed.
|
||||
char *device = "/dev/cu.usbserial";
|
||||
int fd = serial_port_open(device);
|
||||
|
||||
|
||||
if (fd > 0) {
|
||||
// listen on the serial device, this call is blocking.
|
||||
sml_transport_listen(fd, &transport_receiver);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -47,4 +47,4 @@ void sml_file_print(sml_file *file);
|
|||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -30,9 +30,9 @@ extern "C" {
|
|||
|
||||
typedef struct {
|
||||
octet_string *server_id; // optional
|
||||
octet_string *username; // optional
|
||||
octet_string *username; // optional
|
||||
octet_string *password; // optional
|
||||
sml_tree_path *parameter_tree_path;
|
||||
sml_tree_path *parameter_tree_path;
|
||||
octet_string *attribute; // optional
|
||||
} sml_get_proc_parameter_request;
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -36,7 +36,7 @@ typedef octet_string sml_obj_req_entry;
|
|||
|
||||
typedef struct sml_obj_req_entry_list_entry {
|
||||
sml_obj_req_entry *object_list_entry;
|
||||
|
||||
|
||||
// list specific
|
||||
struct sml_obj_req_entry_list_entry *next;
|
||||
} sml_obj_req_entry_list;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -52,7 +52,7 @@ typedef struct sml_list_entry {
|
|||
i8 *scaler; // optional
|
||||
sml_value *value;
|
||||
sml_signature *value_signature; // optional
|
||||
|
||||
|
||||
// list specific
|
||||
struct sml_list_entry *next;
|
||||
} sml_list;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -29,8 +29,8 @@ extern "C" {
|
|||
|
||||
void *sml_number_init(u64 number, unsigned char type, int size);
|
||||
|
||||
// Parses a number. Identified by type (SML_TYPE_INTEGER or SML_TYPE_UNSIGNED)
|
||||
// and maximal number of bytes (SML_TYPE_NUMBER_8, SML_TYPE_NUMBER_16,
|
||||
// Parses a number. Identified by type (SML_TYPE_INTEGER or SML_TYPE_UNSIGNED)
|
||||
// and maximal number of bytes (SML_TYPE_NUMBER_8, SML_TYPE_NUMBER_16,
|
||||
// SML_TYPE_NUMBER_32, SML_TYPE_NUMBER_64)
|
||||
void *sml_number_parse(sml_buffer *buf, unsigned char type, int max_size);
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -30,7 +30,7 @@ extern "C" {
|
|||
|
||||
typedef struct {
|
||||
octet_string *codepage; // optional
|
||||
octet_string *client_id;
|
||||
octet_string *client_id;
|
||||
octet_string *req_file_id;
|
||||
octet_string *server_id; // optional
|
||||
octet_string *username; // optional
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -29,9 +29,9 @@ extern "C" {
|
|||
|
||||
typedef struct {
|
||||
octet_string *server_id; // optional
|
||||
octet_string *username; // optional
|
||||
octet_string *username; // optional
|
||||
octet_string *password; // optional
|
||||
sml_tree_path *parameter_tree_path;
|
||||
sml_tree_path *parameter_tree_path;
|
||||
sml_tree *parameter_tree;
|
||||
} sml_set_proc_parameter_request;
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -59,12 +59,12 @@ typedef int64_t i64;
|
|||
|
||||
// This sml_buffer is used in two different use-cases.
|
||||
//
|
||||
// Parsing: the raw data is in the buffer field,
|
||||
// the buffer_len is the number of raw bytes received,
|
||||
// Parsing: the raw data is in the buffer field,
|
||||
// the buffer_len is the number of raw bytes received,
|
||||
// the cursor points to the current position during parsing
|
||||
//
|
||||
// Writing: At the beginning the buffer field is malloced and zeroed with
|
||||
// a default length, this default length is stored in buffer_len
|
||||
// a default length, this default length is stored in buffer_len
|
||||
// (i.e. the maximum bytes one can write to this buffer)
|
||||
// cursor points to the position, where on can write during the
|
||||
// writing process. If a file is completely written to the buffer,
|
||||
|
@ -81,7 +81,7 @@ sml_buffer *sml_buffer_init(size_t length);
|
|||
|
||||
void sml_buffer_free(sml_buffer *buf);
|
||||
|
||||
// Returns the length of the following data structure. Sets the cursor position to
|
||||
// Returns the length of the following data structure. Sets the cursor position to
|
||||
// the value field.
|
||||
int sml_buf_get_next_length(sml_buffer *buf);
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -46,5 +46,5 @@ void sml_status_free(sml_status *status);
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
// sml_transport_read reads continously bytes from fd and scans
|
||||
// sml_transport_read reads continously bytes from fd and scans
|
||||
// for the SML transport protocol escape sequences. If a SML file
|
||||
// is detected it will be copied into the buffer. The total amount of bytes read
|
||||
// will be returned. If the SML file exceeds the len of the buffer, -1 will be returned
|
||||
|
@ -36,8 +36,8 @@ size_t sml_transport_read(int fd, unsigned char *buffer, size_t max_len);
|
|||
// via sml_transport_read and calls the sml_transporter_receiver
|
||||
void sml_transport_listen(int fd, void (*sml_transport_receiver)(unsigned char *buffer, size_t buffer_len));
|
||||
|
||||
// sml_transport_writes adds the SML transport protocol escape
|
||||
// sequences and writes the given file to fd. The file must be
|
||||
// sml_transport_writes adds the SML transport protocol escape
|
||||
// sequences and writes the given file to fd. The file must be
|
||||
// in the parsed format.
|
||||
// The number of bytes written is returned, 0 if there was an
|
||||
// error.
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -39,33 +39,33 @@ typedef struct {
|
|||
octet_string *server_id;
|
||||
sml_time *sec_index;
|
||||
u64 *status;
|
||||
|
||||
|
||||
sml_unit *unit_pA;
|
||||
i8 *scaler_pA;
|
||||
i64 *value_pA;
|
||||
|
||||
|
||||
sml_unit *unit_R1;
|
||||
i8 *scaler_R1;
|
||||
i64 *value_R1;
|
||||
|
||||
|
||||
sml_unit *unit_R4;
|
||||
i8 *scaler_R4;
|
||||
i64 *value_R4;
|
||||
|
||||
|
||||
octet_string *signature_pA_R1_R4;
|
||||
|
||||
|
||||
sml_unit *unit_mA;
|
||||
i8 *scaler_mA;
|
||||
i64 *value_mA;
|
||||
|
||||
|
||||
sml_unit *unit_R2;
|
||||
i8 *scaler_R2;
|
||||
i64 *value_R2;
|
||||
|
||||
|
||||
sml_unit *unit_R3;
|
||||
i8 *scaler_R3;
|
||||
i64 *value_R3;
|
||||
|
||||
|
||||
octet_string *signature_mA_R2_R3;
|
||||
} sml_tupel_entry;
|
||||
|
||||
|
@ -88,11 +88,11 @@ typedef struct {
|
|||
} sml_proc_par_value;
|
||||
|
||||
typedef struct s_tree{
|
||||
octet_string *parameter_name;
|
||||
octet_string *parameter_name;
|
||||
sml_proc_par_value *parameter_value; // optional
|
||||
struct s_tree **child_list; // optional
|
||||
|
||||
int child_list_len;
|
||||
|
||||
int child_list_len;
|
||||
} sml_tree;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -41,26 +41,26 @@ sml_attention_response *sml_attention_response_parse(sml_buffer *buf){
|
|||
|
||||
msg->server_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->attention_number = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->attention_message = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->attention_details = sml_tree_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
return msg;
|
||||
|
||||
|
||||
error:
|
||||
sml_attention_response_free(msg);
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sml_attention_response_write(sml_attention_response *msg, sml_buffer *buf) {
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 4);
|
||||
|
||||
|
||||
sml_octet_string_write(msg->server_id, buf);
|
||||
sml_octet_string_write(msg->attention_number, buf);
|
||||
sml_octet_string_write(msg->attention_message, buf);
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -30,19 +30,19 @@ sml_boolean *sml_boolean_parse(sml_buffer *buf) {
|
|||
if (sml_buf_optional_is_skipped(buf)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int l;
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_BOOLEAN) {
|
||||
buf->error = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
l = sml_buf_get_next_length(buf);
|
||||
if (l != 1) {
|
||||
buf->error = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_current_byte(buf)) {
|
||||
sml_buf_update_bytes_read(buf, 1);
|
||||
return sml_boolean_init(SML_BOOLEAN_TRUE);
|
||||
|
@ -51,7 +51,7 @@ sml_boolean *sml_boolean_parse(sml_buffer *buf) {
|
|||
sml_buf_update_bytes_read(buf, 1);
|
||||
return sml_boolean_init(SML_BOOLEAN_FALSE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void sml_boolean_write(sml_boolean *boolean, sml_buffer *buf) {
|
||||
|
@ -59,7 +59,7 @@ void sml_boolean_write(sml_boolean *boolean, sml_buffer *buf) {
|
|||
sml_buf_optional_write(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_BOOLEAN, 1);
|
||||
if (*boolean == SML_BOOLEAN_FALSE) {
|
||||
buf->buffer[buf->cursor] = SML_BOOLEAN_FALSE;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -29,22 +29,22 @@ sml_close_request *sml_close_request_init() {
|
|||
|
||||
sml_close_request * sml_close_request_parse(sml_buffer *buf) {
|
||||
sml_close_request *msg = sml_close_request_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 1) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
msg->global_signature = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
return msg;
|
||||
|
||||
|
||||
error:
|
||||
sml_close_request_free(msg);
|
||||
return 0;
|
||||
|
@ -57,7 +57,7 @@ void sml_close_request_write(sml_close_request *msg, sml_buffer *buf) {
|
|||
|
||||
void sml_close_request_free(sml_close_request *msg) {
|
||||
if (msg) {
|
||||
sml_octet_string_free(msg->global_signature);
|
||||
sml_octet_string_free(msg->global_signature);
|
||||
free(msg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -33,18 +33,18 @@ sml_close_response *sml_close_response_parse(sml_buffer *buf) {
|
|||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 1) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
msg->global_signature = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
return msg;
|
||||
|
||||
error:
|
||||
error:
|
||||
sml_close_response_free(msg);
|
||||
return 0;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ void sml_close_response_write(sml_close_response *msg, sml_buffer *buf) {
|
|||
|
||||
void sml_close_response_free(sml_close_response *msg) {
|
||||
if (msg) {
|
||||
sml_octet_string_free(msg->global_signature);
|
||||
sml_octet_string_free(msg->global_signature);
|
||||
free(msg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -30,27 +30,27 @@
|
|||
#define SML_FILE_BUFFER_LENGTH 512
|
||||
|
||||
sml_file *sml_file_parse(unsigned char *buffer, size_t buffer_len) {
|
||||
|
||||
|
||||
sml_file *file = (sml_file*) malloc(sizeof(sml_file));
|
||||
memset(file, 0, sizeof(sml_file));
|
||||
|
||||
|
||||
sml_buffer *buf = sml_buffer_init(buffer_len);
|
||||
memcpy(buf->buffer, buffer, buffer_len);
|
||||
file->buf = buf;
|
||||
|
||||
|
||||
sml_message *msg;
|
||||
|
||||
|
||||
// parsing all messages
|
||||
for (; buf->cursor < buf->buffer_len;) {
|
||||
|
||||
|
||||
if(sml_buf_get_current_byte(buf) == SML_MESSAGE_END) {
|
||||
// reading trailing zeroed bytes
|
||||
sml_buf_update_bytes_read(buf, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
msg = sml_message_parse(buf);
|
||||
|
||||
|
||||
if (sml_buf_has_errors(buf)) {
|
||||
printf("warning: could not read the whole file\n");
|
||||
break;
|
||||
|
@ -65,7 +65,7 @@ sml_file *sml_file_parse(unsigned char *buffer, size_t buffer_len) {
|
|||
sml_file *sml_file_init() {
|
||||
sml_file *file = (sml_file*) malloc(sizeof(sml_file));
|
||||
memset(file, 0, sizeof(sml_file));
|
||||
|
||||
|
||||
sml_buffer *buf = sml_buffer_init(SML_FILE_BUFFER_LENGTH);
|
||||
file->buf = buf;
|
||||
return file;
|
||||
|
@ -88,7 +88,7 @@ void sml_file_write(sml_file *file) {
|
|||
|
||||
void sml_file_free(sml_file *file) {
|
||||
if (file) {
|
||||
|
||||
|
||||
if (file->messages) {
|
||||
int i;
|
||||
for (i = 0; i < file->messages_len; i++) {
|
||||
|
@ -96,11 +96,11 @@ void sml_file_free(sml_file *file) {
|
|||
}
|
||||
free(file->messages);
|
||||
}
|
||||
|
||||
|
||||
if (file->buf) {
|
||||
sml_buffer_free(file->buf);
|
||||
}
|
||||
|
||||
|
||||
free(file);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -39,41 +39,41 @@ void sml_get_list_request_write(sml_get_list_request *msg, sml_buffer *buf) {
|
|||
|
||||
|
||||
sml_get_list_request *sml_get_list_request_parse(sml_buffer *buf) {
|
||||
|
||||
|
||||
sml_get_list_request *msg = (sml_get_list_request *) malloc(sizeof(sml_get_list_request));
|
||||
memset(msg, 0, sizeof(sml_get_list_request));
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 5) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
msg->client_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->server_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->username = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->password = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->list_name = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
return msg;
|
||||
|
||||
error:
|
||||
|
||||
error:
|
||||
sml_get_list_request_free(msg);
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -28,12 +28,12 @@ sml_get_list_response *sml_get_list_response_init() {
|
|||
|
||||
sml_get_list_response *sml_get_list_response_parse(sml_buffer *buf) {
|
||||
sml_get_list_response *msg = sml_get_list_response_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 7) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
|
@ -41,36 +41,36 @@ sml_get_list_response *sml_get_list_response_parse(sml_buffer *buf) {
|
|||
|
||||
msg->client_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->server_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->list_name = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->act_sensor_time = sml_time_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->val_list = sml_list_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->list_signature = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->act_gateway_time = sml_time_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
return msg;
|
||||
|
||||
error:
|
||||
|
||||
error:
|
||||
sml_get_list_response_free(msg);
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void sml_get_list_response_write(sml_get_list_response *msg, sml_buffer *buf) {
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 7);
|
||||
|
||||
|
||||
sml_octet_string_write(msg->client_id, buf);
|
||||
sml_octet_string_write(msg->server_id, buf);
|
||||
sml_octet_string_write(msg->list_name, buf);
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -30,32 +30,32 @@ sml_get_proc_parameter_request *sml_get_proc_parameter_request_init() {
|
|||
|
||||
sml_get_proc_parameter_request *sml_get_proc_parameter_request_parse(sml_buffer *buf) {
|
||||
sml_get_proc_parameter_request *msg = sml_get_proc_parameter_request_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 5) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
msg->server_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->username = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->password = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->parameter_tree_path = sml_tree_path_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->attribute = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
return msg;
|
||||
error:
|
||||
sml_get_proc_parameter_request_free(msg);
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -27,26 +27,26 @@ sml_get_proc_parameter_response *sml_get_proc_parameter_response_init() {
|
|||
|
||||
sml_get_proc_parameter_response *sml_get_proc_parameter_response_parse(sml_buffer *buf) {
|
||||
sml_get_proc_parameter_response *msg = sml_get_proc_parameter_response_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 3) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
msg->server_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->parameter_tree_path = sml_tree_path_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->parameter_tree = sml_tree_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
return msg;
|
||||
error:
|
||||
sml_get_proc_parameter_response_free(msg);
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -26,15 +26,15 @@ sml_get_profile_list_response *sml_get_profile_list_response_init() {
|
|||
memset(msg, 0, sizeof(sml_get_profile_list_response));
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
sml_get_profile_list_response *sml_get_profile_list_response_parse(sml_buffer *buf) {
|
||||
sml_get_profile_list_response *msg = sml_get_profile_list_response_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 9) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
|
@ -42,33 +42,33 @@ sml_get_profile_list_response *sml_get_profile_list_response_parse(sml_buffer *b
|
|||
|
||||
msg->server_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->act_time = sml_time_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->reg_period = sml_u32_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->parameter_tree_path = sml_tree_path_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->val_time = sml_time_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->status = sml_u64_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->period_list = sml_sequence_parse(buf, (void *) &sml_period_entry_parse, (void (*)(void *)) &sml_period_entry_free);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
msg->rawdata = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->period_signature = sml_signature_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
return msg;
|
||||
|
||||
|
||||
return msg;
|
||||
|
||||
error:
|
||||
buf->error = 1;
|
||||
sml_get_profile_list_response_free(msg);
|
||||
|
@ -77,7 +77,7 @@ error:
|
|||
|
||||
void sml_get_profile_list_response_write(sml_get_profile_list_response *msg, sml_buffer *buf) {
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 9);
|
||||
|
||||
|
||||
sml_octet_string_write(msg->server_id, buf);
|
||||
sml_time_write(msg->act_time, buf);
|
||||
sml_u32_write(msg->reg_period, buf);
|
||||
|
@ -87,7 +87,7 @@ void sml_get_profile_list_response_write(sml_get_profile_list_response *msg, sml
|
|||
sml_sequence_write(msg->period_list, buf, (void (*)(void *, sml_buffer *)) &sml_period_entry_write);
|
||||
sml_octet_string_write(msg->rawdata, buf);
|
||||
sml_signature_write(msg->period_signature, buf);
|
||||
}
|
||||
}
|
||||
|
||||
void sml_get_profile_list_response_free(sml_get_profile_list_response *msg) {
|
||||
if (msg) {
|
||||
|
@ -100,7 +100,7 @@ void sml_get_profile_list_response_free(sml_get_profile_list_response *msg) {
|
|||
sml_sequence_free(msg->period_list);
|
||||
sml_octet_string_free(msg->rawdata);
|
||||
sml_signature_free(msg->period_signature);
|
||||
|
||||
|
||||
free(msg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -31,7 +31,7 @@ sml_get_profile_pack_request *sml_get_profile_pack_request_init(){
|
|||
|
||||
void sml_get_profile_pack_request_write(sml_get_profile_pack_request *msg, sml_buffer *buf) {
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 9);
|
||||
|
||||
|
||||
sml_octet_string_write(msg->server_id, buf);
|
||||
sml_octet_string_write(msg->username, buf);
|
||||
sml_octet_string_write(msg->password, buf);
|
||||
|
@ -39,7 +39,7 @@ void sml_get_profile_pack_request_write(sml_get_profile_pack_request *msg, sml_b
|
|||
sml_time_write(msg->begin_time, buf);
|
||||
sml_time_write(msg->end_time, buf);
|
||||
sml_tree_path_write(msg->parameter_tree_path, buf);
|
||||
|
||||
|
||||
if (msg->object_list) {
|
||||
int len = 1;
|
||||
sml_obj_req_entry_list *l = msg->object_list;
|
||||
|
@ -60,37 +60,37 @@ void sml_get_profile_pack_request_write(sml_get_profile_pack_request *msg, sml_b
|
|||
|
||||
|
||||
sml_get_profile_pack_request *sml_get_profile_pack_request_parse(sml_buffer *buf) {
|
||||
|
||||
|
||||
sml_get_profile_pack_request *msg = sml_get_profile_pack_request_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 9) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
msg->server_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->username = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->password = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->with_rawdata = sml_boolean_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->begin_time = sml_time_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->end_time = sml_time_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->parameter_tree_path = sml_tree_path_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
@ -106,7 +106,7 @@ sml_get_profile_pack_request *sml_get_profile_pack_request_parse(sml_buffer *buf
|
|||
memset(n, 0, sizeof(sml_obj_req_entry_list));
|
||||
n->object_list_entry = sml_obj_req_entry_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
if (msg->object_list == 0) {
|
||||
msg->object_list = n;
|
||||
last = msg->object_list;
|
||||
|
@ -117,7 +117,7 @@ sml_get_profile_pack_request *sml_get_profile_pack_request_parse(sml_buffer *buf
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
msg->das_details = sml_tree_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
@ -136,7 +136,7 @@ void sml_get_profile_pack_request_free(sml_get_profile_pack_request *msg){
|
|||
sml_time_free(msg->begin_time);
|
||||
sml_time_free(msg->end_time);
|
||||
sml_tree_path_free(msg->parameter_tree_path);
|
||||
|
||||
|
||||
if (msg->object_list) {
|
||||
sml_obj_req_entry_list *n = 0, *d = msg->object_list;
|
||||
do {
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -30,43 +30,43 @@ sml_get_profile_pack_response *sml_get_profile_pack_response_init() {
|
|||
|
||||
sml_get_profile_pack_response *sml_get_profile_pack_response_parse(sml_buffer *buf){
|
||||
sml_get_profile_pack_response *msg = sml_get_profile_pack_response_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 8) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
msg->server_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->act_time = sml_time_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->reg_period = sml_u32_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->parameter_tree_path = sml_tree_path_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->header_list = sml_sequence_parse(buf, (void *) &sml_prof_obj_header_entry_parse, (void (*)(void *)) &sml_prof_obj_header_entry_free);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->period_list = sml_sequence_parse(buf, (void *) &sml_prof_obj_period_entry_parse, (void (*)(void *)) &sml_prof_obj_period_entry_free);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->rawdata = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->profile_signature = sml_signature_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
return msg;
|
||||
|
||||
|
||||
error:
|
||||
buf->error = 1;
|
||||
sml_get_profile_pack_response_free(msg);
|
||||
|
@ -75,7 +75,7 @@ error:
|
|||
|
||||
void sml_get_profile_pack_response_write(sml_get_profile_pack_response *msg, sml_buffer *buf) {
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 8);
|
||||
|
||||
|
||||
sml_octet_string_write(msg->server_id, buf);
|
||||
sml_time_write(msg->act_time, buf);
|
||||
sml_u32_write(msg->reg_period, buf);
|
||||
|
@ -113,24 +113,24 @@ sml_prof_obj_header_entry *sml_prof_obj_header_entry_init() {
|
|||
|
||||
sml_prof_obj_header_entry *sml_prof_obj_header_entry_parse(sml_buffer *buf) {
|
||||
sml_prof_obj_header_entry *entry = sml_prof_obj_header_entry_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 3) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
entry->obj_name = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
entry->unit = sml_unit_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
entry->scaler = sml_i8_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
return entry;
|
||||
error:
|
||||
buf->error = 1;
|
||||
|
@ -140,7 +140,7 @@ error:
|
|||
|
||||
void sml_prof_obj_header_entry_write(sml_prof_obj_header_entry *entry, sml_buffer *buf) {
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 3);
|
||||
|
||||
|
||||
sml_octet_string_write(entry->obj_name, buf);
|
||||
sml_unit_write(entry->unit, buf);
|
||||
sml_i8_write(entry->scaler, buf);
|
||||
|
@ -151,7 +151,7 @@ void sml_prof_obj_header_entry_free(sml_prof_obj_header_entry *entry) {
|
|||
sml_octet_string_free(entry->obj_name);
|
||||
sml_unit_free(entry->unit);
|
||||
sml_number_free(entry->scaler);
|
||||
|
||||
|
||||
free(entry);
|
||||
}
|
||||
}
|
||||
|
@ -169,18 +169,18 @@ sml_prof_obj_period_entry *sml_prof_obj_period_entry_init() {
|
|||
|
||||
sml_prof_obj_period_entry *sml_prof_obj_period_entry_parse(sml_buffer *buf) {
|
||||
sml_prof_obj_period_entry *entry = sml_prof_obj_period_entry_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 4) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
entry->val_time = sml_time_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
entry->status = sml_u64_parse(buf);
|
||||
|
@ -189,9 +189,9 @@ sml_prof_obj_period_entry *sml_prof_obj_period_entry_parse(sml_buffer *buf) {
|
|||
if (sml_buf_has_errors(buf)) goto error;
|
||||
entry->period_signature = sml_signature_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
return entry;
|
||||
|
||||
|
||||
error:
|
||||
buf->error = 1;
|
||||
sml_prof_obj_period_entry_free(entry);
|
||||
|
@ -212,7 +212,7 @@ void sml_prof_obj_period_entry_free(sml_prof_obj_period_entry *entry) {
|
|||
sml_number_free(entry->status);
|
||||
sml_sequence_free(entry->value_list);
|
||||
sml_signature_free(entry->period_signature);
|
||||
|
||||
|
||||
free(entry);
|
||||
}
|
||||
}
|
||||
|
@ -229,22 +229,22 @@ sml_value_entry *sml_value_entry_init() {
|
|||
|
||||
sml_value_entry *sml_value_entry_parse(sml_buffer *buf) {
|
||||
sml_value_entry *entry = sml_value_entry_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 2) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
entry->value = sml_value_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
entry->value_signature = sml_signature_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
return entry;
|
||||
error:
|
||||
buf->error = 1;
|
||||
|
@ -262,7 +262,7 @@ void sml_value_entry_free(sml_value_entry *entry) {
|
|||
if (entry) {
|
||||
sml_value_free(entry->value);
|
||||
sml_signature_free(entry->value_signature);
|
||||
|
||||
|
||||
free(entry);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -32,16 +32,16 @@ sml_sequence *sml_sequence_init(void (*elem_free) (void *elem)) {
|
|||
return seq;
|
||||
}
|
||||
|
||||
sml_sequence *sml_sequence_parse(sml_buffer *buf,
|
||||
void *(*elem_parse) (sml_buffer *buf),
|
||||
sml_sequence *sml_sequence_parse(sml_buffer *buf,
|
||||
void *(*elem_parse) (sml_buffer *buf),
|
||||
void (*elem_free) (void *elem)) {
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
sml_sequence *seq = sml_sequence_init(elem_free);
|
||||
sml_sequence *seq = sml_sequence_init(elem_free);
|
||||
int i, len = sml_buf_get_next_length(buf);
|
||||
void *p;
|
||||
for (i = 0; i < len; i++) {
|
||||
|
@ -50,7 +50,7 @@ sml_sequence *sml_sequence_parse(sml_buffer *buf,
|
|||
sml_sequence_add(seq, p);
|
||||
}
|
||||
return seq;
|
||||
|
||||
|
||||
error:
|
||||
buf->error = 1;
|
||||
sml_sequence_free(seq);
|
||||
|
@ -61,9 +61,9 @@ void sml_sequence_write(sml_sequence *seq, sml_buffer *buf, void (*elem_write) (
|
|||
sml_buf_optional_write(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, seq->elems_len);
|
||||
|
||||
|
||||
int i;
|
||||
for (i = 0; i < seq->elems_len; i++) {
|
||||
elem_write((seq->elems)[i], buf);
|
||||
|
@ -72,8 +72,8 @@ void sml_sequence_write(sml_sequence *seq, sml_buffer *buf, void (*elem_write) (
|
|||
|
||||
void sml_sequence_free(sml_sequence *seq) {
|
||||
if (seq) {
|
||||
|
||||
int i;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < seq->elems_len; i++) {
|
||||
seq->elem_free((seq->elems)[i]);
|
||||
}
|
||||
|
@ -106,36 +106,36 @@ sml_list *sml_list_entry_parse(sml_buffer *buf) {
|
|||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 7) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
sml_list *l = sml_list_init();
|
||||
sml_list *l = sml_list_init();
|
||||
|
||||
l->obj_name = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
l->status = sml_status_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
l->val_time = sml_time_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
l->unit = sml_u8_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
l->scaler = sml_i8_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
l->value = sml_value_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
l->value_signature = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
return l;
|
||||
|
||||
|
||||
error:
|
||||
// This function doesn't free the allocated memory in error cases,
|
||||
// this is done in sml_list_parse.
|
||||
|
@ -147,16 +147,16 @@ sml_list *sml_list_parse(sml_buffer *buf) {
|
|||
if (sml_buf_optional_is_skipped(buf)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
sml_list *first = 0;
|
||||
sml_list *last = 0;
|
||||
int elems;
|
||||
|
||||
|
||||
elems = sml_buf_get_next_length(buf);
|
||||
|
||||
if (elems > 0) {
|
||||
|
@ -165,16 +165,16 @@ sml_list *sml_list_parse(sml_buffer *buf) {
|
|||
last = first;
|
||||
elems--;
|
||||
}
|
||||
|
||||
|
||||
while(elems > 0) {
|
||||
last->next = sml_list_entry_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
last = last->next;
|
||||
elems--;
|
||||
}
|
||||
|
||||
|
||||
return first;
|
||||
|
||||
|
||||
error:
|
||||
buf->error = 1;
|
||||
sml_list_free(first);
|
||||
|
@ -198,22 +198,22 @@ void sml_list_write(sml_list *list, sml_buffer *buf){
|
|||
sml_buf_optional_write(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
sml_list *i = list;
|
||||
int len = 0;
|
||||
while(i) {
|
||||
i = i->next;
|
||||
len++;
|
||||
}
|
||||
|
||||
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, len);
|
||||
|
||||
|
||||
i = list;
|
||||
while(i) {
|
||||
sml_list_entry_write(i, buf);
|
||||
i = i->next;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void sml_list_entry_free(sml_list *list) {
|
||||
|
@ -233,7 +233,7 @@ void sml_list_free(sml_list *list) {
|
|||
if (list) {
|
||||
sml_list *f = list;
|
||||
sml_list *n = list->next;
|
||||
|
||||
|
||||
while(f) {
|
||||
sml_list_entry_free(f);
|
||||
f = n;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -26,44 +26,44 @@
|
|||
#include <sml/sml_crc16.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// SML MESSAGE
|
||||
|
||||
sml_message *sml_message_parse(sml_buffer *buf) {
|
||||
sml_message *msg = (sml_message *) malloc(sizeof(sml_message));
|
||||
memset(msg, 0, sizeof(sml_message));
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 6) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
msg->transaction_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->group_id = sml_u8_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->abort_on_error = sml_u8_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->message_body = sml_message_body_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->crc = sml_u16_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
if (sml_buf_get_current_byte(buf) == SML_MESSAGE_END) {
|
||||
sml_buf_update_bytes_read(buf, 1);
|
||||
}
|
||||
return msg;
|
||||
|
||||
|
||||
error:
|
||||
sml_message_free(msg);
|
||||
return 0;
|
||||
|
@ -94,10 +94,10 @@ void sml_message_write(sml_message *msg, sml_buffer *buf) {
|
|||
sml_u8_write(msg->group_id, buf);
|
||||
sml_u8_write(msg->abort_on_error, buf);
|
||||
sml_message_body_write(msg->message_body, buf);
|
||||
|
||||
|
||||
msg->crc = sml_u16_init(sml_crc16_calculate(&(buf->buffer[msg_start]), buf->cursor - msg_start));
|
||||
sml_u16_write(msg->crc, buf);
|
||||
|
||||
|
||||
// end of message
|
||||
buf->buffer[buf->cursor] = 0x0;
|
||||
buf->cursor++;
|
||||
|
@ -108,17 +108,17 @@ void sml_message_write(sml_message *msg, sml_buffer *buf) {
|
|||
sml_message_body *sml_message_body_parse(sml_buffer *buf) {
|
||||
sml_message_body *msg_body = (sml_message_body *) malloc(sizeof(sml_message_body));
|
||||
memset(msg_body, 0, sizeof(sml_message_body));
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 2) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
msg_body->tag = sml_u16_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
@ -169,9 +169,9 @@ sml_message_body *sml_message_body_parse(sml_buffer *buf) {
|
|||
printf("error: message type %04X not yet implemented\n", *(msg_body->tag));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return msg_body;
|
||||
|
||||
|
||||
error:
|
||||
free(msg_body);
|
||||
return 0;
|
||||
|
@ -225,7 +225,7 @@ void sml_message_body_write(sml_message_body *message_body, sml_buffer *buf) {
|
|||
break;
|
||||
case SML_MESSAGE_GET_LIST_REQUEST:
|
||||
sml_get_list_request_write((sml_get_list_request *)message_body->data, buf);
|
||||
break;
|
||||
break;
|
||||
case SML_MESSAGE_GET_LIST_RESPONSE:
|
||||
sml_get_list_response_write((sml_get_list_response *) message_body->data, buf);
|
||||
break;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -38,22 +38,22 @@ void *sml_number_parse(sml_buffer *buf, unsigned char type, int max_size) {
|
|||
if (sml_buf_optional_is_skipped(buf)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int l, i;
|
||||
unsigned char b;
|
||||
short negative_int = 0;
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != type) {
|
||||
buf->error = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
l = sml_buf_get_next_length(buf);
|
||||
if (l < 0 || l > max_size) {
|
||||
buf->error = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
unsigned char *np = malloc(max_size);
|
||||
memset(np, 0, max_size);
|
||||
|
||||
|
@ -61,16 +61,16 @@ void *sml_number_parse(sml_buffer *buf, unsigned char type, int max_size) {
|
|||
if (type == SML_TYPE_INTEGER && (b & 128)) {
|
||||
negative_int = 1;
|
||||
}
|
||||
|
||||
|
||||
int missing_bytes = max_size - l;
|
||||
memcpy(&(np[missing_bytes]), sml_buf_get_current_buf(buf), l);
|
||||
|
||||
|
||||
if (negative_int) {
|
||||
for (i = 0; i < missing_bytes; i++) {
|
||||
np[i] = 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!(sml_number_endian() == SML_BIG_ENDIAN)) {
|
||||
sml_number_byte_swap(np, max_size);
|
||||
}
|
||||
|
@ -84,14 +84,14 @@ void sml_number_write(void *np, unsigned char type, int size, sml_buffer *buf) {
|
|||
sml_buf_optional_write(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
sml_buf_set_type_and_length(buf, type, size);
|
||||
memcpy(sml_buf_get_current_buf(buf), np, size);
|
||||
|
||||
|
||||
if (!(sml_number_endian() == SML_BIG_ENDIAN)) {
|
||||
sml_number_byte_swap(sml_buf_get_current_buf(buf), size);
|
||||
}
|
||||
|
||||
|
||||
sml_buf_update_bytes_read(buf, size);
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ void sml_number_byte_swap(unsigned char *bytes, int bytes_len) {
|
|||
int sml_number_endian() {
|
||||
int i = 1;
|
||||
char *p = (char *)&i;
|
||||
|
||||
|
||||
if (p[0] == 1)
|
||||
return SML_LITTLE_ENDIAN;
|
||||
else
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -65,19 +65,19 @@ octet_string *sml_octet_string_parse(sml_buffer *buf) {
|
|||
if (sml_buf_optional_is_skipped(buf)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int l;
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_OCTET_STRING) {
|
||||
buf->error = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
l = sml_buf_get_next_length(buf);
|
||||
if (l < 0) {
|
||||
buf->error = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
octet_string *str = sml_octet_string_init(sml_buf_get_current_buf(buf), l);
|
||||
sml_buf_update_bytes_read(buf, l);
|
||||
return str;
|
||||
|
@ -88,7 +88,7 @@ void sml_octet_string_write(octet_string *str, sml_buffer *buf) {
|
|||
sml_buf_optional_write(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_OCTET_STRING, (unsigned int) str->len);
|
||||
memcpy(sml_buf_get_current_buf(buf), str->str, str->len);
|
||||
buf->cursor += str->len;
|
||||
|
@ -129,10 +129,10 @@ uint8_t ctoi(uint8_t c){
|
|||
|
||||
if((c >= '0') && (c <= '9')) {
|
||||
ret = c - '0';
|
||||
}
|
||||
}
|
||||
else if((c >= 'a') && (c <= 'f')) {
|
||||
ret = c - 'a' + 10;
|
||||
}
|
||||
}
|
||||
else if((c >= 'A') && (c <= 'F')) {
|
||||
ret = c - 'A' + 10;
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -31,48 +31,48 @@ sml_open_request *sml_open_request_init(){
|
|||
|
||||
sml_open_request *sml_open_request_parse(sml_buffer *buf) {
|
||||
sml_open_request *msg = sml_open_request_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 7) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
msg->codepage = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->client_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->req_file_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->server_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->username = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->password = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->sml_version = sml_u8_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
return msg;
|
||||
|
||||
error:
|
||||
|
||||
error:
|
||||
sml_open_request_free(msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sml_open_request_write(sml_open_request *msg, sml_buffer *buf) {
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 7);
|
||||
|
||||
|
||||
sml_octet_string_write(msg->codepage, buf);
|
||||
sml_octet_string_write(msg->client_id, buf);
|
||||
sml_octet_string_write(msg->req_file_id, buf);
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -28,35 +28,35 @@ sml_open_response *sml_open_response_init() {
|
|||
|
||||
sml_open_response *sml_open_response_parse(sml_buffer *buf) {
|
||||
sml_open_response *msg = sml_open_response_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 6) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
msg->codepage = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->client_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->req_file_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->server_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->ref_time = sml_time_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->sml_version = sml_u8_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
return msg;
|
||||
error:
|
||||
sml_open_response_free(msg);
|
||||
|
@ -65,7 +65,7 @@ error:
|
|||
|
||||
void sml_open_response_write(sml_open_response *msg, sml_buffer *buf) {
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 7);
|
||||
|
||||
|
||||
sml_octet_string_write(msg->codepage, buf);
|
||||
sml_octet_string_write(msg->client_id, buf);
|
||||
sml_octet_string_write(msg->req_file_id, buf);
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -27,32 +27,32 @@ sml_set_proc_parameter_request *sml_set_proc_parameter_request_init() {
|
|||
|
||||
sml_set_proc_parameter_request *sml_set_proc_parameter_request_parse(sml_buffer *buf) {
|
||||
sml_set_proc_parameter_request *msg = sml_set_proc_parameter_request_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 5) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
msg->server_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->username = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->password = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->parameter_tree_path = sml_tree_path_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
msg->parameter_tree = sml_tree_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
return msg;
|
||||
error:
|
||||
sml_set_proc_parameter_request_free(msg);
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -25,12 +25,12 @@ int sml_buf_get_next_length(sml_buffer *buf) {
|
|||
int length = 0;
|
||||
unsigned char byte = sml_buf_get_current_byte(buf);
|
||||
int list = ((byte & SML_TYPE_FIELD) == SML_TYPE_LIST) ? 0 : -1;
|
||||
|
||||
|
||||
for (;buf->cursor < buf->buffer_len;) {
|
||||
byte = sml_buf_get_current_byte(buf);
|
||||
length <<= 4;
|
||||
length |= (byte & SML_LENGTH_FIELD);
|
||||
|
||||
|
||||
if ((byte & SML_ANOTHER_TL) != SML_ANOTHER_TL) {
|
||||
break;
|
||||
}
|
||||
|
@ -46,24 +46,24 @@ int sml_buf_get_next_length(sml_buffer *buf) {
|
|||
void sml_buf_set_type_and_length(sml_buffer *buf, unsigned int type, unsigned int l) {
|
||||
// set the type
|
||||
buf->buffer[buf->cursor] |= type;
|
||||
|
||||
|
||||
if (type != SML_TYPE_LIST) {
|
||||
l++;
|
||||
}
|
||||
|
||||
|
||||
if (l > SML_LENGTH_FIELD) {
|
||||
// how much shifts are necessary
|
||||
int mask_pos = (sizeof(unsigned int) * 2) - 1;
|
||||
|
||||
int mask_pos = (sizeof(unsigned int) * 2) - 1;
|
||||
|
||||
// the 4 most significant bits of l
|
||||
unsigned int mask = 0xF0 << (8 * (sizeof(unsigned int) - 1));
|
||||
|
||||
|
||||
// select the 4 most significant bits with a bit set
|
||||
while (!(mask & l)) {
|
||||
mask >>= 4;
|
||||
mask_pos--;
|
||||
}
|
||||
|
||||
|
||||
// copy the bits to the buffer
|
||||
while (mask > SML_LENGTH_FIELD) {
|
||||
buf->buffer[buf->cursor] |= SML_ANOTHER_TL;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -29,17 +29,17 @@ sml_status *sml_status_parse(sml_buffer *buf) {
|
|||
if (sml_buf_optional_is_skipped(buf)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int max = 1;
|
||||
int type = sml_buf_get_next_type(buf);
|
||||
unsigned char byte = sml_buf_get_current_byte(buf);
|
||||
|
||||
|
||||
sml_status *status = (sml_status *) malloc(sizeof(sml_status));
|
||||
status->type = type;
|
||||
switch (type) {
|
||||
case SML_TYPE_UNSIGNED:
|
||||
// get maximal size, if not all bytes are used (example: only 6 bytes for a u64)
|
||||
while (max < ((byte & SML_LENGTH_FIELD) - 1)) {
|
||||
while (max < ((byte & SML_LENGTH_FIELD) - 1)) {
|
||||
max <<= 1;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ sml_status *sml_status_parse(sml_buffer *buf) {
|
|||
sml_status_free(status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ void sml_status_write(sml_status *status, sml_buffer *buf){
|
|||
sml_buf_optional_write(buf);
|
||||
return;
|
||||
}
|
||||
sml_number_write(status->data.status8, (status->type & SML_TYPE_FIELD),
|
||||
sml_number_write(status->data.status8, (status->type & SML_TYPE_FIELD),
|
||||
(status->type & SML_LENGTH_FIELD), buf);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -32,27 +32,27 @@ sml_time *sml_time_parse(sml_buffer *buf) {
|
|||
if (sml_buf_optional_is_skipped(buf)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
sml_time *tme = sml_time_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 2) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
tme->tag = sml_u8_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
tme->data.timestamp = sml_u32_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
return tme;
|
||||
|
||||
|
||||
error:
|
||||
sml_time_free(tme);
|
||||
return 0;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -34,19 +34,19 @@ size_t sml_transport_read(int fd, unsigned char *buffer, size_t max_len) {
|
|||
fd_set readfds;
|
||||
FD_ZERO(&readfds);
|
||||
FD_SET(fd, &readfds);
|
||||
|
||||
|
||||
unsigned char byte;
|
||||
unsigned char buf[max_len];
|
||||
int esc = 0, start = 0, i = 0, end = 0, r;
|
||||
|
||||
|
||||
while (i < max_len) {
|
||||
select(fd + 1, &readfds, 0, 0, 0);
|
||||
if (FD_ISSET(fd, &readfds)) {
|
||||
|
||||
|
||||
if (!i) { // read until escaped start sequence;
|
||||
r = read(fd, &byte, 1);
|
||||
if (r <= 0) continue;
|
||||
|
||||
|
||||
if (esc == 4) {
|
||||
if (byte == 0x01) {
|
||||
buf[esc + start++] = byte;
|
||||
|
@ -74,7 +74,7 @@ size_t sml_transport_read(int fd, unsigned char *buffer, size_t max_len) {
|
|||
else { // read the message
|
||||
r = read(fd, (void *)(&(buf[i])), 1);
|
||||
if (r <= 0) continue;
|
||||
|
||||
|
||||
if (esc == 4) {
|
||||
if (end) {
|
||||
end++;
|
||||
|
@ -106,17 +106,17 @@ size_t sml_transport_read(int fd, unsigned char *buffer, size_t max_len) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void sml_transport_listen(int fd, void (*sml_transport_receiver)(unsigned char *buffer, size_t buffer_len)) {
|
||||
unsigned char buffer[MC_SML_BUFFER_LEN];
|
||||
size_t bytes;
|
||||
|
||||
|
||||
while (1) {
|
||||
bytes = sml_transport_read(fd, buffer, MC_SML_BUFFER_LEN);
|
||||
|
||||
|
||||
if (bytes > 0) {
|
||||
sml_transport_receiver(buffer, bytes);
|
||||
}
|
||||
|
@ -124,39 +124,39 @@ void sml_transport_listen(int fd, void (*sml_transport_receiver)(unsigned char *
|
|||
}
|
||||
|
||||
int sml_transport_write(int fd, sml_file *file) {
|
||||
|
||||
|
||||
unsigned char start_seq[] = {0x1b, 0x1b, 0x1b, 0x1b, 0x01, 0x01, 0x01, 0x01};
|
||||
unsigned char end_seq[] = {0x1b, 0x1b, 0x1b, 0x1b, 0x1a};
|
||||
sml_buffer *buf = file->buf;
|
||||
buf->cursor = 0;
|
||||
|
||||
|
||||
// add start sequence
|
||||
memcpy(sml_buf_get_current_buf(buf), start_seq, 8);
|
||||
buf->cursor += 8;
|
||||
|
||||
|
||||
// add file
|
||||
sml_file_write(file);
|
||||
|
||||
|
||||
// add padding bytes
|
||||
int padding = (buf->cursor % 4) ? (4 - buf->cursor % 4) : 0;
|
||||
if (padding) {
|
||||
// write zeroed bytes
|
||||
// write zeroed bytes
|
||||
memset(sml_buf_get_current_buf(buf), 0, padding);
|
||||
buf->cursor += padding;
|
||||
}
|
||||
|
||||
|
||||
// begin end sequence
|
||||
memcpy(sml_buf_get_current_buf(buf), end_seq, 5);
|
||||
buf->cursor += 5;
|
||||
|
||||
|
||||
// add padding info
|
||||
buf->buffer[buf->cursor++] = (unsigned char) padding;
|
||||
|
||||
|
||||
// add crc checksum
|
||||
u16 crc = sml_crc16_calculate(buf->buffer, buf->cursor);
|
||||
buf->buffer[buf->cursor++] = (unsigned char) ((crc & 0xFF00) >> 8);
|
||||
buf->buffer[buf->cursor++] = (unsigned char) (crc & 0x00FF);
|
||||
|
||||
|
||||
size_t wr = write(fd, buf->buffer, buf->cursor);
|
||||
if (wr == buf->cursor) {
|
||||
return wr;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -34,15 +34,15 @@ sml_tree_path *sml_tree_path_parse(sml_buffer *buf) {
|
|||
if (sml_buf_optional_is_skipped(buf)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
sml_tree_path *tree_path = sml_tree_path_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
octet_string *s;
|
||||
octet_string *s;
|
||||
int elems;
|
||||
for (elems = sml_buf_get_next_length(buf); elems > 0; elems--) {
|
||||
s = sml_octet_string_parse(buf);
|
||||
|
@ -51,7 +51,7 @@ sml_tree_path *sml_tree_path_parse(sml_buffer *buf) {
|
|||
sml_tree_path_add_path_entry(tree_path, s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return tree_path;
|
||||
|
||||
error:
|
||||
|
@ -62,7 +62,7 @@ error:
|
|||
|
||||
void sml_tree_path_add_path_entry(sml_tree_path *tree_path, octet_string *entry) {
|
||||
tree_path->path_entries_len++;
|
||||
tree_path->path_entries = (octet_string **) realloc(tree_path->path_entries,
|
||||
tree_path->path_entries = (octet_string **) realloc(tree_path->path_entries,
|
||||
sizeof(octet_string *) * tree_path->path_entries_len);
|
||||
tree_path->path_entries[tree_path->path_entries_len - 1] = entry;
|
||||
|
||||
|
@ -73,7 +73,7 @@ void sml_tree_path_write(sml_tree_path *tree_path, sml_buffer *buf) {
|
|||
sml_buf_optional_write(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int i;
|
||||
if (tree_path->path_entries && tree_path->path_entries_len > 0) {
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, tree_path->path_entries_len);
|
||||
|
@ -109,31 +109,31 @@ sml_tree *sml_tree_parse(sml_buffer *buf){
|
|||
if (sml_buf_optional_is_skipped(buf)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
sml_tree *tree = sml_tree_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 3) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
tree->parameter_name = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
tree->parameter_value = sml_proc_par_value_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
if (!sml_buf_optional_is_skipped(buf)) {
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
sml_tree *c;
|
||||
int elems;
|
||||
for (elems = sml_buf_get_next_length(buf); elems > 0; elems--) {
|
||||
|
@ -144,7 +144,7 @@ sml_tree *sml_tree_parse(sml_buffer *buf){
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return tree;
|
||||
error:
|
||||
sml_tree_free(tree);
|
||||
|
@ -153,7 +153,7 @@ error:
|
|||
|
||||
void sml_tree_add_tree(sml_tree *base_tree, sml_tree *tree) {
|
||||
base_tree->child_list_len++;
|
||||
base_tree->child_list = (sml_tree **) realloc(base_tree->child_list,
|
||||
base_tree->child_list = (sml_tree **) realloc(base_tree->child_list,
|
||||
sizeof(sml_tree *) * base_tree->child_list_len);
|
||||
base_tree->child_list[base_tree->child_list_len - 1] = tree;
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ void sml_tree_free(sml_tree *tree){
|
|||
for (i = 0; i < tree->child_list_len; i++) {
|
||||
sml_tree_free(tree->child_list[i]);
|
||||
}
|
||||
|
||||
|
||||
free(tree);
|
||||
}
|
||||
}
|
||||
|
@ -176,23 +176,23 @@ void sml_tree_write(sml_tree *tree, sml_buffer *buf) {
|
|||
sml_buf_optional_write(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int i;
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 3);
|
||||
|
||||
sml_octet_string_write(tree->parameter_name, buf);
|
||||
sml_proc_par_value_write(tree->parameter_value, buf);
|
||||
|
||||
|
||||
if (tree->child_list && tree->child_list_len > 0) {
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, tree->child_list_len);
|
||||
|
||||
|
||||
for (i = 0; i < tree->child_list_len; i++) {
|
||||
sml_tree_write(tree->child_list[i], buf);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sml_buf_optional_write(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -208,22 +208,22 @@ sml_proc_par_value *sml_proc_par_value_parse(sml_buffer *buf) {
|
|||
if (sml_buf_optional_is_skipped(buf)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
sml_proc_par_value *ppv = sml_proc_par_value_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 2) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
ppv->tag = sml_u8_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
switch (*(ppv->tag)) {
|
||||
case SML_PROC_PAR_VALUE_TAG_VALUE:
|
||||
ppv->data.value = sml_value_parse(buf);
|
||||
|
@ -241,9 +241,9 @@ sml_proc_par_value *sml_proc_par_value_parse(sml_buffer *buf) {
|
|||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
return ppv;
|
||||
|
||||
|
||||
error:
|
||||
sml_proc_par_value_free(ppv);
|
||||
return 0;
|
||||
|
@ -254,7 +254,7 @@ void sml_proc_par_value_write(sml_proc_par_value *value, sml_buffer *buf) {
|
|||
sml_buf_optional_write(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 2);
|
||||
sml_u8_write(value->tag, buf);
|
||||
|
||||
|
@ -278,7 +278,7 @@ void sml_proc_par_value_write(sml_proc_par_value *value, sml_buffer *buf) {
|
|||
|
||||
void sml_proc_par_value_free(sml_proc_par_value *ppv){
|
||||
if (ppv) {
|
||||
|
||||
|
||||
if (ppv->tag) {
|
||||
switch (*(ppv->tag)) {
|
||||
case SML_PROC_PAR_VALUE_TAG_VALUE:
|
||||
|
@ -301,7 +301,7 @@ void sml_proc_par_value_free(sml_proc_par_value *ppv){
|
|||
sml_number_free(ppv->tag);
|
||||
}
|
||||
else {
|
||||
// Without the tag, there might be a memory leak.
|
||||
// Without the tag, there might be a memory leak.
|
||||
if (ppv->data.value) {
|
||||
free(ppv->data.value);
|
||||
}
|
||||
|
@ -323,74 +323,74 @@ sml_tupel_entry *sml_tupel_entry_parse(sml_buffer *buf) {
|
|||
if (sml_buf_optional_is_skipped(buf)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
sml_tupel_entry *tupel = sml_tupel_entry_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 23) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
tupel->server_id = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
tupel->sec_index = sml_time_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
tupel->status = sml_u64_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
tupel->unit_pA = sml_unit_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
tupel->scaler_pA = sml_i8_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
tupel->value_pA = sml_i64_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
tupel->unit_R1 = sml_unit_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
tupel->scaler_R1 = sml_i8_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
tupel->value_R1 = sml_i64_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
tupel->unit_R4 = sml_unit_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
tupel->scaler_R4 = sml_i8_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
tupel->value_R4 = sml_i64_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
tupel->signature_pA_R1_R4 = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
tupel->unit_mA = sml_unit_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
tupel->scaler_mA = sml_i8_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
tupel->value_mA = sml_i64_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
tupel->unit_R2 = sml_unit_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
tupel->scaler_R2 = sml_i8_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
tupel->value_R2 = sml_i64_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
tupel->unit_R3 = sml_unit_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
tupel->scaler_R3 = sml_i8_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
tupel->value_R3 = sml_i64_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
tupel->signature_mA_R2_R3 = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
return tupel;
|
||||
|
||||
error:
|
||||
|
@ -403,9 +403,9 @@ void sml_tupel_entry_write(sml_tupel_entry *tupel, sml_buffer *buf) {
|
|||
sml_buf_optional_write(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 23);
|
||||
|
||||
|
||||
sml_octet_string_write(tupel->server_id, buf);
|
||||
sml_time_write(tupel->sec_index, buf);
|
||||
sml_u64_write(tupel->status, buf);
|
||||
|
@ -445,35 +445,35 @@ void sml_tupel_entry_free(sml_tupel_entry *tupel) {
|
|||
sml_octet_string_free(tupel->server_id);
|
||||
sml_time_free(tupel->sec_index);
|
||||
sml_number_free(tupel->status);
|
||||
|
||||
|
||||
sml_unit_free(tupel->unit_pA);
|
||||
sml_number_free(tupel->scaler_pA);
|
||||
sml_number_free(tupel->value_pA);
|
||||
|
||||
|
||||
sml_unit_free(tupel->unit_R1);
|
||||
sml_number_free(tupel->scaler_R1);
|
||||
sml_number_free(tupel->value_R1);
|
||||
|
||||
|
||||
sml_unit_free(tupel->unit_R4);
|
||||
sml_number_free(tupel->scaler_R4);
|
||||
sml_number_free(tupel->value_R4);
|
||||
|
||||
|
||||
sml_octet_string_free(tupel->signature_pA_R1_R4);
|
||||
|
||||
|
||||
sml_unit_free(tupel->unit_mA);
|
||||
sml_number_free(tupel->scaler_mA);
|
||||
sml_number_free(tupel->value_mA);
|
||||
|
||||
|
||||
sml_unit_free(tupel->unit_R2);
|
||||
sml_number_free(tupel->scaler_R2);
|
||||
sml_number_free(tupel->value_R2);
|
||||
|
||||
|
||||
sml_unit_free(tupel->unit_R3);
|
||||
sml_number_free(tupel->scaler_R3);
|
||||
sml_number_free(tupel->value_R3);
|
||||
|
||||
|
||||
sml_octet_string_free(tupel->signature_mA_R2_R3);
|
||||
|
||||
|
||||
free(tupel);
|
||||
}
|
||||
}
|
||||
|
@ -492,36 +492,36 @@ sml_period_entry *sml_period_entry_parse(sml_buffer *buf) {
|
|||
if (sml_buf_optional_is_skipped(buf)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
sml_period_entry *period = sml_period_entry_init();
|
||||
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (sml_buf_get_next_length(buf) != 5) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
period->obj_name = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
period->unit = sml_unit_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
period->scaler = sml_i8_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
period->value = sml_value_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
period->value_signature = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
|
||||
return period;
|
||||
|
||||
|
||||
error:
|
||||
sml_period_entry_free(period);
|
||||
return 0;
|
||||
|
@ -532,9 +532,9 @@ void sml_period_entry_write(sml_period_entry *period, sml_buffer *buf) {
|
|||
sml_buf_optional_write(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 5);
|
||||
|
||||
|
||||
sml_octet_string_write(period->obj_name, buf);
|
||||
sml_unit_write(period->unit, buf);
|
||||
sml_i8_write(period->scaler, buf);
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -25,11 +25,11 @@ sml_value *sml_value_parse(sml_buffer *buf) {
|
|||
if (sml_buf_optional_is_skipped(buf)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int max = 1;
|
||||
int type = sml_buf_get_next_type(buf);
|
||||
unsigned char byte = sml_buf_get_current_byte(buf);
|
||||
|
||||
|
||||
sml_value *value = (sml_value *) malloc(sizeof(sml_value));
|
||||
value->type = type;
|
||||
|
||||
|
@ -43,10 +43,10 @@ sml_value *sml_value_parse(sml_buffer *buf) {
|
|||
case SML_TYPE_UNSIGNED:
|
||||
case SML_TYPE_INTEGER:
|
||||
// get maximal size, if not all bytes are used (example: only 6 bytes for a u64)
|
||||
while (max < ((byte & SML_LENGTH_FIELD) - 1)) {
|
||||
while (max < ((byte & SML_LENGTH_FIELD) - 1)) {
|
||||
max <<= 1;
|
||||
}
|
||||
|
||||
|
||||
value->data.uint8 = sml_number_parse(buf, type, max);
|
||||
value->type |= max;
|
||||
break;
|
||||
|
@ -58,7 +58,7 @@ sml_value *sml_value_parse(sml_buffer *buf) {
|
|||
sml_value_free(value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ void sml_value_write(sml_value *value, sml_buffer *buf) {
|
|||
sml_buf_optional_write(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch (value->type & SML_TYPE_FIELD) {
|
||||
case SML_TYPE_OCTET_STRING:
|
||||
sml_octet_string_write(value->data.bytes, buf);
|
||||
|
@ -77,7 +77,7 @@ void sml_value_write(sml_value *value, sml_buffer *buf) {
|
|||
break;
|
||||
case SML_TYPE_UNSIGNED:
|
||||
case SML_TYPE_INTEGER:
|
||||
sml_number_write(value->data.uint8, (value->type & SML_TYPE_FIELD),
|
||||
sml_number_write(value->data.uint8, (value->type & SML_TYPE_FIELD),
|
||||
(value->type & SML_LENGTH_FIELD), buf);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -82,7 +82,7 @@ TEST_GROUP_RUNNER(sml_boolean) {
|
|||
RUN_TEST_CASE(sml_boolean, init);
|
||||
RUN_TEST_CASE(sml_boolean, parse_true);
|
||||
RUN_TEST_CASE(sml_boolean, parse_false);
|
||||
RUN_TEST_CASE(sml_boolean, parse_optional);
|
||||
RUN_TEST_CASE(sml_boolean, parse_optional);
|
||||
RUN_TEST_CASE(sml_boolean, write_true);
|
||||
RUN_TEST_CASE(sml_boolean, write_false);
|
||||
RUN_TEST_CASE(sml_boolean, write_optional);
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -29,11 +29,11 @@ TEST_SETUP(sml_buffer) {
|
|||
}
|
||||
|
||||
TEST_TEAR_DOWN(sml_buffer) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
TEST(sml_buffer, init_defaults) {
|
||||
|
||||
|
||||
TEST_ASSERT_NOT_NULL(buf);
|
||||
TEST_ASSERT_NOT_NULL(buf->buffer);
|
||||
TEST_ASSERT_EQUAL(buffer_len, buf->buffer_len);
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -50,7 +50,7 @@ TEST(sml_list, add) {
|
|||
TEST(sml_list, parse_two_entries) {
|
||||
hex2binary("727702610101010142000177026101010101420001", sml_buf_get_current_buf(buf));
|
||||
sml_list *l = sml_list_parse(buf);
|
||||
|
||||
|
||||
TEST_ASSERT_FALSE(sml_buf_has_errors(buf));
|
||||
TEST_ASSERT_NOT_NULL(l);
|
||||
TEST_ASSERT_NOT_NULL(l->next);
|
||||
|
@ -70,7 +70,7 @@ TEST(sml_list, write_one_entry) {
|
|||
l->value = sml_value_init();
|
||||
l->value->type = SML_TYPE_OCTET_STRING;
|
||||
l->value->data.bytes = sml_octet_string_init((unsigned char *)"Hallo", 5);
|
||||
|
||||
|
||||
sml_list_write(l, buf);
|
||||
expected_buf(buf, "71770648616C6C6F010101010648616C6C6F01", 19);
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ TEST(sml_sequence, init) {
|
|||
|
||||
TEST(sml_sequence, parse_octet_string) {
|
||||
hex2binary("720648616C6C6F0648616C6C6F", sml_buf_get_current_buf(buf));
|
||||
|
||||
|
||||
sml_sequence *seq = sml_sequence_parse(buf, (void *) &sml_octet_string_parse, (void (*)(void *))&sml_octet_string_free);
|
||||
TEST_ASSERT_NOT_NULL(seq);
|
||||
TEST_ASSERT_EQUAL(2, seq->elems_len);
|
||||
|
@ -120,7 +120,7 @@ TEST(sml_sequence, write_octet_string) {
|
|||
sml_sequence *seq = sml_sequence_init((void (*)(void *))&sml_octet_string_free);
|
||||
sml_sequence_add(seq, sml_octet_string_init((unsigned char *)"Hallo", 5));
|
||||
sml_sequence_add(seq, sml_octet_string_init((unsigned char *)"Hallo", 5));
|
||||
|
||||
|
||||
sml_sequence_write(seq, buf, (void (*)(void *, sml_buffer *))&sml_octet_string_write);
|
||||
expected_buf(buf, "720648616C6C6F0648616C6C6F", 13);
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -152,7 +152,7 @@ TEST_GROUP_RUNNER(sml_number) {
|
|||
RUN_TEST_CASE(sml_number, parse_int32);
|
||||
RUN_TEST_CASE(sml_number, parse_int64);
|
||||
RUN_TEST_CASE(sml_number, parse_int64_fewer_bytes);
|
||||
|
||||
|
||||
RUN_TEST_CASE(sml_number, write_unsigned8);
|
||||
RUN_TEST_CASE(sml_number, write_integer32);
|
||||
RUN_TEST_CASE(sml_number, write_integer8_optional);
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -40,14 +40,14 @@ TEST(sml_octet_string, init) {
|
|||
|
||||
TEST(sml_octet_string, parse) {
|
||||
hex2binary("0648616C6C6F", sml_buf_get_current_buf(buf));
|
||||
|
||||
|
||||
octet_string *str = sml_octet_string_parse(buf);
|
||||
expected_octet_string(str, "Hallo", 5);
|
||||
}
|
||||
|
||||
TEST(sml_octet_string, parse_multiple_tl_fields) {
|
||||
hex2binary("8102616161616F6161616161616161616161", sml_buf_get_current_buf(buf));
|
||||
|
||||
|
||||
octet_string *str = sml_octet_string_parse(buf);
|
||||
expected_octet_string(str, "aaaaoaaaaaaaaaaa", 16);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ TEST(sml_octet_string, parse_multiple_tl_fields) {
|
|||
TEST(sml_octet_string, parse_optional) {
|
||||
hex2binary("01", sml_buf_get_current_buf(buf));
|
||||
octet_string *str = sml_octet_string_parse(buf);
|
||||
|
||||
|
||||
TEST_ASSERT_FALSE(sml_buf_has_errors(buf));
|
||||
TEST_ASSERT_NULL(str);
|
||||
TEST_ASSERT_EQUAL(1, buf->cursor);
|
||||
|
@ -76,7 +76,7 @@ TEST(sml_octet_string, cmp) {
|
|||
octet_string *s1 = sml_octet_string_init((unsigned char *)"Hallo", 5);
|
||||
octet_string *s2 = sml_octet_string_init((unsigned char *)"Hi", 2);
|
||||
octet_string *s3 = sml_octet_string_init((unsigned char *)"Hallo", 5);
|
||||
|
||||
|
||||
TEST_ASSERT_TRUE(sml_octet_string_cmp(s1, s2) != 0);
|
||||
TEST_ASSERT_EQUAL(0, sml_octet_string_cmp(s1, s3));
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -40,7 +40,7 @@ TEST(sml_status, init) {
|
|||
TEST(sml_status, parse_status8) {
|
||||
hex2binary("6201", sml_buf_get_current_buf(buf));
|
||||
sml_status *s = sml_status_parse(buf);
|
||||
|
||||
|
||||
TEST_ASSERT_NOT_NULL(s);
|
||||
TEST_ASSERT_EQUAL(1, *(s->data.status8));
|
||||
TEST_ASSERT_EQUAL((SML_TYPE_UNSIGNED | SML_TYPE_NUMBER_8), s->type);
|
||||
|
@ -49,7 +49,7 @@ TEST(sml_status, parse_status8) {
|
|||
TEST(sml_status, parse_optional) {
|
||||
hex2binary("01", sml_buf_get_current_buf(buf));
|
||||
sml_status *s = sml_status_parse(buf);
|
||||
|
||||
|
||||
TEST_ASSERT_NULL(s);
|
||||
TEST_ASSERT_FALSE(sml_buf_has_errors(buf));
|
||||
TEST_ASSERT_EQUAL(1, buf->cursor);
|
||||
|
@ -59,7 +59,7 @@ TEST(sml_status, write_status32) {
|
|||
sml_status *s = sml_status_init();
|
||||
s->type = SML_TYPE_UNSIGNED | SML_TYPE_NUMBER_32;
|
||||
s->data.status32 = sml_u32_init(42);
|
||||
|
||||
|
||||
sml_status_write(s, buf);
|
||||
expected_buf(buf, "650000002A", 5);
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -40,7 +40,7 @@ TEST(sml_time, init) {
|
|||
TEST(sml_time, parse_sec_index) {
|
||||
hex2binary("72620165000000FF", sml_buf_get_current_buf(buf));
|
||||
sml_time *t = sml_time_parse(buf);
|
||||
|
||||
|
||||
TEST_ASSERT_NOT_NULL(t);
|
||||
TEST_ASSERT_EQUAL(SML_TIME_SEC_INDEX, *(t->tag));
|
||||
TEST_ASSERT_EQUAL(8, buf->cursor);
|
||||
|
@ -49,7 +49,7 @@ TEST(sml_time, parse_sec_index) {
|
|||
TEST(sml_time, parse_timestamp) {
|
||||
hex2binary("72620265000000FF", sml_buf_get_current_buf(buf));
|
||||
sml_time *t = sml_time_parse(buf);
|
||||
|
||||
|
||||
TEST_ASSERT_NOT_NULL(t);
|
||||
TEST_ASSERT_EQUAL(SML_TIME_TIMESTAMP, *(t->tag));
|
||||
TEST_ASSERT_EQUAL(8, buf->cursor);
|
||||
|
@ -58,7 +58,7 @@ TEST(sml_time, parse_timestamp) {
|
|||
TEST(sml_time, parse_optional) {
|
||||
hex2binary("01", sml_buf_get_current_buf(buf));
|
||||
sml_time *t = sml_time_parse(buf);
|
||||
|
||||
|
||||
TEST_ASSERT_NULL(t);
|
||||
TEST_ASSERT_EQUAL(1, buf->cursor);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ TEST(sml_time, write_sec_index) {
|
|||
sml_time *t = sml_time_init();
|
||||
t->data.sec_index = sml_u32_init(255);
|
||||
t->tag = sml_u8_init(SML_TIME_SEC_INDEX);
|
||||
|
||||
|
||||
sml_time_write(t, buf);
|
||||
expected_buf(buf, "72620165000000FF", 8);
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -41,7 +41,7 @@ TEST(sml_tree, init) {
|
|||
TEST(sml_tree, add_tree) {
|
||||
sml_tree *t = sml_tree_init();
|
||||
sml_tree_add_tree(t, sml_tree_init());
|
||||
|
||||
|
||||
TEST_ASSERT_NOT_NULL(t->child_list[0]);
|
||||
TEST_ASSERT_EQUAL(1, t->child_list_len);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ TEST(sml_tree, write) {
|
|||
TEST(sml_tree, parse_with_child) {
|
||||
hex2binary("730648616C6C6F0171730648616C6C6F0101", sml_buf_get_current_buf(buf));
|
||||
sml_tree *t = sml_tree_parse(buf);
|
||||
|
||||
|
||||
TEST_ASSERT_NOT_NULL(t);
|
||||
TEST_ASSERT_NOT_NULL(t->child_list[0]);
|
||||
TEST_ASSERT_EQUAL(1, t->child_list_len);
|
||||
|
@ -65,7 +65,7 @@ TEST(sml_tree, parse_with_child) {
|
|||
TEST(sml_tree, parse_with_error_child) {
|
||||
hex2binary("730648616C6C6F0171720648616C6C6F0101", sml_buf_get_current_buf(buf));
|
||||
sml_tree *t = sml_tree_parse(buf);
|
||||
|
||||
|
||||
TEST_ASSERT_NULL(t);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -40,7 +40,7 @@ TEST(sml_value, init) {
|
|||
TEST(sml_value, parse_octet_string) {
|
||||
hex2binary("0648616C6C6F", sml_buf_get_current_buf(buf));
|
||||
sml_value *v = sml_value_parse(buf);
|
||||
|
||||
|
||||
TEST_ASSERT_NOT_NULL(v);
|
||||
TEST_ASSERT_EQUAL(SML_TYPE_OCTET_STRING, v->type);
|
||||
expected_octet_string(v->data.bytes, "Hallo", 5);
|
||||
|
@ -50,7 +50,7 @@ TEST(sml_value, parse_boolean) {
|
|||
hex2binary("4200", sml_buf_get_current_buf(buf));
|
||||
sml_value *v = sml_value_parse(buf);
|
||||
|
||||
TEST_ASSERT_NOT_NULL(v);
|
||||
TEST_ASSERT_NOT_NULL(v);
|
||||
TEST_ASSERT_EQUAL(SML_TYPE_BOOLEAN, v->type);
|
||||
TEST_ASSERT_FALSE(*(v->data.boolean));
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ TEST(sml_value, parse_boolean) {
|
|||
TEST(sml_value, parse_unsigned32) {
|
||||
hex2binary("6500000001", sml_buf_get_current_buf(buf));
|
||||
sml_value *v = sml_value_parse(buf);
|
||||
|
||||
|
||||
TEST_ASSERT_NOT_NULL(v);
|
||||
TEST_ASSERT_EQUAL(1, *(v->data.uint32));
|
||||
TEST_ASSERT_EQUAL((SML_TYPE_UNSIGNED | SML_TYPE_NUMBER_32), v->type);
|
||||
|
@ -69,7 +69,7 @@ TEST(sml_value, parse_unsigned32) {
|
|||
TEST(sml_value, parse_integer64_fewer_bytes) {
|
||||
hex2binary("58FFFFFFFFFFFF0F", sml_buf_get_current_buf(buf));
|
||||
sml_value *v = sml_value_parse(buf);
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL(-241, *(v->data.int64));
|
||||
TEST_ASSERT_EQUAL((SML_TYPE_INTEGER | SML_TYPE_NUMBER_64), v->type);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ TEST(sml_value, parse_integer64_fewer_bytes) {
|
|||
TEST(sml_value, parse_optional) {
|
||||
hex2binary("01", sml_buf_get_current_buf(buf));
|
||||
sml_value *v = sml_value_parse(buf);
|
||||
|
||||
|
||||
TEST_ASSERT_NULL(v);
|
||||
TEST_ASSERT_EQUAL(1, buf->cursor);
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ TEST(sml_value, write_octet_string) {
|
|||
sml_value *v = sml_value_init();
|
||||
v->type = SML_TYPE_OCTET_STRING;
|
||||
v->data.bytes = sml_octet_string_init((unsigned char *)"Hallo", 5);
|
||||
|
||||
|
||||
sml_value_write(v, buf);
|
||||
expected_buf(buf, "0648616C6C6F", 6);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ TEST(sml_value, write_boolean) {
|
|||
sml_value *v = sml_value_init();
|
||||
v->type = SML_TYPE_BOOLEAN;
|
||||
v->data.boolean = sml_boolean_init(SML_BOOLEAN_FALSE);
|
||||
|
||||
|
||||
sml_value_write(v, buf);
|
||||
expected_buf(buf, "4200", 2);
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ TEST(sml_value, write_unsigned32) {
|
|||
sml_value *v = sml_value_init();
|
||||
v->type = SML_TYPE_UNSIGNED | SML_TYPE_NUMBER_32;
|
||||
v->data.uint32 = sml_u32_init(42);
|
||||
|
||||
|
||||
sml_value_write(v, buf);
|
||||
expected_buf(buf, "650000002A", 5);
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ TEST(sml_value, write_integer16) {
|
|||
sml_value *v = sml_value_init();
|
||||
v->type = SML_TYPE_INTEGER | SML_TYPE_NUMBER_16;
|
||||
v->data.int16 = sml_i16_init(-5);
|
||||
|
||||
|
||||
sml_value_write(v, buf);
|
||||
expected_buf(buf, "53FFFB", 3);
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
|||
|
||||
uint8_t test_helper_ctoi(uint8_t c){
|
||||
uint8_t ret = 0;
|
||||
|
||||
|
||||
if((c >= '0') && (c <= '9')){
|
||||
ret = c - '0';
|
||||
} else if((c >= 'a') && (c <= 'f')){
|
||||
|
@ -31,7 +31,7 @@ uint8_t test_helper_ctoi(uint8_t c){
|
|||
} else if((c >= 'A') && (c <= 'F')){
|
||||
ret = c - 'A' + 10;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -26,4 +26,4 @@ int hex2binary(char *hex, unsigned char *buf);
|
|||
void expected_buf(sml_buffer *buf, char *hex, int len);
|
||||
void expected_octet_string(octet_string *str, char *content, int len);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
|
||||
// DAI-Labor, TU-Berlin
|
||||
//
|
||||
//
|
||||
// This file is part of libSML.
|
||||
//
|
||||
//
|
||||
// libSML is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// libSML 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 General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libSML. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "unity/unity_fixture.h"
|
||||
#include "unity/unity_fixture.h"
|
||||
|
||||
static void runAllTests() {
|
||||
RUN_TEST_GROUP(sml_octet_string);
|
||||
|
|
Loading…
Add table
Reference in a new issue