home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name HLPAS2C -- Convert a Pascal string to C format.
- *
- * Synopsis length = hlpas2c(ppascal_string, pc_string,
- * max_length);
- *
- * int length Length of C string,
- * including terminating '\0'.
- * const char *ppascal_string Pascal string to convert.
- * char *pc_string Buffer to place C string in.
- * int max_length Maximum length of C string,
- * including '\0'.
- *
- *
- * Description HLPAS2C will convert a Pascal-style string with leading
- * length byte into a C-style '\0' terminated string.
- * The maximum number of characters that will be written
- * to pc_string will be max_length.
- *
- * Returns int length The total length of the C string includng
- * the terminating '\0'.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1989
- *
- **/
- #include <bhelp.h>
- #include <string.h>
-
- int hlpas2c(ppascal_string, pc_string, max_length)
- const char *ppascal_string;
- char *pc_string;
- int max_length;
- {
- int c_length;
- int temp_index;
-
- c_length = (int) ppascal_string[0] + 1;
- c_length = (max_length > c_length) ? c_length
- : max_length;
- ppascal_string++;
- for (temp_index = 0; temp_index < (c_length - 1); temp_index++)
- pc_string[temp_index] = ppascal_string[temp_index];
- pc_string[c_length - 1] = '\0';
-
- return(c_length);
- }