Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
4191d256
Commit
4191d256
authored
24 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Added more wrapper functions for Unix compatibility.
parent
c32630a8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
xtrn/sdk/xsdkwrap.c
+106
-33
106 additions, 33 deletions
xtrn/sdk/xsdkwrap.c
xtrn/sdk/xsdkwrap.h
+8
-10
8 additions, 10 deletions
xtrn/sdk/xsdkwrap.h
with
114 additions
and
43 deletions
xtrn/sdk/xsdkwrap.c
+
106
−
33
View file @
4191d256
...
...
@@ -68,12 +68,110 @@
#ifdef __unix__
struct
termios
current
;
// our current term settings
struct
termios
original
;
// old termios settings
struct
timeval
timeout
=
{
0
,
0
};
// passed in select() call
fd_set
inp
;
// ditto
static
int
beensetup
=
0
;
// has _termios_setup() been called?
/****************************************************************************/
/* Wrapper for Win32 create/begin thread function */
/* Uses POSIX threads */
/****************************************************************************/
#ifdef _POSIX_THREADS
ulong
_beginthread
(
void
(
*
start_address
)(
void
*
)
,
unsigned
stack_size
,
void
*
arglist
)
{
pthread_t
thread
;
pthread_attr_t
attr
;
pthread_attr_init
(
&
attr
);
/* initialize attribute structure */
/* set thread attributes to PTHREAD_CREATE_DETACHED which will ensure
that thread resources are freed on exit() */
pthread_attr_setdetachstate
(
&
attr
,
PTHREAD_CREATE_DETACHED
);
if
(
pthread_create
(
&
thread
,
&
attr
/* default attributes */
/* POSIX defines this arg as "void *(*start_address)" */
,(
void
*
)
start_address
,
arglist
)
==
0
)
return
((
int
)
thread
/* thread handle */
);
return
(
-
1
);
/* error */
}
#else
#error "Need _beginthread implementation for non-POSIX thread library."
#endif
/****************************************************************************/
/* Convert ASCIIZ string to upper case */
/****************************************************************************/
char
*
strupr
(
char
*
str
)
{
char
*
p
=
str
;
while
(
*
p
)
{
*
p
=
toupper
(
*
p
);
p
++
;
}
return
(
str
);
}
/****************************************************************************/
/* Convert ASCIIZ string to lower case */
/****************************************************************************/
char
*
strlwr
(
char
*
str
)
{
char
*
p
=
str
;
while
(
*
p
)
{
*
p
=
tolower
(
*
p
);
p
++
;
}
return
(
str
);
}
/****************************************************************************/
/* Reverse chars in string */
/****************************************************************************/
char
*
strrev
(
char
*
str
)
{
char
t
,
*
i
=
str
,
*
j
=
str
+
strlen
(
str
);
while
(
i
<
j
)
{
t
=*
i
;
*
(
i
++
)
=*
(
--
j
);
*
j
=
t
;
}
return
str
;
}
/* This is a bit of a hack, but it works */
char
*
_fullpath
(
char
*
absPath
,
const
char
*
relPath
,
size_t
maxLength
)
{
char
*
curdir
=
(
char
*
)
malloc
(
PATH_MAX
+
1
);
if
(
curdir
==
NULL
)
{
strcpy
(
absPath
,
relPath
);
return
(
absPath
);
}
getcwd
(
curdir
,
PATH_MAX
);
if
(
chdir
(
relPath
)
!=
0
)
/* error, invalid dir */
strcpy
(
absPath
,
relPath
);
else
{
getcwd
(
absPath
,
maxLength
);
chdir
(
curdir
);
}
free
(
curdir
);
return
absPath
;
}
/***************************************/
/* Console I/O Stuff (by Casey Martin) */
/***************************************/
static
struct
termios
current
;
// our current term settings
static
struct
termios
original
;
// old termios settings
static
struct
timeval
timeout
=
{
0
,
0
};
// passed in select() call
static
fd_set
inp
;
// ditto
static
int
beensetup
=
0
;
// has _termios_setup() been called?
/*
I'm using a variable function here simply for the sake of speed. The
termios functions must be called before a kbhit() can be successful, so
...
...
@@ -160,34 +258,9 @@ int getch(void)
#endif // __unix__
/****************************************************************************/
/* Convert ASCIIZ string to upper case */
/****************************************************************************/
#ifdef __unix__
char
*
strupr
(
char
*
str
)
{
char
*
p
=
str
;
while
(
*
p
)
{
*
p
=
toupper
(
*
p
);
p
++
;
}
return
(
str
);
}
/****************************************************************************/
/* Convert ASCIIZ string to lower case */
/****************************************************************************/
char
*
strlwr
(
char
*
str
)
{
char
*
p
=
str
;
while
(
*
p
)
{
*
p
=
tolower
(
*
p
);
p
++
;
}
return
(
str
);
}
#endif
/**************/
/* File Stuff */
/**************/
/****************************************************************************/
/* Returns the length of the file in 'filename' */
...
...
This diff is collapsed.
Click to expand it.
xtrn/sdk/xsdkwrap.h
+
8
−
10
View file @
4191d256
...
...
@@ -42,6 +42,7 @@
int
kbhit
(
void
);
int
getch
(
void
);
#define ungetch(x)
/* !need a wrapper for this */
#else
/* DOS-Based */
...
...
@@ -132,7 +133,13 @@
#define _rmdir(dir) rmdir(dir)
#define tell(fd) lseek(fd,0,SEEK_CUR)
char
*
_fullpath
(
char
*
absPath
,
const
char
*
relPath
int
sopen
(
char
*
fn
,
int
access
,
int
share
);
long
filelength
(
int
fd
);
char
*
strupr
(
char
*
str
);
char
*
strlwr
(
char
*
str
);
char
*
strrev
(
char
*
str
);
char
*
_fullpath
(
char
*
absPath
,
const
char
*
relPath
,
size_t
maxLength
);
#elif defined(__MSDOS__)
...
...
@@ -145,8 +152,6 @@
#endif
#ifndef BOOL
#define BOOL int
#endif
...
...
@@ -168,13 +173,6 @@ extern "C" {
int
unlock
(
int
fd
,
long
pos
,
int
len
);
#endif
#if defined(__unix__)
int
sopen
(
char
*
fn
,
int
access
,
int
share
);
long
filelength
(
int
fd
);
char
*
strupr
(
char
*
str
);
char
*
strlwr
(
char
*
str
);
#endif
#if !defined(_MSC_VER) && !defined(__BORLANDC__)
char
*
ultoa
(
unsigned
long
val
,
char
*
str
,
int
radix
);
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment