dlls/ntdll/unix/system.c
static BOOL sysfs_count_list_elements(const char *filename, DWORD *result)
{
    FILE *f;

    f = fopen(filename, "r");
    if (!f) return FALSE;

    while (!feof(f))
    {
        char op;
        DWORD beg, end;

        if (!fscanf(f, "%u%c ", &beg, &op)) break;
        if(op == '-')
            fscanf(f, "%u%c ", &end, &op);
        else
            end = beg;

        *result += end - beg + 1;
    }
    fclose( f );
    return TRUE;
}
/* Helper function for counting number of elements in interval lists as used by
 * the Linux kernel. The format is comma separated list of intervals of which
 * each interval has the format of "begin-end" where begin and end are decimal
 * numbers. E.g. "0-7", "0-7,16-23"
 *
 * Example files include:
 * - /sys/devices/system/cpu/online
 * - /sys/devices/system/cpu/cpu0/cache/index0/shared_cpu_list
 * - /sys/devices/system/cpu/cpu0/topology/thread_siblings_list.
 */
Helper function for counting number of elements in interval lists as used by
the Linux kernel. The format is comma separated list of intervals of which
each interval has the format of "begin-end" where begin and end are decimal
numbers.


Helper function for counting number of elements in interval lists as used by the Linux kernel . The format is comma separated list of intervals of which each interval has the format of " begin - end " where begin and end are decimal numbers .
static BOOL sysfs_count_list_elements(const char *filename, DWORD *result)
{
    FILE *f;
    f = fopen(filename, "r");
    if (!f) return FALSE;
    while (!feof(f))
    {
        char op;
        DWORD beg, end;
        if (!fscanf(f, "%u%c ", &beg, &op)) break;
        if(op == '-')
            fscanf(f, "%u%c ", &end, &op);
        else
            end = beg;
        *result += end - beg + 1;
    }
    fclose( f );
    return TRUE;
}
static BOOL sysfs_count_list_elements ( const char * filename , DWORD * result ) { FILE * f ; f = fopen ( filename , " " ) ; if ( ! f ) return FALSE ; while ( ! feof ( f ) ) { char op ; DWORD beg , end ; if ( ! fscanf ( f , " " , & beg , & op ) ) break ; if ( op == ' ' ) fscanf ( f , " " , & end , & op ) ; else end = beg ; * result += end - beg + 1 ; } fclose ( f ) ; return TRUE ; }
Helper function for counting number of elements in interval lists as used by
 the Linux kernel.
Helper function for counting number of elements in interval lists as used by the Linux kernel .