summaryrefslogtreecommitdiff
path: root/ugapp-wifidirect/src/wfd-ugapp-util.c
blob: 94fb8969d52d83df2919b2270c1831220f0caeb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
*  WiFi-Direct UG
*
* Copyright 2012  Samsung Electronics Co., Ltd

* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

* http://www.tizenopensource.org/license

* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

/**
 * This file implements wifi direct application utils functions.
 *
 * @file    wfd-app-util.c
 * @author  Sungsik Jang (sungsik.jang@samsung.com)
 * @version 0.1
 */


#include <stdio.h>
#include <string.h>
#include "wfd-ugapp-util.h"


char *wfd_app_trim_path(const char *filewithpath)
{
#if 0
    char *filename = NULL;
    if ((filename = strrchr(filewithpath, '/')) == NULL)
        return (char *) filewithpath;
    else
        return (filename + 1);
#else
    static char *filename[100];
    char *strptr = NULL;
    int start = 0;
    const char *space = "                                        ";
    int len = strlen(filewithpath);

    if (len > 20)
    {
        strptr = (char *) filewithpath + (len - 20);
        start = 0;
    }
    else if (len < 20)
    {
        strptr = (char *) filewithpath;
        start = 20 - len;
    }
    strncpy((char *) filename, space, strlen(space));
    strncpy((char *) filename + start, strptr, 50);

    return (char *) filename;
#endif
}


int wfd_app_gettid()
{
#ifdef __NR_gettid
    return syscall(__NR_gettid);
#else
    fprintf(stderr,
            "__NR_gettid is not defined, please include linux/unistd.h ");
    return -1;
#endif
}