Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions
mantomak.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

Go to the source code of this file.

Classes

struct  char_list_struct
struct  macro_list_struct

Defines

#define DEFAULT_MANIFEST_EXT   ".mn"
#define DEFAULT_MAKEFILE_EXT   ".win"

Typedefs

typedef struct char_list_struct char_list
typedef struct macro_list_struct macro_list

Functions

void help (void)
char * input_filename (const char *)
char * output_filename (const char *, const char *)
int input_to_output (FILE *, FILE *)
int output_rules (FILE *)
int output_end (FILE *)
int buffer_to_output (char *, FILE *)
macro_listextract_macros (char *)
char * find_macro (char *, char **)
void add_macro (char *, macro_list **)
int macro_length (char *)
int value_length (char *)
void add_values (char *, char_list **)
char * skip_white (char *)
int write_macros (macro_list *, FILE *)
int write_values (char_list *, FILE *, int)
void free_macro_list (macro_list *)
void free_char_list (char_list *)
void morph_macro (macro_list **, char *, char *, char *)
void slash_convert (macro_list *, char *)
int explicit_rules (macro_list *, char *, FILE *)
void create_classroot (macro_list **ppList)
int main (int argc, char *argv[])

Class Documentation

struct char_list_struct

Definition at line 46 of file mantomak.c.

Collaboration diagram for char_list_struct:
Class Members
struct char_list_struct * m_pNext
char * m_pString
struct macro_list_struct

Definition at line 51 of file mantomak.c.

Collaboration diagram for macro_list_struct:
Class Members
char * m_pMacro
struct macro_list_struct * m_pNext
char_list * m_pValue

Define Documentation

Definition at line 44 of file mantomak.c.

Definition at line 43 of file mantomak.c.


Typedef Documentation

typedef struct char_list_struct char_list
typedef struct macro_list_struct macro_list

Function Documentation

void add_macro ( char *  pString,
macro_list **  ppList 
)

Definition at line 698 of file mantomak.c.

{
    macro_list *pEntry = NULL;
    int iLength = 0;

    if(pString == NULL || *pString == '\0' || ppList == NULL) {
       return;
    }

    /*  Allocate a new list entry for the macro.
     */
    pEntry = (macro_list *)calloc(1, sizeof(macro_list));

    /*  Very first part of the string is the macro name.
     *  How long is it?
     */
    iLength = macro_length(pString);
    pEntry->m_pMacro = (char *)calloc(iLength + 1, 1);
    strncpy(pEntry->m_pMacro, pString, iLength);

    /*  Skip to the values.
     *  These are always on the right side of an '='
     */
    pString = strchr(pString, '=');
    if(pString) {
       pString++;
    }
    add_values(pString, &(pEntry->m_pValue));

    /*  Add the macro to the end of the macro list.
     */
    while(*ppList)  {
       ppList = &((*ppList)->m_pNext);
    }
    *ppList = pEntry;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void add_values ( char *  pString,
char_list **  ppList 
)

Definition at line 735 of file mantomak.c.

{
    char_list **ppTraverse = NULL;
    char_list *pEntry = NULL;
    int iLength = 0;
    int iBackslash = 0;

    if(pString == NULL || *pString == '\0' || ppList == NULL)   {
       return;
    }

    while(pString)  {
       /*  Find start of value.
        */
       iBackslash = 0;
       while(*pString) {
           if(*pString == '\\')    {
              iBackslash++;
           }
           else if(*pString == '\n')   {
              if(iBackslash == 0)  {
                  /*  End of values.
                   *  Setting to NULL gets out of all loops.
                   */
                  pString = NULL;
                  break;
              }
              iBackslash = 0;
           }
           else if(!isspace(*pString))  {
              /*  Backslashes part of string.
               *  This screws up if a backslash is in the middle of the string.
               */
              pString -= iBackslash;
              break;
           }

           pString++;
       }
       if(pString == NULL || *pString == '\0') {
           break;
       }

       /*  Do not honor anything beginning with a #
        */
       if(*pString == '#') {
           /*  End of line.
            */
           while(*pString && *pString != '\n') {
              pString++;
           }
           continue;
       }

       /*  Very first part of the string is value name.
        *  How long is it?
        */
       iLength = value_length(pString);

       /*  Do not honor $(NULL)
        */
       if(_strnicmp(pString, "$(NULL)", 7) == 0)    {
           pString += iLength;
           continue;
       }

       /*  Allocate a new list entry for the next value.
        */
       pEntry = (char_list *)calloc(1, sizeof(char_list));

       pEntry->m_pString = (char *)calloc(iLength + 1, 1);
       strncpy(pEntry->m_pString, pString, iLength);

       /*  Add new value entry to the end of the list.
        */
       ppTraverse = ppList;
       while(*ppTraverse)  {
           ppTraverse = &((*ppTraverse)->m_pNext);
       }
       *ppTraverse = pEntry;

       /*  Go on to next value.
        */
       pString += iLength;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int buffer_to_output ( char *  pBuffer,
FILE pOutput 
)

Definition at line 291 of file mantomak.c.

{
    int iRetval = 0;
    macro_list *pMacros = NULL;

    /*  Tokenize the macros and their corresponding values.
     */
    pMacros = extract_macros(pBuffer);
    if(pMacros != NULL) {
       /*  Perform forward to backslash conversion on those macros known to be
        *      path information only.
        */
       slash_convert(pMacros, "JBOOTDIRS");
       slash_convert(pMacros, "JDIRS");
       slash_convert(pMacros, "DEPTH");
       slash_convert(pMacros, "NS_DEPTH");
       slash_convert(pMacros, "PACKAGE");
       slash_convert(pMacros, "JMC_GEN_DIR");
       slash_convert(pMacros, "DIST_PUBLIC");

       /*  Process some of the macros, and convert them
        *      into different macros with different data.
        */
       morph_macro(&pMacros, "JMC_GEN", "JMC_HEADERS", "$(JMC_GEN_DIR)\\%s.h");
       morph_macro(&pMacros, "JMC_GEN", "JMC_STUBS", "$(JMC_GEN_DIR)\\%s.c");
       morph_macro(&pMacros, "JMC_GEN", "JMC_OBJS", ".\\$(OBJDIR)\\%s.obj");
       morph_macro(&pMacros, "CSRCS", "C_OBJS", ".\\$(OBJDIR)\\%s.obj");
       morph_macro(&pMacros, "CPPSRCS", "CPP_OBJS", ".\\$(OBJDIR)\\%s.obj");
       morph_macro(&pMacros, "REQUIRES", "LINCS", "-I$(XPDIST)\\public\\%s");

       create_classroot( &pMacros );

       /*  Output the Macros and the corresponding values.
        */
       iRetval = write_macros(pMacros, pOutput);

       /*  Output rule file inclusion
        */
       if(iRetval == 0)    {
           iRetval = output_rules(pOutput);
       }

       /*  Output explicit build rules/dependencies for JMC_GEN.
        */
       if(iRetval == 0)    {
           iRetval = explicit_rules(pMacros, "JMC_GEN", pOutput);
       }

       if(iRetval == 0)    {
           iRetval = output_end(pOutput);
       }
       /*  Free off the macro list.
        */
       free_macro_list(pMacros);
       pMacros = NULL;
    }

    return(iRetval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 510 of file mantomak.c.

{
    char cwd[512];
    int i, i2;
    macro_list *pEntry = NULL;
    macro_list *pE;

    /*  Find macro of said name.
     *  Case insensitive.
     */
    pEntry = *ppList;
    while(pEntry)    {
       if(stricmp(pEntry->m_pMacro, "PACKAGE") == 0)  {
           break;
       }

       pEntry = pEntry->m_pNext;
    }

    if(pEntry == 0 || pEntry->m_pValue == 0 || pEntry->m_pValue->m_pString == 0)  {
       return;
    }

    _getcwd( cwd, 512 );

    i = strlen( pEntry->m_pValue->m_pString );
    i2 = strlen( cwd );

    cwd[i2-i-1] = 0;

    pE = NULL;
    pE = (macro_list *)calloc(sizeof(macro_list),1);
    pE->m_pMacro = strdup("CLASSROOT");
    pE->m_pValue = (char_list *)calloc(sizeof(char_list),1);
    pE->m_pValue->m_pString = strdup(cwd);

    while(*ppList)  {
       ppList = &((*ppList)->m_pNext);
    }
    *ppList = pE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int explicit_rules ( macro_list pList,
char *  pMacro,
FILE pOutput 
)

Definition at line 351 of file mantomak.c.

{
    int iRetval = 0;
    macro_list *pEntry = NULL;

    if(pList == NULL || pMacro == NULL || pOutput == NULL) {
       return(0);
    }

    /*  Find macro of said name.
     *  Case insensitive.
     */
    pEntry = pList;
    while(pEntry)    {
       if(stricmp(pEntry->m_pMacro, pMacro) == 0)  {
           break;
       }

       pEntry = pEntry->m_pNext;
    }

    if(pEntry)  {
       /*  Decide style of rule depending on macro name.
        */
       if(stricmp(pEntry->m_pMacro, "JMC_GEN") == 0)    {
           char_list *pNames = NULL;
           char *pModuleName = NULL;
           char *pClassName = NULL;

           pNames = pEntry->m_pValue;
           while(pNames)   {
              pModuleName = pNames->m_pString;
              pClassName = pModuleName + 1;

              fprintf(pOutput, "$(JMC_GEN_DIR)\\%s.h", pModuleName);
              fprintf(pOutput, ": ");
              fprintf(pOutput, "$(JMCSRCDIR)\\%s.class", pClassName);
              fprintf(pOutput, "\n    ");
              fprintf(pOutput, "$(JMC) -d $(JMC_GEN_DIR) -interface $(JMC_GEN_FLAGS) $(?F:.class=)");
              fprintf(pOutput, "\n");

              fprintf(pOutput, "$(JMC_GEN_DIR)\\%s.c", pModuleName);
              fprintf(pOutput, ": ");
              fprintf(pOutput, "$(JMCSRCDIR)\\%s.class", pClassName);
              fprintf(pOutput, "\n    ");
              fprintf(pOutput, "$(JMC) -d $(JMC_GEN_DIR) -module $(JMC_GEN_FLAGS) $(?F:.class=)");
              fprintf(pOutput, "\n");

              pNames = pNames->m_pNext;
           }
       }
       else    {
           /*  Don't know how to format macro.
            */
           iRetval = 69;
       }
    }

    return(iRetval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

macro_list * extract_macros ( char *  pBuffer)

Definition at line 680 of file mantomak.c.

{
    macro_list *pRetval = NULL;
    char *pTraverse = NULL;
    char *pMacro = NULL;

    pTraverse = pBuffer;
    while(pTraverse)    {
       pMacro = NULL;
       pTraverse = find_macro(pTraverse, &pMacro);
       if(pMacro)  {
           add_macro(pMacro, &pRetval);
       }
    }

    return(pRetval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char * find_macro ( char *  pBuffer,
char **  ppMacro 
)

Definition at line 822 of file mantomak.c.

{
    char *pRetval = NULL;
    int iBackslash = 0;

    if(pBuffer == NULL || ppMacro == NULL) {
       return(NULL);
    }

    /*  Skip any whitespace in the buffer.
     *  If comments need to be skipped also, this is the place.
     */
    while(1)    {
       while(*pBuffer && isspace(*pBuffer))    {
           pBuffer++;
       }
       if(*pBuffer == '#') {
           /*  Go to the end of the line, it's a comment.
            */
           while(*pBuffer && *pBuffer != '\n') {
              pBuffer++;
           }

           continue;
       }
       break;
    }

    if(*pBuffer)    {
       /*  Should be at the start of a macro.
        */
       *ppMacro = pBuffer;
    }

    /*  Find the end of the macro for the return value.
     *  This is the end of a line which does not contain a backslash at the end.
     */
    while(*pBuffer) {
       if(*pBuffer == '\\')    {
           iBackslash++;
       }
       else if(*pBuffer == '\n')   {
           if(iBackslash == 0)  {
              pRetval = pBuffer + 1;
              break;
           }
           iBackslash = 0;
       }
       else if(!isspace(*pBuffer))  {
           iBackslash = 0;
       }

       pBuffer++;
    }

    return(pRetval);
}

Here is the caller graph for this function:

Definition at line 985 of file mantomak.c.

{
    char_list *pFree = NULL;

    if(pList == NULL)   {
       return;
    }

    while(pList)    {
       pFree = pList;
       pList = pList->m_pNext;

       pFree->m_pNext = NULL;

       free(pFree->m_pString);
       pFree->m_pString = NULL;

       free(pFree);
       pFree = NULL;
    }
}

Here is the caller graph for this function:

Definition at line 960 of file mantomak.c.

{
    macro_list *pFree = NULL;

    if(pList == NULL)   {
       return;
    }

    while(pList)    {
       pFree = pList;
       pList = pList->m_pNext;

       pFree->m_pNext = NULL;

       free_char_list(pFree->m_pValue);
       pFree->m_pValue = NULL;

       free(pFree->m_pMacro);
       pFree->m_pMacro = NULL;

       free(pFree);
       pFree = NULL;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void help ( void  )
char * input_filename ( const char *  pInputFile)

Definition at line 162 of file mantomak.c.

{
       char aResult[_MAX_PATH];
       char aDrive[_MAX_DRIVE];
       char aDir[_MAX_DIR];
       char aName[_MAX_FNAME];
       char aExt[_MAX_EXT];

       if(pInputFile == NULL)  {
              return(NULL);
       }

       _splitpath(pInputFile, aDrive, aDir, aName, aExt);

       if(aExt[0] == '\0')     {
              /*      No extension provided.
               *      Use the default.
               */
              strcpy(aExt, DEFAULT_MANIFEST_EXT);
       }

       aResult[0] = '\0';
       _makepath(aResult, aDrive, aDir, aName, aExt);

       if(aResult[0] == '\0')  {
              return(NULL);
       }
       else    {
              return(strdup(aResult));
       }
}

Here is the caller graph for this function:

int input_to_output ( FILE pInput,
FILE pOutput 
)

Definition at line 228 of file mantomak.c.

{
       char *pHog = NULL;
       long lSize = 0;
       int iRetval = 0;

       /*      Read the entire file into memory.
        */
       fseek(pInput, 0, SEEK_END);
       lSize = ftell(pInput);
       fseek(pInput, 0, SEEK_SET);

       pHog = (char *)malloc(lSize + 1);
       if(pHog)        {
              *(pHog + lSize) = '\0';
              fread(pHog, lSize, 1, pInput);

              iRetval = buffer_to_output(pHog, pOutput);

              free(pHog);
              pHog = NULL;
       }
       else    {
              fprintf(stderr, "MANTOMAK:  Out of Memory....\n");
              iRetval = 1;
       }

       return(iRetval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int macro_length ( char *  pMacro)

Definition at line 880 of file mantomak.c.

{
    int iRetval = 0;

    if(pMacro == NULL)  {
       return(0);
    }

    /*  Length is no big deal.
     *  Problem is finding the end:
     *      whitespace
     *      '='
     */
    while(*pMacro)  {
       if(*pMacro == '=')  {
           break;
       }
       else if(isspace(*pMacro))   {
           break;
       }
       
       pMacro++;
       iRetval++;
    }

    return(iRetval);
}

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 80 of file mantomak.c.

{
       int iOS = 0;
       char *pInputFile = NULL;
       char *pOutputFile = NULL;

       /*      Figure out arguments.
        *      [REQUIRED] First argument is input file.
        *      [OPTIONAL] Second argument is output file.
        */
       if(argc > 1)    {
              FILE *pInputStream = NULL;
              FILE *pOutputStream = NULL;

              /*      Form respective filenames.
               */
              pInputFile = input_filename(argv[1]);
              pOutputFile = output_filename(pInputFile, argc > 2 ? argv[2] : NULL);

              if(pInputFile == NULL)  {
                     fprintf(stderr, "MANTOMAK:  Unable to form input filename\n");
                     iOS = 1;
              }
              else    {
                     pInputStream = fopen(pInputFile, "rb");
                     if(pInputStream == NULL)        {
                            fprintf(stderr, "MANTOMAK:  Unable to open input file %s\n", pInputFile);
                            iOS = 1;
                     }
              }
              if(pOutputFile == NULL) {
                     fprintf(stderr, "MANTOMAK:  Unable to form output filename\n");
                     iOS = 1;
              }
              else if(pInputStream != NULL)   {
                     pOutputStream = fopen(pOutputFile, "wt");
                     if(pOutputStream == NULL)       {
                            fprintf(stderr, "MANTOMAK:  Unable to open output file %s\n", pOutputFile);
                            iOS = 1;
                     }
              }

              /*      Only do the real processing if our error code is not
               *              already set.
               */
              if(iOS == 0)    {
                     iOS = input_to_output(pInputStream, pOutputStream);
              }

              if(pInputStream != NULL)        {
                     fclose(pInputStream);
                     pInputStream = NULL;
              }
              if(pOutputStream != NULL)       {
                     fclose(pOutputStream);
                     pOutputStream = NULL;
              }
       }
       else    {
              help();
              iOS = 1;
       }

       if(pInputFile)  {
              free(pInputFile);
              pInputFile = NULL;
       }
       if(pOutputFile) {
              free(pOutputFile);
              pOutputFile = NULL;
       }

       return(iOS);
}

Here is the call graph for this function:

void morph_macro ( macro_list **  ppList,
char *  pMacro,
char *  pMorph,
char *  pPrintf 
)

Definition at line 449 of file mantomak.c.

{
    macro_list *pEntry = NULL;

    if(ppList == NULL || pMacro == NULL || pMorph == NULL || pPrintf == NULL) {
       return;
    }

    /*  Find macro of said name.
     *  Case insensitive.
     */
    pEntry = *ppList;
    while(pEntry)    {
       if(stricmp(pEntry->m_pMacro, pMacro) == 0)  {
           break;
       }

       pEntry = pEntry->m_pNext;
    }

    if(pEntry)  {
       char_list *pFilename = NULL;
       char aPath[_MAX_PATH];
       char aDrive[_MAX_DRIVE];
       char aDir[_MAX_DIR];
       char aFName[_MAX_FNAME];
       char aExt[_MAX_EXT];
       char *pBuffer = NULL;

       /*  Start with buffer size needed.
        *  We expand this as we go along if needed.
        */
       pBuffer = (char *)malloc(strlen(pMorph) + 2);
       strcpy(pBuffer, pMorph);
       strcat(pBuffer, "=");

       /*  Go through each value, converting over to new macro.
        */
       pFilename = pEntry->m_pValue;
       while(pFilename) {
           _splitpath(pFilename->m_pString, aDrive, aDir, aFName, aExt);

           /*  Expand buffer by required amount.
            */
           sprintf(aPath, pPrintf, aFName);
           strcat(aPath, " ");
           pBuffer = (char *)realloc(pBuffer, _msize(pBuffer) + strlen(aPath));
           strcat(pBuffer, aPath);

           pFilename = pFilename->m_pNext;
       }

       /*  Add the macro.
        */
       add_macro(pBuffer, ppList);

       free(pBuffer);
       pBuffer = NULL;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int output_end ( FILE pOutput)

Definition at line 274 of file mantomak.c.

{
       int iRetval = 0;

       if(EOF ==
       fputs("\n"
             "!endif"
             "\n",
           pOutput))
    {
              fprintf(stderr, "MANTOMAK:  Error writing to file....\n");
              iRetval = 1;
       }
       return(iRetval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char * output_filename ( const char *  pInputFile,
const char *  pOutputFile 
)

Definition at line 194 of file mantomak.c.

{
       char aResult[_MAX_PATH];
       char aDrive[_MAX_DRIVE];
       char aDir[_MAX_DIR];
       char aName[_MAX_FNAME];
       char aExt[_MAX_EXT];

       if(pOutputFile != NULL) {
              return(strdup(pOutputFile));
       }

       /*      From here on out, we have to create our own filename,
        *              implied from the input file name.
        */

       if(pInputFile == NULL)  {
              return(NULL);
       }

       _splitpath(pInputFile, aDrive, aDir, aName, aExt);
       strcpy(aExt, DEFAULT_MAKEFILE_EXT);

       aResult[0] = '\0';
       _makepath(aResult, aDrive, aDir, aName, aExt);

       if(aResult[0] == '\0')  {
              return(NULL);
       }
       else    {
              return(strdup(aResult));
       }
}

Here is the caller graph for this function:

int output_rules ( FILE pOutput)

Definition at line 258 of file mantomak.c.

{
       int iRetval = 0;

       if(EOF ==
       fputs("\n"
             "!if \"$(MANIFEST_LEVEL)\"==\"RULES\""
             "\n",
           pOutput))
    {
              fprintf(stderr, "MANTOMAK:  Error writing to file....\n");
              iRetval = 1;
       }
       return(iRetval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char * skip_white ( char *  pString)

Definition at line 947 of file mantomak.c.

{
    if(pString == NULL) {
       return(NULL);
    }

    while(*pString && isspace(*pString)) {
       pString++;
    }

    return(pString);
}
void slash_convert ( macro_list pList,
char *  pMacro 
)

Definition at line 412 of file mantomak.c.

{
    macro_list *pEntry = NULL;

    if(pList == NULL || pMacro == NULL) {
       return;
    }

    /*  Find macro of said name.
     *  Case insensitive.
     */
    pEntry = pList;
    while(pEntry)    {
       if(stricmp(pEntry->m_pMacro, pMacro) == 0)  {
           break;
       }

       pEntry = pEntry->m_pNext;
    }

    if(pEntry)  {
       char *pConvert = NULL;
       char_list *pValue = pEntry->m_pValue;

       while(pValue)   {
           pConvert = pValue->m_pString;
           while(pConvert && *pConvert)    {
              if(*pConvert == '/')    {
                  *pConvert = '\\';
              }
              pConvert++;
           }
           pValue = pValue->m_pNext;
       }
    }
}

Here is the caller graph for this function:

int value_length ( char *  pValue)
int write_macros ( macro_list pList,
FILE pOutput 
)

Definition at line 553 of file mantomak.c.

{
    int iRetval = 0;
    int iLineLength = 0;

    if(pList == NULL || pOutput == NULL)    {
       return(0);
    }

       if(EOF ==
       fputs("\n"
             "!if \"$(MANIFEST_LEVEL)\"==\"MACROS\""
             "\n",
           pOutput))
    {
              fprintf(stderr, "MANTOMAK:  Error writing to file....\n");
              return(1);
       }

    while(pList)    {
        int bIgnoreForWin16 = 0;

        /* The following macros should not be emitted for Win16 */
        if (0 == strcmp(pList->m_pMacro, "LINCS")) {
            bIgnoreForWin16 = 1;
        }


        if (bIgnoreForWin16) {
            if(0 > fprintf(pOutput, "!if \"$(MOZ_BITS)\" != \"16\"\n"))  {
                fprintf(stderr, "MANTOMAK:  Error writing to file....\n");
                iRetval = 1;
                break;
            }
        }

       if(0 > fprintf(pOutput, "%s=", pList->m_pMacro))  {
              fprintf(stderr, "MANTOMAK:  Error writing to file....\n");
           iRetval = 1;
           break;
       }
       iLineLength += strlen(pList->m_pMacro) + 1;

       iRetval = write_values(pList->m_pValue, pOutput, iLineLength);
       if(iRetval) {
           break;
       }

       if(EOF == fputc('\n', pOutput))    {
              fprintf(stderr, "MANTOMAK:  Error writing to file....\n");
           iRetval = 1;
           break;
       }
       iLineLength = 0;

       pList = pList->m_pNext;

        if (bIgnoreForWin16) {
            if(0 > fprintf(pOutput, "!endif\n"))  {
                fprintf(stderr, "MANTOMAK:  Error writing to file....\n");
                iRetval = 1;
                break;
            }
            bIgnoreForWin16 = 0;
        }
    }

       if(EOF ==
       fputs("\n"
             "!endif"
             "\n",
           pOutput))
    {
              fprintf(stderr, "MANTOMAK:  Error writing to file....\n");
              return(1);
       }
    return(iRetval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int write_values ( char_list pList,
FILE pOutput,
int  iLineLength 
)

Definition at line 632 of file mantomak.c.

{
    int iRetval = 0;
    
    if(pList == NULL || pOutput == NULL)    {
       return(0);
    }

    while(pList)    {
       if(iLineLength == 0)    {
           if(EOF == fputs("    ", pOutput))  {
                  fprintf(stderr, "MANTOMAK:  Error writing to file....\n");
              iRetval = 1;
              break;
           }
           iLineLength += 4;

           if(0 > fprintf(pOutput, "%s ", pList->m_pString))   {
                  fprintf(stderr, "MANTOMAK:  Error writing to file....\n");
              iRetval = 1;
              break;
           }
           iLineLength += strlen(pList->m_pString) + 1;
       }
       else if(iLineLength + strlen(pList->m_pString) > 72)    {
           if(EOF == fputs("\\\n", pOutput)) {
                  fprintf(stderr, "MANTOMAK:  Error writing to file....\n");
              iRetval = 1;
              break;
           }
           iLineLength = 0;
           continue;
       }
       else    {
           if(0 > fprintf(pOutput, "%s ", pList->m_pString))   {
                  fprintf(stderr, "MANTOMAK:  Error writing to file....\n");
              iRetval = 1;
              break;
           }
           iLineLength += strlen(pList->m_pString) + 1;
       }

       pList = pList->m_pNext;
    }

    return(iRetval);
}

Here is the call graph for this function:

Here is the caller graph for this function: