Logo Search packages:      
Sourcecode: t1utils version File versions  Download package

int Clp_CurOptionNameBuf ( Clp_Parser clp,
char *  buf,
int  len 
)

Extract the current option as a string.

Parameters:
clp the parser
buf output buffer
len length of output buffer
Returns:
number of characters written to the buffer, not including the terminating NUL
A string that looks like the last option parsed by clp is extracted into buf. The correct option characters are put into the string first, followed by the option text. The output buffer is null-terminated unless len == 0.

See also:
Clp_CurOptionName

Definition at line 2285 of file clp.c.

References Clp_Parser::internal.

{
    Clp_Internal *cli = clp->internal;
    int optno = cli->current_option;
    int pos = 0;
    if (optno < 0)
      pos += copy_string(buf, len, pos, "(no current option!)");
    else if (cli->current_short) {
      pos += copy_string(buf, len, pos, cli->option_chars);
      if (cli->utf8)
          pos = (encode_utf8(buf + pos, len - pos - 1, cli->opt[optno].short_name) - buf);
      else if (pos < len - 1)
          buf[pos++] = cli->opt[optno].short_name;
    } else if (cli->negated_by_no) {
      pos += copy_string(buf, len, pos, cli->option_chars);
      pos += copy_string(buf, len, pos, "no-");
      pos += copy_string(buf, len, pos, cli->opt[optno].long_name + cli->iopt[optno].ilongoff);
    } else {
      pos += copy_string(buf, len, pos, cli->option_chars);
      pos += copy_string(buf, len, pos, cli->opt[optno].long_name + cli->iopt[optno].ilongoff);
    }
    if (pos < len)
      buf[pos] = 0;
    return pos;
}


Generated by  Doxygen 1.6.0   Back to index