wmgeneral, wmsun: Use threadsafe functions.

This commit is contained in:
Doug Torrance 2015-06-14 17:04:48 -05:00 committed by Carlos R. Mafra
parent d8688d16d9
commit e46ebfcb20
14 changed files with 32 additions and 28 deletions

View file

@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
char temp[128]; char temp[128];
while (fgets(temp, 128, fp)) { while (fgets(temp, 128, fp)) {
char *q; char *q, *saveptr;
char *tokens = " :\t\n"; char *tokens = " :\t\n";
int key; int key;
key = 0; key = 0;
q = strdup(temp); q = strdup(temp);
q = strtok(q, tokens); q = strtok_r(q, tokens, &saveptr);
if(!q) if(!q)
continue; continue;
while (key >= 0 && keys[key].label) { while (key >= 0 && keys[key].label) {

View file

@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
char temp[128]; char temp[128];
while (fgets(temp, 128, fp)) { while (fgets(temp, 128, fp)) {
char *q; char *q, *saveptr;
char *tokens = " :\t\n"; char *tokens = " :\t\n";
int key; int key;
key = 0; key = 0;
q = strdup(temp); q = strdup(temp);
q = strtok(q, tokens); q = strtok_r(q, tokens, &saveptr);
if(!q) if(!q)
continue; continue;
while (key >= 0 && keys[key].label) { while (key >= 0 && keys[key].label) {

View file

@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
char temp[128]; char temp[128];
while (fgets(temp, 128, fp)) { while (fgets(temp, 128, fp)) {
char *q; char *q, *saveptr;
char *tokens = " :\t\n"; char *tokens = " :\t\n";
int key; int key;
key = 0; key = 0;
q = strdup(temp); q = strdup(temp);
q = strtok(q, tokens); q = strtok_r(q, tokens, &saveptr);
if(!q) if(!q)
continue; continue;
while (key >= 0 && keys[key].label) { while (key >= 0 && keys[key].label) {

View file

@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
char temp[128]; char temp[128];
while (fgets(temp, 128, fp)) { while (fgets(temp, 128, fp)) {
char *q; char *q, *saveptr;
char *tokens = " :\t\n"; char *tokens = " :\t\n";
int key; int key;
key = 0; key = 0;
q = strdup(temp); q = strdup(temp);
q = strtok(q, tokens); q = strtok_r(q, tokens, &saveptr);
if(!q) if(!q)
continue; continue;
while (key >= 0 && keys[key].label) { while (key >= 0 && keys[key].label) {

View file

@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
char temp[128]; char temp[128];
while (fgets(temp, 128, fp)) { while (fgets(temp, 128, fp)) {
char *q; char *q, *saveptr;
char *tokens = " :\t\n"; char *tokens = " :\t\n";
int key; int key;
key = 0; key = 0;
q = strdup(temp); q = strdup(temp);
q = strtok(q, tokens); q = strtok_r(q, tokens, &saveptr);
if(!q) if(!q)
continue; continue;
while (key >= 0 && keys[key].label) { while (key >= 0 && keys[key].label) {

View file

@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
char temp[128]; char temp[128];
while (fgets(temp, 128, fp)) { while (fgets(temp, 128, fp)) {
char *q; char *q, *saveptr;
char *tokens = " :\t\n"; char *tokens = " :\t\n";
int key; int key;
key = 0; key = 0;
q = strdup(temp); q = strdup(temp);
q = strtok(q, tokens); q = strtok_r(q, tokens, &saveptr);
if(!q) if(!q)
continue; continue;
while (key >= 0 && keys[key].label) { while (key >= 0 && keys[key].label) {

View file

@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
char temp[128]; char temp[128];
while (fgets(temp, 128, fp)) { while (fgets(temp, 128, fp)) {
char *q; char *q, *saveptr;
char *tokens = " :\t\n"; char *tokens = " :\t\n";
int key; int key;
key = 0; key = 0;
q = strdup(temp); q = strdup(temp);
q = strtok(q, tokens); q = strtok_r(q, tokens, &saveptr);
if(!q) if(!q)
continue; continue;
while (key >= 0 && keys[key].label) { while (key >= 0 && keys[key].label) {

View file

@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
char temp[128]; char temp[128];
while (fgets(temp, 128, fp)) { while (fgets(temp, 128, fp)) {
char *q; char *q, *saveptr;
char *tokens = " :\t\n"; char *tokens = " :\t\n";
int key; int key;
key = 0; key = 0;
q = strdup(temp); q = strdup(temp);
q = strtok(q, tokens); q = strtok_r(q, tokens, &saveptr);
if(!q) if(!q)
continue; continue;
while (key >= 0 && keys[key].label) { while (key >= 0 && keys[key].label) {

View file

@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
char temp[128]; char temp[128];
while (fgets(temp, 128, fp)) { while (fgets(temp, 128, fp)) {
char *q; char *q, *saveptr;
char *tokens = " :\t\n"; char *tokens = " :\t\n";
int key; int key;
key = 0; key = 0;
q = strdup(temp); q = strdup(temp);
q = strtok(q, tokens); q = strtok_r(q, tokens, &saveptr);
if(!q) if(!q)
continue; continue;
while (key >= 0 && keys[key].label) { while (key >= 0 && keys[key].label) {

View file

@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
char temp[128]; char temp[128];
while (fgets(temp, 128, fp)) { while (fgets(temp, 128, fp)) {
char *q; char *q, *saveptr;
char *tokens = " :\t\n"; char *tokens = " :\t\n";
int key; int key;
key = 0; key = 0;
q = strdup(temp); q = strdup(temp);
q = strtok(q, tokens); q = strtok_r(q, tokens, &saveptr);
if(!q) if(!q)
continue; continue;
while (key >= 0 && keys[key].label) { while (key >= 0 && keys[key].label) {

View file

@ -69,6 +69,7 @@
/* /*
* Includes * Includes
*/ */
#define _POSIX_C_SOURCE 1
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include <unistd.h> #include <unistd.h>
@ -177,12 +178,14 @@ int main(int argc, char *argv[]) {
* *
*/ */
if (n>nMAX){ if (n>nMAX){
struct tm result;
n = 0; n = 0;
nMAX = 1000; nMAX = 1000;
CurrentGMTTime = time(CurrentTime); GMTTime = gmtime(&CurrentGMTTime); CurrentGMTTime = time(CurrentTime);
GMTTime = gmtime_r(&CurrentGMTTime, &result);
DayOfMonth = GMTTime->tm_mday; DayOfMonth = GMTTime->tm_mday;
UT = GMTTime->tm_hour + GMTTime->tm_min/60.0 + GMTTime->tm_sec/3600.0; UT = GMTTime->tm_hour + GMTTime->tm_min/60.0 + GMTTime->tm_sec/3600.0;
@ -190,7 +193,8 @@ int main(int argc, char *argv[]) {
Month = GMTTime->tm_mon+1; Month = GMTTime->tm_mon+1;
CurrentLocalTime = CurrentGMTTime; LocalTime = localtime(&CurrentLocalTime); CurrentLocalTime = CurrentGMTTime;
LocalTime = localtime_r(&CurrentLocalTime, &result);
LocalDayOfMonth = LocalTime->tm_mday; LocalDayOfMonth = LocalTime->tm_mday;
if ((OldLocalDayOfMonth != LocalDayOfMonth)||(Flag)){ if ((OldLocalDayOfMonth != LocalDayOfMonth)||(Flag)){

View file

@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
char temp[128]; char temp[128];
while (fgets(temp, 128, fp)) { while (fgets(temp, 128, fp)) {
char *q; char *q, *saveptr;
char *tokens = " :\t\n"; char *tokens = " :\t\n";
int key; int key;
key = 0; key = 0;
q = strdup(temp); q = strdup(temp);
q = strtok(q, tokens); q = strtok_r(q, tokens, &saveptr);
if(!q) if(!q)
continue; continue;
while (key >= 0 && keys[key].label) { while (key >= 0 && keys[key].label) {

View file

@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
char temp[128]; char temp[128];
while (fgets(temp, 128, fp)) { while (fgets(temp, 128, fp)) {
char *q; char *q, *saveptr;
char *tokens = " :\t\n"; char *tokens = " :\t\n";
int key; int key;
key = 0; key = 0;
q = strdup(temp); q = strdup(temp);
q = strtok(q, tokens); q = strtok_r(q, tokens, &saveptr);
if(!q) if(!q)
continue; continue;
while (key >= 0 && keys[key].label) { while (key >= 0 && keys[key].label) {

View file

@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
char temp[128]; char temp[128];
while (fgets(temp, 128, fp)) { while (fgets(temp, 128, fp)) {
char *q; char *q, *saveptr;
char *tokens = " :\t\n"; char *tokens = " :\t\n";
int key; int key;
key = 0; key = 0;
q = strdup(temp); q = strdup(temp);
q = strtok(q, tokens); q = strtok_r(q, tokens, &saveptr);
if(!q) if(!q)
continue; continue;
while (key >= 0 && keys[key].label) { while (key >= 0 && keys[key].label) {