ctopts.c revision b18c2d1e
10bbfda8aSnia/* 20bbfda8aSnia * Compile-time options 30bbfda8aSnia */ 40bbfda8aSnia 50bbfda8aSnia#include "ctwm.h" 60bbfda8aSnia 70bbfda8aSnia#include <stdio.h> 80bbfda8aSnia#include <stdlib.h> 90bbfda8aSnia#include <string.h> 100bbfda8aSnia 110bbfda8aSnia#include "ctopts.h" 120bbfda8aSnia 130bbfda8aSnia 140bbfda8aSnia/* 150bbfda8aSnia * What options we're build with 160bbfda8aSnia */ 170bbfda8aSniastatic char *ctopts[] = { 180bbfda8aSnia "I18N", // Used to be optional, now standard. Remove? 190bbfda8aSnia#ifdef XPM 200bbfda8aSnia "XPM", 210bbfda8aSnia#endif 220bbfda8aSnia#ifdef JPEG 230bbfda8aSnia "JPEG", 240bbfda8aSnia#endif 250bbfda8aSnia#ifdef USEM4 260bbfda8aSnia "USEM4", 270bbfda8aSnia#endif 280bbfda8aSnia#ifdef SOUNDS 290bbfda8aSnia "SOUNDS", 300bbfda8aSnia#endif 310bbfda8aSnia#ifdef EWMH 320bbfda8aSnia "EWMH", 330bbfda8aSnia#endif 34b18c2d1eSnia#ifdef XRANDR 35b18c2d1eSnia "XRANDR", 36b18c2d1eSnia#endif 370bbfda8aSnia#ifdef DEBUG 380bbfda8aSnia "DEBUG", 390bbfda8aSnia#endif 400bbfda8aSnia NULL 410bbfda8aSnia}; 420bbfda8aSnia 430bbfda8aSnia 440bbfda8aSnia/* 450bbfda8aSnia * Build a string of our compile-time opts 460bbfda8aSnia */ 470bbfda8aSniachar * 480bbfda8aSniactopts_string(char *sep) 490bbfda8aSnia{ 500bbfda8aSnia char *cto; 510bbfda8aSnia size_t slen, tlen; 520bbfda8aSnia int i; 530bbfda8aSnia 540bbfda8aSnia /* Figure out how long our string would be */ 550bbfda8aSnia slen = strlen(sep); 560bbfda8aSnia tlen = 0; 570bbfda8aSnia i = -1; 580bbfda8aSnia while(ctopts[++i]) { 590bbfda8aSnia tlen += strlen(ctopts[i]); 600bbfda8aSnia if(i > 0) { 610bbfda8aSnia tlen += slen; 620bbfda8aSnia } 630bbfda8aSnia } 640bbfda8aSnia 650bbfda8aSnia /* Now make it */ 660bbfda8aSnia cto = malloc(tlen + 1); 670bbfda8aSnia *cto = '\0'; 680bbfda8aSnia i = -1; 690bbfda8aSnia while(ctopts[++i]) { 700bbfda8aSnia if(i > 0) { 710bbfda8aSnia strcat(cto, sep); 720bbfda8aSnia } 730bbfda8aSnia strcat(cto, ctopts[i]); 740bbfda8aSnia } 750bbfda8aSnia 760bbfda8aSnia return cto; 770bbfda8aSnia} 78