+ return e;
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct element *first, *elem, *prev;
+ int circular, opt, errfnd;
+
+ /* The "\-c" command\-line option can be used to specify that the
+ list is circular */
+
+ errfnd = 0;
+ circular = 0;
+ while ((opt = getopt(argc, argv, "c")) != \-1) {
+ switch (opt) {
+ case 'c':
+ circular = 1;
+ break;
+ default:
+ errfnd = 1;
+ break;
+ }
+ }
+
+ if (errfnd || optind >= argc) {
+ fprintf(stderr, "Usage: %s [\-c] string...\en", argv[0]);
+ exit(EXIT_FAILURE);
+ }
+
+ /* Create first element and place it in the linked list */
+
+ elem = new_element();
+ first = elem;
+
+ elem\->name = argv[optind];
+
+ if (circular) {
+ elem\->forward = elem;
+ elem\->backward = elem;
+ insque(elem, elem);
+ } else {
+ insque(elem, NULL);
+ }
+
+ /* Add remaining command\-line arguments as list elements */
+
+ while (++optind < argc) {
+ prev = elem;
+
+ elem = new_element();
+ elem\->name = argv[optind];
+ insque(elem, prev);
+ }
+
+ /* Traverse the list from the start, printing element names */
+
+ printf("Traversing completed list:\en");
+ elem = first;
+ do {
+ printf(" %s\en", elem\->name);
+ elem = elem\->forward;
+ } while (elem != NULL && elem != first);
+
+ if (elem == first)
+ printf("That was a circular list\en");
+
+ exit(EXIT_SUCCESS);
+}
+.fi
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。