diff options
author | Guido van Rossum <guido@python.org> | 1997-07-31 19:39:54 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-07-31 19:39:54 (GMT) |
commit | f4e32c729bae45db02e74d7b873316b3f61d7507 (patch) | |
tree | d6470ace798ce3c39d4b8626b6071bc9b6330805 /Modules | |
parent | 55b9ab5bdb0ef3b00339d751a8db5e23aa936cf0 (diff) | |
download | cpython-f4e32c729bae45db02e74d7b873316b3f61d7507.zip cpython-f4e32c729bae45db02e74d7b873316b3f61d7507.tar.gz cpython-f4e32c729bae45db02e74d7b873316b3f61d7507.tar.bz2 |
Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/fcntlmodule.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Modules/fcntlmodule.c b/Modules/fcntlmodule.c index e7c91b1..e951bc4 100644 --- a/Modules/fcntlmodule.c +++ b/Modules/fcntlmodule.c @@ -257,6 +257,30 @@ static PyMethodDef fcntl_methods[] = { /* Module initialisation */ +static int +ins(d, symbol, value) + PyObject* d; + char* symbol; + long value; +{ + PyObject* v = PyInt_FromLong(value); + if (!v || PyDict_SetItemString(d, symbol, v) < 0) + return -1; + + Py_DECREF(v); + return 0; +} + +static int +all_ins(d) + PyObject* d; +{ + if (ins(d, "LOCK_SH", (long)LOCK_SH)) return -1; + if (ins(d, "LOCK_EX", (long)LOCK_EX)) return -1; + if (ins(d, "LOCK_NB", (long)LOCK_NB)) return -1; + if (ins(d, "LOCK_UN", (long)LOCK_UN)) return -1; +} + void initfcntl() { @@ -267,6 +291,7 @@ initfcntl() /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); + all_ins(d); /* Check for errors */ if (PyErr_Occurred()) |