Annotation of 43BSDReno/contrib/isode-beta/pepy/hello_world.py, revision 1.1

1.1     ! root        1: HelloWorldDefs DEFINITIONS ::=
        !             2: 
        !             3: %{
        !             4: #include <stdio.h>
        !             5: 
        !             6: 
        !             7: static char *text;
        !             8: static char *myname = "hello_world";
        !             9: 
        !            10: 
        !            11: void adios ();
        !            12: 
        !            13: /*  */
        !            14: 
        !            15: /* ARGSUSED */
        !            16: 
        !            17: main (argc, argv, envp)
        !            18: int     argc;
        !            19: char  **argv,
        !            20:       **envp;
        !            21: {
        !            22:     PE     pe;
        !            23: 
        !            24:     myname = argv[0];
        !            25: 
        !            26:     if (build_HelloWorldDefs_MyStruct (&pe, 1, NULL, NULLCP, NULLCP) == NOTOK)
        !            27:        adios (NULLCP, "encoder fails");
        !            28:     if (unbuild_HelloWorldDefs_MyStruct (pe, 1, NULLIP, NULLVP, NULLCP)
        !            29:            == NOTOK)
        !            30:        adios (NULLCP, "decoder fails");
        !            31: 
        !            32:     exit (0);                  /* NOTREACHED */
        !            33: }
        !            34: %}
        !            35: 
        !            36: BEGIN
        !            37: 
        !            38: ENCODER        build
        !            39: 
        !            40: MyStruct ::=
        !            41:        PrintableString [[s "Hello World" ]]
        !            42: 
        !            43: 
        !            44: DECODER        unbuild
        !            45: 
        !            46: MyStruct ::=
        !            47:        PrintableString [[s text]]
        !            48:        %{ printf("%s\n", text); %}
        !            49: 
        !            50: END
        !            51: 
        !            52: %{
        !            53: 
        !            54: /*    ERRORS */
        !            55: 
        !            56: #include <varargs.h>
        !            57: 
        !            58: 
        !            59: #ifndef        lint
        !            60: void   _advise ();
        !            61: 
        !            62: 
        !            63: static void  adios (va_alist)
        !            64: va_dcl
        !            65: {
        !            66:     va_list ap;
        !            67: 
        !            68:     va_start (ap);
        !            69: 
        !            70:     _advise (ap);
        !            71: 
        !            72:     va_end (ap);
        !            73: 
        !            74:     _exit (1);
        !            75: }
        !            76: #else
        !            77: /* VARARGS */
        !            78: 
        !            79: static void  adios (what, fmt)
        !            80: char   *what,
        !            81:        *fmt;
        !            82: {
        !            83:     adios (what, fmt);
        !            84: }
        !            85: #endif
        !            86: 
        !            87: 
        !            88: #ifndef        lint
        !            89: static void  advise (va_alist)
        !            90: va_dcl
        !            91: {
        !            92:     va_list ap;
        !            93: 
        !            94:     va_start (ap);
        !            95: 
        !            96:     _advise (ap);
        !            97: 
        !            98:     va_end (ap);
        !            99: }
        !           100: 
        !           101: 
        !           102: static void  _advise (ap)
        !           103: va_list        ap;
        !           104: {
        !           105:     char    buffer[BUFSIZ];
        !           106: 
        !           107:     asprintf (buffer, ap);
        !           108: 
        !           109:     (void) fflush (stdout);
        !           110: 
        !           111:     fprintf (stderr, "%s: ", myname);
        !           112:     (void) fputs (buffer, stderr);
        !           113:     (void) fputc ('\n', stderr);
        !           114: 
        !           115:     (void) fflush (stderr);
        !           116: }
        !           117: #else
        !           118: /* VARARGS */
        !           119: 
        !           120: static void  advise (what, fmt)
        !           121: char   *what,
        !           122:        *fmt;
        !           123: {
        !           124:     advise (what, fmt);
        !           125: }
        !           126: #endif
        !           127: 
        !           128: %}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.