Add flags and usage() to main. Uncrustify

This commit is contained in:
Pim van Pelt
2019-01-03 21:28:32 +01:00
parent cb48b78265
commit cafecbb897
3 changed files with 167 additions and 107 deletions

View File

@ -23,91 +23,97 @@
int _mgos_timers = 0;
int log_print_prefix(enum cs_log_level l, const char *func, const char *file) {
char ll_str[6];
char ll_file[31];
char ll_func[41];
size_t offset=0;
char ll_str[6];
char ll_file[31];
char ll_func[41];
size_t offset = 0;
switch(l) {
case LL_ERROR:
strncpy(ll_str, "ERROR", sizeof(ll_str));
break;
case LL_WARN:
strncpy(ll_str, "WARN", sizeof(ll_str));
break;
case LL_INFO:
strncpy(ll_str, "INFO", sizeof(ll_str));
break;
case LL_DEBUG:
strncpy(ll_str, "DEBUG", sizeof(ll_str));
break;
case LL_VERBOSE_DEBUG:
strncpy(ll_str, "VERB", sizeof(ll_str));
break;
default: // LL_NONE
return 0;
switch (l) {
case LL_ERROR:
strncpy(ll_str, "ERROR", sizeof(ll_str));
break;
case LL_WARN:
strncpy(ll_str, "WARN", sizeof(ll_str));
break;
case LL_INFO:
strncpy(ll_str, "INFO", sizeof(ll_str));
break;
case LL_DEBUG:
strncpy(ll_str, "DEBUG", sizeof(ll_str));
break;
case LL_VERBOSE_DEBUG:
strncpy(ll_str, "VERB", sizeof(ll_str));
break;
default: // LL_NONE
return 0;
}
offset=0;
offset = 0;
memset(ll_file, 0, sizeof(ll_file));
if (strlen(file) >= sizeof(ll_file))
offset=strlen(file)-sizeof(ll_file)+1;
strncpy(ll_file, file+offset, sizeof(ll_file)-1);
if (strlen(file) >= sizeof(ll_file)) {
offset = strlen(file) - sizeof(ll_file) + 1;
}
strncpy(ll_file, file + offset, sizeof(ll_file) - 1);
offset=0;
offset = 0;
memset(ll_func, 0, sizeof(ll_func));
if (strlen(func) >= sizeof(ll_func))
offset=strlen(func)-sizeof(ll_func)+1;
strncpy(ll_func, func+offset, sizeof(ll_func)-1);
if (strlen(func) >= sizeof(ll_func)) {
offset = strlen(func) - sizeof(ll_func) + 1;
}
strncpy(ll_func, func + offset, sizeof(ll_func) - 1);
printf ("%-5s %-30s %-40s| ", ll_str, ll_file, ll_func);
printf("%-5s %-30s %-40s| ", ll_str, ll_file, ll_func);
return 1;
}
double mg_time(void) {
struct timespec ts;
double ret;
double ret;
clock_gettime(CLOCK_REALTIME_COARSE, &ts);
ret = (double) ts.tv_sec;
ret += ((double)ts.tv_nsec)/1000000000;
ret = (double)ts.tv_sec;
ret += ((double)ts.tv_nsec) / 1000000000;
return ret;
}
void mgos_usleep(uint32_t usecs) {
usleep(usecs);
}
bool mgos_gpio_set_int_handler(int pin, enum mgos_gpio_int_mode mode, mgos_gpio_int_handler_f cb, void *arg) {
LOG(LL_INFO, ("Not implemented."));
return true;
(void)pin;
(void)mode;
(void)cb;
(void)arg;
}
bool mgos_gpio_enable_int(int pin) {
LOG(LL_INFO, ("Not implemented."));
return true;
(void)pin;
}
bool mgos_gpio_disable_int(int pin) {
LOG(LL_INFO, ("Not implemented."));
return true;
(void)pin;
}
void mgos_gpio_clear_int(int pin) {
LOG(LL_INFO, ("Not implemented."));
return;
(void)pin;
}