apply FSL(Flora Software License)
[apps/native/ug-wifi-direct.git] / popup-wifidirect / src / wfd-app-util.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  *    http://www.tizenopensource.org/license
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * This file implements wifi direct application utils functions.
19  *
20  * @file    wfd-app-util.c
21  * @author  Sungsik Jang (sungsik.jang@samsung.com)
22  * @version 0.1
23  */
24
25
26 #include <stdio.h>
27 #include <string.h>
28 #include "wfd-app-util.h"
29
30
31 char *wfd_app_trim_path(const char *filewithpath)
32 {
33     static char *filename[100];
34     char *strptr = NULL;
35     int start = 0;
36     const char *space = "                                        ";
37     int len = strlen(filewithpath);
38
39     if (len > 20)
40     {
41         strptr = (char *) filewithpath + (len - 20);
42         start = 0;
43     }
44     else if (len < 20)
45     {
46         strptr = (char *) filewithpath;
47         start = 20 - len;
48     }
49     strncpy((char *) filename, space, strlen(space));
50     strncpy((char *) filename + start, strptr, 50);
51
52     return (char *) filename;
53 }
54
55
56 int wfd_app_gettid()
57 {
58 #ifdef __NR_gettid
59     return syscall(__NR_gettid);
60 #else
61     fprintf(stderr,
62             "__NR_gettid is not defined, please include linux/unistd.h ");
63     return -1;
64 #endif
65 }