コード例 #1
0
ファイル: filelist.c プロジェクト: ABratovic/open-watcom-v2
static void scanDirectory( char *buf, FileList *list )
{
    DIR                 *dirhdl;
    struct dirent       *dirent;
    char                fname[_MAX_FNAME];
    unsigned            len;

    dirhdl = opendir( buf );
    if ( dirhdl == NULL )
        return;
    dirent = readdir( dirhdl );
    while( dirent != NULL ) {
        len = strlen( dirent->d_name );
        if ( len < 5 || stricmp ( &dirent->d_name[len - 4], DEF_EXT ) != 0 ) {
            dirent = readdir( dirhdl );
            continue;
        }
        list->items[ list->used ] = HelpMemAlloc( sizeof( FileInfo ) );
        len = strlen( buf ) + 1;
        list->items[ list->used ]->fpath = HelpMemAlloc( len );
        strcpy( list->items[ list->used ]->fpath, buf );
        _splitpath( dirent->d_name, NULL, NULL, fname, NULL );
        len = strlen( fname ) + 1;
        list->items[ list->used ]->fname = HelpMemAlloc( len );
        strcpy( list->items[ list->used ]->fname, fname );
        list->used ++;
        if( list->used == list->allocated ) {
            list->allocated += MAX_HELPFILES;
            list = HelpMemRealloc( list, sizeof( FileList )
                                   + list->allocated * sizeof( FileInfo* ) );
        }
        dirent = readdir( dirhdl );
    }
    closedir( dirhdl );
}
コード例 #2
0
ファイル: help.c プロジェクト: bhanug/open-watcom-v2
static void save_line( int line, long offset )
/* Assumption:  line <= lastHelpLine + 1 */
{
    if( line >= maxPos ) {
        maxPos = line + 10;
        helpPos = HelpMemRealloc( helpPos, maxPos * sizeof( *helpPos ) );
    }
    if( line > lastHelpLine ) {
        lastHelpLine = line;
    }
    if( offset == -1 ) {
        helpPos[line] = (unsigned)-1;
    } else {
        helpPos[line] = offset - topPos;
    }
}