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