|
Lines 89-94
Link Here
|
| 89 |
#include <pwd.h> |
89 |
#include <pwd.h> |
| 90 |
#endif |
90 |
#endif |
| 91 |
|
91 |
|
|
|
92 |
#define ShapeInput 2 |
| 93 |
|
| 92 |
typedef enum { |
94 |
typedef enum { |
| 93 |
WINTYPE_DESKTOP, |
95 |
WINTYPE_DESKTOP, |
| 94 |
WINTYPE_DOCK, |
96 |
WINTYPE_DOCK, |
|
Lines 403-408
Link Here
|
| 403 |
#endif |
405 |
#endif |
| 404 |
} |
406 |
} |
| 405 |
|
407 |
|
|
|
408 |
void |
| 409 |
loadConfig(char *filename){ |
| 410 |
FILE *file = NULL; |
| 411 |
char line[ 1024 ]; |
| 412 |
size_t length = 0; |
| 413 |
Bool wasNull = False; |
| 414 |
Bool section = False; |
| 415 |
|
| 416 |
if( filename == NULL ){ |
| 417 |
#ifdef USE_ENV_HOME |
| 418 |
const char *home = getenv("HOME"); |
| 419 |
#else |
| 420 |
const char *home; |
| 421 |
struct passwd *p; |
| 422 |
p = getpwuid(getuid()); |
| 423 |
if (p) |
| 424 |
home = p->pw_dir; |
| 425 |
else |
| 426 |
home = getenv("HOME"); |
| 427 |
#endif |
| 428 |
const char *configfile = "/.xcompmgrrc"; |
| 429 |
int n = strlen(home)+strlen(configfile)+1; |
| 430 |
filename = (char*)malloc(n*sizeof(char)); |
| 431 |
memset(filename,0,n); |
| 432 |
wasNull = True; |
| 433 |
|
| 434 |
strcat(filename, home); |
| 435 |
strcat(filename, configfile); |
| 436 |
} |
| 437 |
|
| 438 |
printf("trying '%s' as configfile\n\n", filename); |
| 439 |
|
| 440 |
if( (file = fopen(filename, "r")) == NULL ){ |
| 441 |
printf("failed to open config file. does it exist?\n"); |
| 442 |
if( wasNull ){ |
| 443 |
free(filename); |
| 444 |
filename = NULL; |
| 445 |
} |
| 446 |
return; |
| 447 |
} |
| 448 |
|
| 449 |
/*find section*/ |
| 450 |
while( !section && fgets(line, 1023, file) != NULL ){ |
| 451 |
if( strcmp(line, "[xcompmgr]\n") == 0 ) |
| 452 |
section = True; |
| 453 |
} |
| 454 |
/*read and set values*/ |
| 455 |
while( section && fgets(line, 1023, file) != NULL ){ |
| 456 |
int ret = strlen( line ); |
| 457 |
if( ret > 1 ){ |
| 458 |
if( *line == '[' )/*found new section - maybe check for '\n'?*/ |
| 459 |
break; |
| 460 |
*(line+ret-1) = '\0'; |
| 461 |
setParameter(line); |
| 462 |
} |
| 463 |
} |
| 464 |
printf("\nfinished parsing the config file\n"); |
| 465 |
fclose(file); |
| 466 |
if( wasNull ){ |
| 467 |
free(filename); |
| 468 |
filename = NULL; |
| 469 |
} |
| 470 |
} |
| 471 |
|
| 406 |
void handle_siguser (int sig) |
472 |
void handle_siguser (int sig) |
| 407 |
{ |
473 |
{ |
| 408 |
int uidnum; |
474 |
int uidnum; |
|
Lines 2992-3060
Link Here
|
| 2992 |
return 0; |
3058 |
return 0; |
| 2993 |
} |
3059 |
} |
| 2994 |
|
3060 |
|
| 2995 |
void |
|
|
| 2996 |
loadConfig(char *filename){ |
| 2997 |
FILE *file = NULL; |
| 2998 |
char line[ 1024 ]; |
| 2999 |
size_t length = 0; |
| 3000 |
Bool wasNull = False; |
| 3001 |
Bool section = False; |
| 3002 |
|
| 3003 |
if( filename == NULL ){ |
| 3004 |
#ifdef USE_ENV_HOME |
| 3005 |
const char *home = getenv("HOME"); |
| 3006 |
#else |
| 3007 |
const char *home; |
| 3008 |
struct passwd *p; |
| 3009 |
p = getpwuid(getuid()); |
| 3010 |
if (p) |
| 3011 |
home = p->pw_dir; |
| 3012 |
else |
| 3013 |
home = getenv("HOME"); |
| 3014 |
#endif |
| 3015 |
const char *configfile = "/.xcompmgrrc"; |
| 3016 |
int n = strlen(home)+strlen(configfile)+1; |
| 3017 |
filename = (char*)malloc(n*sizeof(char)); |
| 3018 |
memset(filename,0,n); |
| 3019 |
wasNull = True; |
| 3020 |
|
| 3021 |
strcat(filename, home); |
| 3022 |
strcat(filename, configfile); |
| 3023 |
} |
| 3024 |
|
| 3025 |
printf("trying '%s' as configfile\n\n", filename); |
| 3026 |
|
| 3027 |
if( (file = fopen(filename, "r")) == NULL ){ |
| 3028 |
printf("failed to open config file. does it exist?\n"); |
| 3029 |
if( wasNull ){ |
| 3030 |
free(filename); |
| 3031 |
filename = NULL; |
| 3032 |
} |
| 3033 |
return; |
| 3034 |
} |
| 3035 |
|
| 3036 |
/*find section*/ |
| 3037 |
while( !section && fgets(line, 1023, file) != NULL ){ |
| 3038 |
if( strcmp(line, "[xcompmgr]\n") == 0 ) |
| 3039 |
section = True; |
| 3040 |
} |
| 3041 |
/*read and set values*/ |
| 3042 |
while( section && fgets(line, 1023, file) != NULL ){ |
| 3043 |
int ret = strlen( line ); |
| 3044 |
if( ret > 1 ){ |
| 3045 |
if( *line == '[' )/*found new section - maybe check for '\n'?*/ |
| 3046 |
break; |
| 3047 |
*(line+ret-1) = '\0'; |
| 3048 |
setParameter(line); |
| 3049 |
} |
| 3050 |
} |
| 3051 |
printf("\nfinished parsing the config file\n"); |
| 3052 |
fclose(file); |
| 3053 |
if( wasNull ){ |
| 3054 |
free(filename); |
| 3055 |
filename = NULL; |
| 3056 |
} |
| 3057 |
} |
| 3058 |
|
3061 |
|
| 3059 |
void |
3062 |
void |
| 3060 |
usage (char *program) |
3063 |
usage (char *program) |