Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ lctrstr(PCI) — OpenDesktop Software Development System 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought


 lcs_translate_string(PCI)      6 January 1993      lcs_translate_string(PCI)


 Name

    lcs_translate_string - translates input string to output string

 Syntax


    #include <lcs.h>

    int lcs_translate_string(out, out_size, in)
    char *out, *in;
    int out_size;


 Description

    This function translates a NULL-terminated string of characters in in and
    places the result in out. No more than outsize characters, including a
    terminating NULL, are placed in out.

    To use this function, you must first get the tables, set the tables, and
    set the options.

 Return value

    This function returns 0 on a successful translation and -1 when a trans-
    lation error occurs.  Translation statistics are described in lcsintro.
    Error codes are returned in lcserrno.

 Example


       #include <lcs.h>
       #define MAX_LINE 1024;
       char inbuf[MAX_LINE];
       char outbuf[MAX_LINE];
               :
               :
       /* Get input table */
               :
               :
       /* Get output table */
               :
               :
       /* Set the tables */
               :
               :
       /* Set the options. */
               :
               :
       if ( lcs_translate_string(outbuf, MAX_LINE, inbuf) < 0) {
               switch(lcs_errno) {
               case LCS_ERR_NOTFOUND:
                      fprintf(stderr,"Translation table(s) not found!\n");
                      exit(1);
               case LCS_ERR_BADTABLE:
                      fprintf(stderr, "Translation table(s) bad!\n");
                      exit(1);
               case LCS_ERR_NOTABLE:
                      fprintf(stderr, "Translation tables not set!\n");
                      exit(1);
               case LCS_ERR_NOSPACE:
                      /* Insufficient space, hhmm */
                      fprintf(stderr,
                         "Insufficient space in output buffer!\n");
                      exit(1);
               case LCS_ERR_STOPXLAT:
                      /* Untranslatable character and abort_on */
                      fprintf(stderr, "Untranslatable character!\n");
                      exit(1);
               case LCS_ERR_INPUT_SPLIT:
                      /* Input is split across multiple buffers */
                      fprintf(stderr, "Input split!\n");
                      exit(1);
               default:
                      /* Unknown error condition, help! */
                      fprintf(stderr, "Unknown error: %d\n", lcs_errno);
                      exit(1);
               } /* end switch */
       }


 See also

    lcsintro(PCI), lcstranslateblock(PCI), lcsgettable(PCI),
    lcssettables(PCI), lcssetoptions(PCI)


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026