static PyObject * mkpwent(struct passwd *p) { int setIndex = 0; PyObject *v = PyStructSequence_New(&StructPwdType); if (v == NULL) return NULL; #define SETI(i,val) PyStructSequence_SET_ITEM(v, i, PyInt_FromLong((long) val)) #define SETS(i,val) sets(v, i, val) SETS(setIndex++, p->pw_name); #ifdef __VMS SETS(setIndex++, ""); #else SETS(setIndex++, p->pw_passwd); #endif SETI(setIndex++, p->pw_uid); SETI(setIndex++, p->pw_gid); SETS(setIndex++, p->pw_dir); SETS(setIndex++, p->pw_shell); #undef SETS #undef SETI if (PyErr_Occurred()) { Py_XDECREF(v); return NULL; } return v; }
static PyObject *mkspent(struct spwd *p) { int setIndex = 0; PyObject *v = PyStructSequence_New(&StructSpwdType); if (v == NULL) return NULL; #define SETI(i,val) PyStructSequence_SET_ITEM(v, i, PyInt_FromLong((long) val)) #define SETS(i,val) sets(v, i, val) SETS(setIndex++, p->sp_namp); SETS(setIndex++, p->sp_pwdp); #ifndef __HAIKU__ SETI(setIndex++, p->sp_lstchg); #endif SETI(setIndex++, p->sp_min); SETI(setIndex++, p->sp_max); SETI(setIndex++, p->sp_warn); SETI(setIndex++, p->sp_inact); SETI(setIndex++, p->sp_expire); SETI(setIndex++, p->sp_flag); #undef SETS #undef SETI if (PyErr_Occurred()) { Py_DECREF(v); return NULL; } return v; }