File: bsd.c

package info (click to toggle)
rioutil 1.4.4-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,980 kB
  • ctags: 777
  • sloc: sh: 11,429; ansic: 5,834; makefile: 112
file content (53 lines) | stat: -rw-r--r-- 1,438 bytes parent folder | download | duplicates (2)
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
/**
 *   (c) 2001-2004 Nathan Hjelm <hjelmn@users.sourceforge.net>
 *   v1.0.6 bsd.c
 *   
 *   Functions that are possibly missing.
 *
 *   This program 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 2 of the License, or
 *   (at your option) any later version.
 *   
 *   This program 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 this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 **/

#include <string.h>
#include <sys/types.h>

#include "config.h"
#include "rio_internal.h"

/* seems that neither freebsd or macos x have this */
#if defined (__FreeBSD__) || defined (__MacOSX__)

u_int32_t bswap_32(u_int32_t x){
  return ((x<<24) & 0xff000000) |
    ((x<<8 ) & 0x00ff0000) |
    ((x>>8 ) & 0x0000ff00) |
    ((x>>24) & 0x000000ff);
}

#endif

#if !defined(HAVE_BASENAME)

char *basename(char *x){
  int i;
  /* there is no / in x */
  if (strstr(x, "/") == NULL)
    return x;
 
  for (i = strlen(x) - 1 ; x[i] != '/'; i--);

  return &x[i+1];
}

#endif