Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
919213a0
Kaydet (Commit)
919213a0
authored
Ara 17, 1996
tarafından
Roger E. Masse
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Grandly renamed.
üst
0bff94ff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
61 deletions
+65
-61
fcntlmodule.c
Modules/fcntlmodule.c
+65
-61
No files found.
Modules/fcntlmodule.c
Dosyayı görüntüle @
919213a0
...
...
@@ -31,8 +31,8 @@ PERFORMANCE OF THIS SOFTWARE.
/* fcntl module */
#include "
allobjects
.h"
#include "modsupport.h"
#include "
Python
.h"
/*#include "modsupport.h"*/
#ifdef HAVE_UNISTD_H
#include <unistd.h>
...
...
@@ -48,10 +48,10 @@ PERFORMANCE OF THIS SOFTWARE.
/* fcntl(fd, opt, [arg]) */
static
o
bject
*
static
PyO
bject
*
fcntl_fcntl
(
self
,
args
)
o
bject
*
self
;
/* Not used */
o
bject
*
args
;
PyO
bject
*
self
;
/* Not used */
PyO
bject
*
args
;
{
int
fd
;
int
code
;
...
...
@@ -61,47 +61,48 @@ fcntl_fcntl(self, args)
int
len
;
char
buf
[
1024
];
if
(
getargs
(
args
,
"(iis#)"
,
&
fd
,
&
code
,
&
str
,
&
len
))
{
if
(
PyArg_Parse
(
args
,
"(iis#)"
,
&
fd
,
&
code
,
&
str
,
&
len
))
{
if
(
len
>
sizeof
buf
)
{
err_setstr
(
ValueError
,
"fcntl string arg too long"
);
PyErr_SetString
(
PyExc_ValueError
,
"fcntl string arg too long"
);
return
NULL
;
}
memcpy
(
buf
,
str
,
len
);
BGN_SAVE
Py_BEGIN_ALLOW_THREADS
ret
=
fcntl
(
fd
,
code
,
buf
);
END_SAVE
Py_END_ALLOW_THREADS
if
(
ret
<
0
)
{
err_errno
(
IOError
);
PyErr_SetFromErrno
(
PyExc_
IOError
);
return
NULL
;
}
return
newsizedstringobject
(
buf
,
len
);
return
PyString_FromStringAndSize
(
buf
,
len
);
}
err_c
lear
();
if
(
getargs
(
args
,
"(ii)"
,
&
fd
,
&
code
))
PyErr_C
lear
();
if
(
PyArg_Parse
(
args
,
"(ii)"
,
&
fd
,
&
code
))
arg
=
0
;
else
{
err_c
lear
();
if
(
!
getargs
(
args
,
"(iii)"
,
&
fd
,
&
code
,
&
arg
))
PyErr_C
lear
();
if
(
!
PyArg_Parse
(
args
,
"(iii)"
,
&
fd
,
&
code
,
&
arg
))
return
NULL
;
}
BGN_SAVE
Py_BEGIN_ALLOW_THREADS
ret
=
fcntl
(
fd
,
code
,
arg
);
END_SAVE
Py_END_ALLOW_THREADS
if
(
ret
<
0
)
{
err_errno
(
IOError
);
PyErr_SetFromErrno
(
PyExc_
IOError
);
return
NULL
;
}
return
newintobject
((
long
)
ret
);
return
PyInt_FromLong
((
long
)
ret
);
}
/* ioctl(fd, opt, [arg]) */
static
o
bject
*
static
PyO
bject
*
fcntl_ioctl
(
self
,
args
)
o
bject
*
self
;
/* Not used */
o
bject
*
args
;
PyO
bject
*
self
;
/* Not used */
PyO
bject
*
args
;
{
int
fd
;
int
code
;
...
...
@@ -111,56 +112,57 @@ fcntl_ioctl(self, args)
int
len
;
char
buf
[
1024
];
if
(
getargs
(
args
,
"(iis#)"
,
&
fd
,
&
code
,
&
str
,
&
len
))
{
if
(
PyArg_Parse
(
args
,
"(iis#)"
,
&
fd
,
&
code
,
&
str
,
&
len
))
{
if
(
len
>
sizeof
buf
)
{
err_setstr
(
ValueError
,
"ioctl string arg too long"
);
PyErr_SetString
(
PyExc_ValueError
,
"ioctl string arg too long"
);
return
NULL
;
}
memcpy
(
buf
,
str
,
len
);
BGN_SAVE
Py_BEGIN_ALLOW_THREADS
ret
=
ioctl
(
fd
,
code
,
buf
);
END_SAVE
Py_END_ALLOW_THREADS
if
(
ret
<
0
)
{
err_errno
(
IOError
);
PyErr_SetFromErrno
(
PyExc_
IOError
);
return
NULL
;
}
return
newsizedstringobject
(
buf
,
len
);
return
PyString_FromStringAndSize
(
buf
,
len
);
}
err_c
lear
();
if
(
getargs
(
args
,
"(ii)"
,
&
fd
,
&
code
))
PyErr_C
lear
();
if
(
PyArg_Parse
(
args
,
"(ii)"
,
&
fd
,
&
code
))
arg
=
0
;
else
{
err_c
lear
();
if
(
!
getargs
(
args
,
"(iii)"
,
&
fd
,
&
code
,
&
arg
))
PyErr_C
lear
();
if
(
!
PyArg_Parse
(
args
,
"(iii)"
,
&
fd
,
&
code
,
&
arg
))
return
NULL
;
}
BGN_SAVE
Py_BEGIN_ALLOW_THREADS
ret
=
ioctl
(
fd
,
code
,
arg
);
END_SAVE
Py_END_ALLOW_THREADS
if
(
ret
<
0
)
{
err_errno
(
IOError
);
PyErr_SetFromErrno
(
PyExc_
IOError
);
return
NULL
;
}
return
newintobject
((
long
)
ret
);
return
PyInt_FromLong
((
long
)
ret
);
}
/* flock(fd, operation) */
static
o
bject
*
static
PyO
bject
*
fcntl_flock
(
self
,
args
)
o
bject
*
self
;
/* Not used */
o
bject
*
args
;
PyO
bject
*
self
;
/* Not used */
PyO
bject
*
args
;
{
int
fd
;
int
code
;
int
ret
;
if
(
!
getargs
(
args
,
"(ii)"
,
&
fd
,
&
code
))
if
(
!
PyArg_Parse
(
args
,
"(ii)"
,
&
fd
,
&
code
))
return
NULL
;
BGN_SAVE
Py_BEGIN_ALLOW_THREADS
#ifdef HAVE_FLOCK
ret
=
flock
(
fd
,
code
);
#else
...
...
@@ -180,27 +182,28 @@ fcntl_flock(self, args)
else
if
(
code
&
LOCK_EX
)
l
.
l_type
=
F_WRLCK
;
else
{
err_setstr
(
ValueError
,
"unrecognized flock argument"
);
PyErr_SetString
(
PyExc_ValueError
,
"unrecognized flock argument"
);
return
NULL
;
}
l
.
l_whence
=
l
.
l_start
=
l
.
l_len
=
0
;
ret
=
fcntl
(
fd
,
(
code
&
LOCK_NB
)
?
F_SETLK
:
F_SETLKW
,
&
l
);
}
#endif
/* HAVE_FLOCK */
END_SAVE
Py_END_ALLOW_THREADS
if
(
ret
<
0
)
{
err_errno
(
IOError
);
PyErr_SetFromErrno
(
PyExc_
IOError
);
return
NULL
;
}
INCREF
(
None
);
return
None
;
Py_INCREF
(
Py_
None
);
return
Py_
None
;
}
/* lockf(fd, operation) */
static
o
bject
*
static
PyO
bject
*
fcntl_lockf
(
self
,
args
)
o
bject
*
self
;
/* Not used */
o
bject
*
args
;
PyO
bject
*
self
;
/* Not used */
PyO
bject
*
args
;
{
int
fd
,
code
,
len
=
0
,
start
=
0
,
whence
=
0
,
ret
;
...
...
@@ -208,7 +211,7 @@ fcntl_lockf(self, args)
&
start
,
&
whence
))
return
NULL
;
BGN_SAVE
Py_BEGIN_ALLOW_THREADS
#ifndef LOCK_SH
#define LOCK_SH 1
/* shared lock */
#define LOCK_EX 2
/* exclusive lock */
...
...
@@ -224,7 +227,8 @@ fcntl_lockf(self, args)
else
if
(
code
&
LOCK_EX
)
l
.
l_type
=
F_WRLCK
;
else
{
err_setstr
(
ValueError
,
"unrecognized flock argument"
);
PyErr_SetString
(
PyExc_ValueError
,
"unrecognized flock argument"
);
return
NULL
;
}
l
.
l_len
=
len
;
...
...
@@ -232,18 +236,18 @@ fcntl_lockf(self, args)
l
.
l_whence
=
whence
;
ret
=
fcntl
(
fd
,
(
code
&
LOCK_NB
)
?
F_SETLK
:
F_SETLKW
,
&
l
);
}
END_SAVE
Py_END_ALLOW_THREADS
if
(
ret
<
0
)
{
err_errno
(
IOError
);
PyErr_SetFromErrno
(
PyExc_
IOError
);
return
NULL
;
}
INCREF
(
None
);
return
None
;
Py_INCREF
(
Py_
None
);
return
Py_
None
;
}
/* List of functions */
static
struct
methodlist
fcntl_methods
[]
=
{
static
PyMethodDef
fcntl_methods
[]
=
{
{
"fcntl"
,
fcntl_fcntl
},
{
"ioctl"
,
fcntl_ioctl
},
{
"flock"
,
fcntl_flock
},
...
...
@@ -257,15 +261,15 @@ static struct methodlist fcntl_methods[] = {
void
initfcntl
()
{
o
bject
*
m
,
*
d
;
PyO
bject
*
m
,
*
d
;
/* Create the module and add the functions */
m
=
initm
odule
(
"fcntl"
,
fcntl_methods
);
m
=
Py_InitM
odule
(
"fcntl"
,
fcntl_methods
);
/* Add some symbolic constants to the module */
d
=
getmoduled
ict
(
m
);
d
=
PyModule_GetD
ict
(
m
);
/* Check for errors */
if
(
err_o
ccurred
())
fatal
(
"can't initialize module fcntl"
);
if
(
PyErr_O
ccurred
())
Py_FatalError
(
"can't initialize module fcntl"
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment