mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 07:50:40 +01:00
Function to notify errors
This commit is contained in:
4
Makefile
4
Makefile
@@ -2,8 +2,8 @@ CXX=gcc
|
|||||||
|
|
||||||
CXXFLAGS=-g -Wall -Werror -fstack-protector-all -pedantic -Wno-unused
|
CXXFLAGS=-g -Wall -Werror -fstack-protector-all -pedantic -Wno-unused
|
||||||
|
|
||||||
SOURCE=main.c standart.c extended.c cpuid.c udev.c printer.c args.c
|
SOURCE=main.c standart.c extended.c cpuid.c udev.c printer.c args.c global.c
|
||||||
HEADERS=standart.h extended.h cpuid.h udev.h printer.h ascii.h args.h
|
HEADERS=standart.h extended.h cpuid.h udev.h printer.h ascii.h args.h global.h
|
||||||
|
|
||||||
OUTPUT=cpufetch
|
OUTPUT=cpufetch
|
||||||
|
|
||||||
|
|||||||
16
global.c
Normal file
16
global.c
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
#define RED "\x1b[31;1m"
|
||||||
|
#define RESET "\x1b[0m"
|
||||||
|
|
||||||
|
void printError(const char *fmt, ...) {
|
||||||
|
int buffer_size = 4096;
|
||||||
|
char buffer[buffer_size];
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
vsnprintf(buffer,buffer_size, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
fprintf(stderr,RED "ERROR: "RESET "%s\n",buffer);
|
||||||
|
}
|
||||||
6
global.h
Normal file
6
global.h
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef __GLOBAL__
|
||||||
|
#define __GLOBAL__
|
||||||
|
|
||||||
|
void printError(const char *fmt, ...);
|
||||||
|
|
||||||
|
#endif
|
||||||
1
main.c
1
main.c
@@ -5,6 +5,7 @@
|
|||||||
#include "standart.h"
|
#include "standart.h"
|
||||||
#include "udev.h"
|
#include "udev.h"
|
||||||
#include "extended.h"
|
#include "extended.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
/***
|
/***
|
||||||
SAMPLE OUTPUT
|
SAMPLE OUTPUT
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "printer.h"
|
#include "printer.h"
|
||||||
#include "ascii.h"
|
#include "ascii.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
#define COL_INTEL_DEFAULT_1 "\x1b[36;1m"
|
#define COL_INTEL_DEFAULT_1 "\x1b[36;1m"
|
||||||
#define COL_INTEL_DEFAULT_2 "\x1b[37;1m"
|
#define COL_INTEL_DEFAULT_2 "\x1b[37;1m"
|
||||||
@@ -66,7 +67,7 @@ struct ascii* set_ascii(VENDOR cpuVendor, STYLE style) {
|
|||||||
/*** Check that number of lines of ascii art matches the number
|
/*** Check that number of lines of ascii art matches the number
|
||||||
of spaces plus the number of lines filled with text ***/
|
of spaces plus the number of lines filled with text ***/
|
||||||
if(LINES_SPACE_UP+LINES_SPACE_DOWN+ATTRIBUTE_COUNT != NUMBER_OF_LINES) {
|
if(LINES_SPACE_UP+LINES_SPACE_DOWN+ATTRIBUTE_COUNT != NUMBER_OF_LINES) {
|
||||||
printf("Bug at line number %d in file %s\n", __LINE__, __FILE__);
|
printError("Number of lines do not match (%d vs %d)",LINES_SPACE_UP+LINES_SPACE_DOWN+ATTRIBUTE_COUNT,NUMBER_OF_LINES);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,8 +86,7 @@ struct ascii* set_ascii(VENDOR cpuVendor, STYLE style) {
|
|||||||
strcpy(art->color2,COL_INTEL_DARK_2);
|
strcpy(art->color2,COL_INTEL_DARK_2);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//TODO Bugs function
|
printError("Found invalid style (%d)",style);
|
||||||
printf("Bug at line number %d in file %s\n", __LINE__, __FILE__);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,8 +125,7 @@ struct ascii* set_ascii(VENDOR cpuVendor, STYLE style) {
|
|||||||
strcpy(art->color2,COL_AMD_DARK_2);
|
strcpy(art->color2,COL_AMD_DARK_2);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//TODO Bugs function
|
printError("Found invalid style (%d)",style);
|
||||||
printf("Bug at line number %d in file %s\n", __LINE__, __FILE__);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user