Skip to content

Commit cc43d97

Browse files
committed
Merge branch 'release/1.2.0'
2 parents 5e446ea + 4778de7 commit cc43d97

9 files changed

+96
-46
lines changed

CMakeLists.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)
22

33
project(libastphonenumber)
44
set(libastphonenumber_VERSION_MAJOR 1)
5-
set(libastphonenumber_VERSION_MINOR 1)
5+
set(libastphonenumber_VERSION_MINOR 2)
66

77
if(UNIX)
88
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++0x")
@@ -50,7 +50,8 @@ target_link_libraries(libastphonenumber_tester dl)
5050

5151
add_executable(
5252
libastphonenumber_static_tester
53-
"test/test_info.c"
53+
"test/display.c"
54+
"test/tester_static.c"
5455
)
5556
target_link_libraries(libastphonenumber_static_tester astphonenumber)
5657

asterisk/app_numformat.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
</parameter>
130130
</syntax>
131131
<description>
132-
<para>This functionn returns information about a phone number.</para>
132+
<para>This function returns information about a phone number.</para>
133133
</description>
134134
</function>
135135
<function name="REGION_INFO" language="en_US">
@@ -150,7 +150,7 @@
150150
</parameter>
151151
</syntax>
152152
<description>
153-
<para>This functionn returns information about a region.</para>
153+
<para>This function returns information about a region.</para>
154154
</description>
155155
</function>
156156
***/
@@ -254,7 +254,7 @@ static char *cli_formatnum_e164(struct ast_cli_entry *e, int cmd, struct ast_cli
254254

255255
memset(buf, 0, 100);
256256

257-
ast_cli(a->fd, "Original inforamtion\n");
257+
ast_cli(a->fd, "Original information\n");
258258
ast_cli(a->fd, " - Number: %s\n", number);
259259
ast_cli(a->fd, " - Country: %s\n", country);
260260

@@ -466,9 +466,9 @@ static int load_module(void)
466466
ast_cli_register_multiple(cli_formatnum, ARRAY_LEN(cli_formatnum));
467467

468468
/* Load external module */
469-
lib_astphonenumber_handle = dlopen("/usr/lib/libastphonenumber.so", RTLD_LAZY);
469+
lib_astphonenumber_handle = dlopen("/usr/lib/libastphonenumber.so.1", RTLD_LAZY);
470470
if (!lib_astphonenumber_handle){
471-
ast_log(LOG_WARNING, "Unable to load libastphonenumber.so: %s\n", dlerror());
471+
ast_log(LOG_WARNING, "Unable to load libastphonenumber.so.1: %s\n", dlerror());
472472
return 1;
473473
}
474474
// Load functions
@@ -479,7 +479,7 @@ static int load_module(void)
479479
get_number_type_fn = (enum phone_type (*)(char*, char*)) dlsym(lib_astphonenumber_handle, "get_number_type");
480480
get_country_code_for_region_fn = (int (*)(char*)) dlsym(lib_astphonenumber_handle, "get_country_code_for_region");
481481
if ((error = dlerror()) != NULL){
482-
ast_log(LOG_WARNING, "Unable to load functions on libastphonenumber.so: %s\n", error);
482+
ast_log(LOG_WARNING, "Unable to load functions on libastphonenumber.so.1: %s\n", error);
483483
return 1;
484484
}
485485

debian/changelog

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
libastphonenumber (1.2.0) all; urgency=medium
2+
3+
* Improvment: Remove some char when for some formatting
4+
* Improvement: Review testing section
5+
* Bugfix: Link to the right library version
6+
* Bugfix: Fix debian installation issue between both packages
7+
* Bugfix: Language typo issue
8+
9+
-- Sebastien De Fauw <sdefauw@gmail.com> Mon, 29 Apr 2019 11:18:31 +0200
10+
111
libastphonenumber (1.1.0) all; urgency=low
212

313
* Feature: Embeds a testing binary of the library

debian/libastphonenumber.install

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
usr/lib/libast*.so
2-
usr/bin/libast*
1+
usr/lib/libast*.so.*
2+
usr/bin/libast*

src/formatting.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
#include "phonenumbers/phonenumber.pb.h"
88
#include "phonenumbers/phonenumberutil.h"
99

10-
#define REMOVE_SPACES(x) x.erase(std::remove(x.begin(), x.end(), ' '), x.end())
10+
#define REMOVE_CHAR(x, c) ((x).erase(std::remove((x).begin(), (x).end(), (c)), (x).end()))
11+
#define REMOVE_SPACES(x) (REMOVE_CHAR(x, ' '))
12+
#define REMOVE_DASHES(x) (REMOVE_CHAR(x, '-'))
1113

1214
using i18n::phonenumbers::PhoneNumber;
1315
using i18n::phonenumbers::PhoneNumberUtil;
@@ -42,13 +44,17 @@ int num_format(char* number, char* country, enum phone_format type, char* format
4244
case EXTERNAL_CALL:
4345
phone_util.FormatOutOfCountryCallingNumber(pnumber, country, &formatted_number);
4446
REMOVE_SPACES(formatted_number);
47+
REMOVE_DASHES(formatted_number);
4548
break;
4649
case NATIONAL:
4750
phone_util.Format(pnumber, PhoneNumberUtil::NATIONAL, &formatted_number);
4851
break;
4952
case NATIONAL_COMPACT:
5053
phone_util.Format(pnumber, PhoneNumberUtil::NATIONAL, &formatted_number);
5154
REMOVE_SPACES(formatted_number);
55+
REMOVE_DASHES(formatted_number);
56+
REMOVE_CHAR(formatted_number, ')');
57+
REMOVE_CHAR(formatted_number, '(');
5258
break;
5359
case NATIONAL_SHORT:
5460
formatted_number = std::to_string(pnumber.national_number());

test/test_info.c test/display.c

+1-34
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
2-
#include <stdio.h>
3-
#include <stdlib.h>
4-
5-
#include "../src/regioninfo.h"
6-
#include "../src/numinfo.h"
7-
#include "../src/formatting.h"
8-
9-
#define BOOL2STR(b) b ? "Yes" : "No"
10-
1+
#include "display.h"
112

123
void print_region_info(char* country) {
134

@@ -55,27 +46,3 @@ void print_formatted(char* num, char* country) {
5546
num_format(num, country, NATIONAL_SHORT, buf);
5647
printf(" - National short: %s\n", buf);
5748
}
58-
59-
int main(int argc, char **argv)
60-
{
61-
char* number;
62-
char* country;
63-
64-
number = argv[1];
65-
country = argv[2];
66-
67-
if (!number || !country) {
68-
printf("Invalid input ! Input: <NUMBER> <COUNTRY>\n");
69-
return 0;
70-
}
71-
72-
printf("=== INPUT ===\n");
73-
printf(" - Number: %s\n", number);
74-
printf(" - Country: %s\n", country);
75-
76-
print_num_info(number, country);
77-
print_region_info(country);
78-
print_formatted(number, country);
79-
80-
return 0;
81-
}

test/display.h

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
#include <stdio.h>
3+
#include <stdlib.h>
4+
5+
#include "../src/regioninfo.h"
6+
#include "../src/numinfo.h"
7+
#include "../src/formatting.h"
8+
9+
10+
#ifndef LIBASTPHONENUMBER_DISPLAY_H
11+
#define LIBASTPHONENUMBER_DISPLAY_H
12+
13+
#define BOOL2STR(b) b ? "Yes" : "No"
14+
15+
void print_region_info(char* country);
16+
void print_num_info(char* num, char* country);
17+
void print_formatted(char* num, char* country);
18+
19+
#endif //LIBASTPHONENUMBER_DISPLAY_H

test/test_lib_dyn_load.c

+17-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@
55

66
#include "../src/formatting.h"
77

8+
static int (*num_format_fn)(char *, char *, enum phone_format, char *);
9+
static int (*is_valid_number_fn)(char* , char*, int);
10+
static int (*get_region_fn)(char* , char* , char *);
11+
static int (*get_country_code_fn)(char* , char*);
12+
static enum phone_type (*get_number_type_fn)(char* , char*);
13+
static int (*get_country_code_for_region_fn)(char* region);
14+
815
int main(int argc, char **argv)
916
{
1017
void *lib_handle;
1118
int (*fn)(char *, char *, enum phone_format, char *);
1219
char *error;
1320
char out_num[100];
1421

15-
lib_handle = dlopen("/usr/lib/libastphonenumber.so", RTLD_LAZY);
22+
lib_handle = dlopen("/usr/lib/libastphonenumber.so.1", RTLD_LAZY);
1623
if (!lib_handle)
1724
{
1825
fprintf(stderr, "dlopen: %s\n", dlerror());
@@ -32,6 +39,15 @@ int main(int argc, char **argv)
3239
}
3340

3441
(*fn)(argv[1], argv[2], PLUSE164, out_num);
42+
43+
num_format_fn = (int (*)(char *, char *, enum phone_format, char *)) dlsym(lib_handle, "num_format");
44+
is_valid_number_fn = (int (*)(char*, char*, int)) dlsym(lib_handle, "is_valid_number");
45+
get_region_fn = (int (*)(char*, char* , char *)) dlsym(lib_handle, "get_region");
46+
get_country_code_fn = (int (*)(char*, char*)) dlsym(lib_handle, "get_country_code");
47+
get_number_type_fn = (enum phone_type (*)(char*, char*)) dlsym(lib_handle, "get_number_type");
48+
get_country_code_for_region_fn = (int (*)(char*)) dlsym(lib_handle, "get_country_code_for_region");
49+
50+
3551
printf("Formatted: %s\n",out_num);
3652

3753
dlclose(lib_handle);

test/tester_static.c

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
#include "display.h"
3+
4+
#include "../src/regioninfo.h"
5+
#include "../src/numinfo.h"
6+
#include "../src/formatting.h"
7+
8+
9+
int main(int argc, char **argv)
10+
{
11+
char* number;
12+
char* country;
13+
14+
number = argv[1];
15+
country = argv[2];
16+
17+
if (!number || !country) {
18+
printf("Invalid input ! Input: <NUMBER> <COUNTRY>\n");
19+
return 0;
20+
}
21+
22+
printf("=== INPUT ===\n");
23+
printf(" - Number: %s\n", number);
24+
printf(" - Country: %s\n", country);
25+
26+
print_num_info(number, country);
27+
print_region_info(country);
28+
print_formatted(number, country);
29+
30+
return 0;
31+
}

0 commit comments

Comments
 (0)