.\" -*- coding: UTF-8 -*- '\" t .\" Copyright, the authors of the Linux man-pages project .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH getprotoent_r 3 "21 سبتمبر 2025" "صفحات دليل لينكس 6.18" .SH الاسم getprotoent_r, getprotobyname_r, getprotobynumber_r \- الحصول على مدخل البروتوكول (قابل لإعادة الدخول) .SH المكتبة مكتبة سي المعيارية (\fIlibc\fP،\ \fI\-lc\fP) .SH موجز .nf \fB#include \fP .P \fBint getprotoent_r(\fPsize_t size; \fB struct protoent *restrict \fP\fIresult_buf\fP\fB,\fP \fB char \fP\fIbuf\fP\fB[restrict \fP\fIsize\fP\fB], size_t \fP\fIsize\fP\fB,\fP \fB struct protoent **restrict \fP\fIresult\fP\fB);\fP \fBint getprotobyname_r(\fPsize_t size; \fB const char *restrict \fP\fIname\fP\fB,\fP \fB struct protoent *restrict \fP\fIresult_buf\fP\fB,\fP \fB char \fP\fIbuf\fP\fB[restrict \fP\fIsize\fP\fB], size_t \fP\fIsize\fP\fB,\fP \fB struct protoent **restrict \fP\fIresult\fP\fB);\fP \fBint getprotobynumber_r(\fPsize_t size; \fB int \fP\fIproto\fP\fB,\fP \fB struct protoent *restrict \fP\fIresult_buf\fP\fB,\fP \fB char \fP\fIbuf\fP\fB[restrict \fP\fIsize\fP\fB], size_t \fP\fIsize\fP\fB,\fP \fB struct protoent **restrict \fP\fIresult\fP\fB);\fP .P .fi .RS -4 متطلبات ماكروات اختبار الميزات لـ glibc (انظر \fBfeature_test_macros\fP(7)): .RE .P \fBgetprotoent_r\fP(), \fBgetprotobyname_r\fP(), \fBgetprotobynumber_r\fP(): .nf منذ glibc 2.19: _DEFAULT_SOURCE glibc 2.19 وما قبله: _BSD_SOURCE || _SVID_SOURCE .fi .SH الوصف الدوال \fBgetprotoent_r\fP() و \fBgetprotobyname_r\fP() و \fBgetprotobynumber_r\fP() هي المكافئات القابلة لإعادة الدخول لـ \fBgetprotoent\fP(3) و \fBgetprotobyname\fP(3) و \fBgetprotobynumber\fP(3) على التوالي. تختلف في طريقة إرجاع بنية \fIprotoent\fP، وفي توقيع استدعاء الدالة وقيمة الإرجاع. تصف صفحة الدليل هذه الاختلافات فقط عن الدوال غير القابلة لإعادة الدخول. .P بدلاً من إرجاع مؤشر إلى بنية \fIprotoent\fP مخصصة بشكل ثابت كنتيجة للدالة، تنسخ هذه الدوال البنية إلى الموقع المشار إليه بواسطة \fIresult_buf\fP. .P .\" I can find no information on the required/recommended buffer size; .\" the nonreentrant functions use a 1024 byte buffer. .\" The 1024 byte value is also what the Solaris man page suggests. -- mtk تُستخدم المصفوفة \fIbuf\fP لتخزين حقول سلسلة المحارف المشار إليها بواسطة بنية \fIprotoent\fP المُرجعة. (تخصص الدوال غير القابلة لإعادة الدخول هذه السلاسل في تخزين ثابت.) يُحدد حجم هذه المصفوفة في \fIsize\fP. إذا كانت \fIbuf\fP صغيرة جدًا، يفشل الاستدعاء مع الخطأ \fBERANGE\fP، ويجب على المستدعي المحاولة مرة أخرى بمخزن مؤقت أكبر. (يجب أن يكون مخزن مؤقت بحجم 1024 بايت كافيًا لمعظم التطبيقات.) .P إذا حصل استدعاء الدالة بنجاح على سجل بروتوكول، فسيُضبط \fI*result\fP ليشير إلى \fIresult_buf\fP؛ وإلا، فسيُضبط \fI*result\fP على NULL. .SH "قيمة الإرجاع" تُعيد هذه الدوال 0 عند النجاح. وتُعيد أحد أرقام الأخطاء الموجبة المدرجة في قسم ERRORS عند حدوث خطأ. .P عند الخطأ، أو عدم العثور على السجل (\fBgetprotobyname_r\fP()، \fBgetprotobynumber_r\fP())، أو نهاية الإدخال (\fBgetprotoent_r\fP())، يُضبط \fIresult\fP على NULL. .SH الأخطاء .TP \fBENOENT\fP (\fBgetprotoent_r\fP()) لا مزيد من السجلات في قاعدة البيانات. .TP \fBERANGE\fP المخزن المؤقت \fIbuf\fP صغير جدًا. حاول مرة أخرى بمخزن أكبر (وزيادة \fIsize\fP). .SH السمات للاطلاع على شرح للمصطلحات المستخدمة في هذا القسم، انظر \fBattributes\fP(7). .TS allbox; lbx lb lb l l l. الواجهة السمة القيمة T{ .na .nh \fBgetprotoent_r\fP(), \fBgetprotobyname_r\fP(), \fBgetprotobynumber_r\fP() T} سلامة الخيوط المنطقة (locale) آمنة لتعدد المسالك (MT\-Safe) .TE .SH الإصدارات توجد دوال بأسماء مماثلة في بعض الأنظمة الأخرى، وإن كان ذلك عادةً بتواقيع استدعاء مختلفة. .SH المعايير GNU. .SH أمثلة يستخدم البرنامج أدناه \fBgetprotobyname_r\fP() لاسترداد سجل البروتوكول للبروتوكول المسمى في وسيط سطر الأوامر الأول. إذا تم توفير وسيط سطر أوامر ثانٍ (عدد صحيح)، فسيُستخدم كقيمة مبدئية لـ \fIsize\fP؛ إذا فشل \fBgetprotobyname_r\fP() مع الخطأ \fBERANGE\fP، يعيد البرنامج المحاولة بأحجام مخزن مؤقت أكبر. تُظهر جلسة الصدفة التالية بعض عمليات التشغيل النموذجية: .P .in +4n .EX $\fB ./a.out tcp 1\fP ERANGE! Retrying with larger buffer getprotobyname_r() returned: 0 (success) (size=78) p_name=tcp; p_proto=6; aliases=TCP $\fB ./a.out xxx 1\fP ERANGE! Retrying with larger buffer getprotobyname_r() returned: 0 (success) (size=100) Call failed/record not found .EE .in .SS "مصدر البرنامج" .\" SRC BEGIN (getprotoent_r.c) \& .EX #define _GNU_SOURCE #include #include #include #include #include #include \& #define MAX_BUF 10000 \& int main(int argc, char *argv[]) { int size, erange_cnt, s; struct protoent result_buf; struct protoent *result; char buf[MAX_BUF]; \& if (argc < 2) { printf("Usage: %s proto\-name [size]\[rs]n", argv[0]); exit(EXIT_FAILURE); } \& size = 1024; if (argc > 2) size = atoi(argv[2]); \& if (size > MAX_BUF) { printf("Exceeded buffer limit (%d)\[rs]n", MAX_BUF); exit(EXIT_FAILURE); } \& erange_cnt = 0; do { s = getprotobyname_r(argv[1], &result_buf, buf, size, &result); if (s == ERANGE) { if (erange_cnt == 0) printf("ERANGE! Retrying with larger buffer\[rs]n"); erange_cnt++; \& /* Increment a byte at a time so we can see exactly what size buffer was required. */ \& size++; \& if (size > MAX_BUF) { printf("Exceeded buffer limit (%d)\[rs]n", MAX_BUF); exit(EXIT_FAILURE); } } } while (s == ERANGE); \& printf("getprotobyname_r() returned: %s (size=%d)\[rs]n", (s == 0) ? "0 (success)" : (s == ENOENT) ? "ENOENT" : strerror(s), size); \& if (s != 0 || result == NULL) { printf("Call failed/record not found\[rs]n"); exit(EXIT_FAILURE); } \& printf("p_name=%s; p_proto=%d; aliases=", result_buf.p_name, result_buf.p_proto); for (char **p = result_buf.p_aliases; *p != NULL; p++) printf("%s ", *p); printf("\[rs]n"); \& exit(EXIT_SUCCESS); } .EE .\" SRC END .SH "انظر أيضًا" \fBgetprotoent\fP(3), \fBprotocols\fP(5) .PP .SH ترجمة تُرجمت هذه الصفحة من الدليل بواسطة زايد السعيدي . .PP هذه الترجمة هي وثيقة مجانية؛ راجع .UR https://www.gnu.org/licenses/gpl-3.0.html رخصة جنو العامة الإصدار 3 .UE أو ما بعده للاطلاع على شروط حقوق النشر. لا توجد أي ضمانات. .PP إذا وجدت أي أخطاء في ترجمة صفحة الدليل هذه، يرجى إرسال بريد إلكتروني إلى قائمة بريد المترجمين: .MT kde-l10n-ar@kde.org .ME .