示例#1
0
文件: darwin.c 项目: augre/pegasus
int printMachine(FILE *out, int indent, const char* tag, const void* data) {
    /* purpose: format the information into the given stream as XML.
     * paramtr: out (IO): the buffer
     *          indent (IN): indentation level
     *          tag (IN): name to use for element tags.
     *          data (IN): MachineDarwinInfo info to print.
     * returns: 0 if no error
     */

    /* sanity check */
    if (data == NULL) {
        return 0;
    }

    const MachineDarwinInfo* ptr = (const MachineDarwinInfo*) data;

    /* start basic info */
    startBasicMachine(out, indent, tag, ptr->basic);

    /* Print contents of <darwin> */
    printDarwinInfo(out, indent+2, ptr);

    /* finish tag */
    finalBasicMachine(out, indent, tag, ptr->basic);

    return 0;
}
示例#2
0
文件: basic.c 项目: bingzhang/pegasus
int printBasicMachine(FILE *out, int indent, const char* tag,
                      const void* data) {
    /* purpose: format the machine information into the given stream as XML.
     * paramtr: out (IO): The stream
     *          indent (IN): indentation level
     *          tag (IN): name to use for element tags.
     *          data (IN): MachineBasicInfo info to print.
     */
    const MachineBasicInfo* ptr = (const MachineBasicInfo*) data;

    if (ptr) {
        char b[32];
        startBasicMachine(out, indent+2, tag, ptr);

#if defined(_SC_PHYS_PAGES) || defined(_SC_AVPHYS_PAGES)
        fprintf(out, "%*s<ram", indent, "");
#ifdef _SC_PHYS_PAGES
        fprintf(out, " total=\"%s\"",
                sizer(b, 32, sizeof(ptr->ram_total), &(ptr->ram_total)));
#endif /* _SC_PHYS_PAGES */
#ifdef _SC_AVPHYS_PAGES
        fprintf(out, " avail=\"%s\"",
                sizer(b, 32, sizeof(ptr->ram_avail), &(ptr->ram_avail)));
#endif /* _SC_AVPHYS_PAGES */
        fprintf(out, "/>\n");
#endif /* _SC_PHYS_PAGES || _SC_AVPHYS_PAGES */

#if defined(_SC_NPROCESSORS_CONF) || defined(_SC_NPROCESSORS_ONLN)
        fprintf(out, "%*s<cpu", indent, "");
#ifdef _SC_NPROCESSORS_CONF
        fprintf(out, " total=\"%s\"",
                sizer(b, 32, sizeof(ptr->cpu_total), &(ptr->cpu_total)));
#endif /* _SCN_PROCESSORS_CONF */
#ifdef _SC_NPROCESSORS_ONLN
        fprintf(out, " online=\"%s\"",
                sizer(b, 32, sizeof(ptr->cpu_online), &(ptr->cpu_online)));
#endif /* _SC_NPROCESSORS_ONLN */
        fprintf(out, "/>\n");
#endif /* _SC_NPROCESSORS_CONF || _SC_NPROCESSORS_ONLN */

        finalBasicMachine(out, indent+2, tag, ptr);
    }

    return 0;
}
示例#3
0
文件: linux.c 项目: bingzhang/pegasus
int printMachine(FILE *out, int indent, const char* tag, const void* data) {
    /* purpose: format the information into the given stream as XML.
     * paramtr: out (IO): The stream
     *          indent (IN): indentation level
     *          tag (IN): name to use for element tags.
     *          data (IN): MachineLinuxInfo info to print.
     */

    /* sanity check */
    if (data == NULL) {
        return 0;
    }

    const MachineLinuxInfo* ptr = (const MachineLinuxInfo*) data;
    startBasicMachine(out, indent, tag, ptr->basic);
    printLinuxInfo(out, indent+2, ptr);
    finalBasicMachine(out, indent, tag, ptr->basic);

    return 0;
}
示例#4
0
int printBasicMachine(FILE *out, int indent, const char* tag,
                      const void* data) {
    /* purpose: format the machine information into the given stream as XML.
     * paramtr: out (IO): The stream
     *          indent (IN): indentation level
     *          tag (IN): name to use for element tags.
     *          data (IN): MachineBasicInfo info to print.
     */
    const MachineBasicInfo* ptr = (const MachineBasicInfo*) data;

    if (ptr) {
        startBasicMachine(out, indent+2, tag, ptr);

#if defined(_SC_PHYS_PAGES) || defined(_SC_AVPHYS_PAGES)
#ifdef _SC_PHYS_PAGES
        fprintf(out, "%*s  ram_total: %llu\n", indent-2, "", ptr->ram_total / 1024);
#endif /* _SC_PHYS_PAGES */
#ifdef _SC_AVPHYS_PAGES
        fprintf(out, "%*s  ram_avail: %llu\n", indent-2, "", ptr->ram_avail / 1024);
#endif /* _SC_AVPHYS_PAGES */
#endif /* _SC_PHYS_PAGES || _SC_AVPHYS_PAGES */

#if defined(_SC_NPROCESSORS_CONF) || defined(_SC_NPROCESSORS_ONLN)
#ifdef _SC_NPROCESSORS_CONF
        fprintf(out, "%*s  cpu_total: %hu\n", indent-2, "", ptr->cpu_total);
#endif /* _SCN_PROCESSORS_CONF */
#ifdef _SC_NPROCESSORS_ONLN
        fprintf(out, "%*s  cpu_online=\"%hu\"", indent-2, "", ptr->cpu_online);
#endif /* _SC_NPROCESSORS_ONLN */
#endif /* _SC_NPROCESSORS_CONF || _SC_NPROCESSORS_ONLN */

        finalBasicMachine(out, indent+2, tag, ptr);
    }

    return 0;
}