+/*
+ * CDE - Common Desktop Environment
+ *
+ * Copyright (c) 1993-2012, The Open Group. All rights reserved.
+ *
+ * These libraries and programs are free software; you can
+ * redistribute them and/or modify them under the terms of the GNU
+ * Lesser General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * These libraries and programs are distributed in the hope that
+ * they will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with these librararies and programs; if not, write
+ * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA 02110-1301 USA
+ */
/*******************************************************************************
**
** util.c
#define X_INCLUDE_STRING_H
#define X_INCLUDE_TIME_H
#define XOS_USE_NO_LOCKING
+#if defined(linux)
+#undef SVR4
+#endif
#include <X11/Xos_r.h>
#include <errno.h>
}
#else
tmp = (char*)getenv("PRINTER");
- if (tmp != NULL && *tmp != NULL) {
+ if (tmp != NULL && *tmp != '\0') {
printer_name = (char*)malloc(strlen(tmp)+1);
strcpy(printer_name, tmp);
}
{
register int n;
- if (s==NULL) return NULL;
+ if (s==NULL) return 0;
return (strlen(s));
}
}
k++;
}
- newstr[k] = NULL;
+ newstr[k] = '\0';
return(newstr);
}
k++;
}
}
- newstr[k] = NULL;
+ newstr[k] = '\0';
return(newstr);
}
if (ptr == buf)
return(NULL);
else {
- *ptr = NULL;
+ *ptr = '\0';
return(cm_strdup(buf));
}
}
#if defined(sun) || defined(USL) || defined(__uxp__)
sysinfo(SI_SRPC_DOMAIN, local_domain, DOM_NM_LN);
#else
- (void) getdomainname(local_domain, BUFSIZ);
+ if(-1 == getdomainname(local_domain, BUFSIZ)) {
+ fprintf(stderr, "getdomainname() failed %d '%s'\n", errno, strerror(errno));
+ }
+
#endif /* sun || USL || __uxp__ */
}
return(local_domain);
get_component(&str2, com2, '.');
if (*com1) {
- if (*com2 == NULL)
+ if (*com2 == '\0')
return (B_TRUE);
} else {
- if (*com2 == NULL)
+ if (*com2 == '\0')
return (B_TRUE);
else
return (B_FALSE);
/* take care of case: a.b a. */
if (strcmp(str2, ".") == 0
- && (strcmp(str1, ".") != 0 || *str1 != NULL))
+ && (strcmp(str1, ".") != 0 || *str1 != '\0'))
return (B_FALSE);
/* skip "." */
if (*str1 == '.') {
- if (*str2 == NULL)
+ if (*str2 == '\0')
return (B_TRUE);
else {
str1++;
str2++;
}
- } else if (strcmp(str2, ".") == 0 || *str2 == NULL)
+ } else if (strcmp(str2, ".") == 0 || *str2 == '\0')
return (B_TRUE);
else
return (B_FALSE);
get_last_component(str2, &ptr2, com2, '.');
if (*com1) {
- if (*com2 == NULL)
+ if (*com2 == '\0')
return (B_TRUE);
} else {
- if (*com2 == NULL)
+ if (*com2 == '\0')
return (B_TRUE);
else
return (B_FALSE);
char *tmp_date, *str = separator_str(sep);
_Xstrtokparams strtok_buf;
- m[0] = NULL;
- d[0] = NULL;
- y[0] = NULL;
+ m[0] = '\0';
+ d[0] = '\0';
+ y[0] = '\0';
if (datestr == NULL)
return 0;
datestr2mdy(char *datestr, OrderingType order, SeparatorType sep, char *buf) {
char m[3], d[3], y[5];
- buf[0] = NULL;
+ buf[0] = '\0';
if (datestr == NULL)
return 0;
struct tm *tm;
_Xltimeparams localtime_buf;
- buff[0] = NULL;
+ buff[0] = '\0';
tm = _XLocaltime(&tick, localtime_buf);
switch (order) {
boolean_t am;
if (t == 0) {
- sprintf(buffer, "\0");
+ buffer[0] = '\0';
} else if (dt == HOUR12) {
am = adjust_hour(&hr);
*/
idx = sizeof(Dtcm_appointment);
appt = (Dtcm_appointment *)ckalloc(idx);
- memset(appt, NULL, idx);
+ memset(appt, 0, idx);
appt->reason = reason;
appt->version = version;
api_idx = va_arg(pvar, int);
while (api_idx) {
if ((reason == appt_read) || !entry_ident_index_ro(api_idx, version))
- CmDataListAdd(api_ids, (void *)api_idx, 0);
+ CmDataListAdd(api_ids, (void *) (intptr_t) api_idx, 0);
api_idx = va_arg(pvar, int);
}
va_end(pvar);
for (idx = 0; idx < def_attr_count; idx++) {
if ((reason == appt_write) && entry_ident_index_ro(default_appt_attrs[idx], version))
continue;
- CmDataListAdd(api_ids, (void *)default_appt_attrs[idx], 0);
+ CmDataListAdd(api_ids, (void *) (intptr_t) default_appt_attrs[idx], 0);
}
}
appt->num_names = api_ids->count;
idx = sizeof(CSA_attribute_reference *) * appt->num_names;
appt->names = (CSA_attribute_reference *)ckalloc(idx);
- memset(appt->names, NULL, idx);
+ memset(appt->names, 0, idx);
appt->count = api_ids->count;
if (reason == appt_write) {
idx = sizeof(CSA_attribute) * appt->count;
appt->attrs = (CSA_attribute *)ckalloc(idx);
- memset(appt->attrs, NULL, idx);
+ memset(appt->attrs, 0, idx);
}
/*
* Now loop through and set the names and initialize the attributes
*/
for (idx = 0; idx < appt->count; idx++) {
- api_idx = (int)CmDataListGetData(api_ids, idx + 1);
+ api_idx = (int) (intptr_t) CmDataListGetData(api_ids, idx + 1);
appt->names[idx] = strdup(_CSA_entry_attribute_names[api_idx]);
if (reason == appt_write)
initialize_entry_attr(api_idx, &appt->attrs[idx], reason, version);
if (reason == appt_write)
set_appt_links(appt);
- CmDataListDestroy(api_ids, NULL);
+ CmDataListDestroy(api_ids, 0);
return appt;
}
*/
idx = sizeof(Dtcm_calendar);
cal = (Dtcm_calendar *)ckalloc(idx);
- memset(cal, NULL, idx);
+ memset(cal, 0, idx);
cal->reason = reason;
cal->version = version;
api_idx = va_arg(pvar, int);
while (api_idx) {
if ((reason == appt_read) || !cal_ident_index_ro(api_idx, version))
- CmDataListAdd(api_ids, (void *)api_idx, 0);
+ CmDataListAdd(api_ids, (void *) (intptr_t) api_idx, 0);
api_idx = va_arg(pvar, int);
}
va_end(pvar);
for (idx = 0; idx < DEF_CAL_ATTR_COUNT; idx++) {
if ((reason == appt_write) && cal_ident_index_ro(default_cal_attrs[idx], version))
continue;
- CmDataListAdd(api_ids, (void *)default_cal_attrs[idx], 0);
+ CmDataListAdd(api_ids, (void *) (intptr_t) default_cal_attrs[idx], 0);
}
}
cal->num_names = api_ids->count;
idx = sizeof(CSA_attribute_reference) * cal->num_names;
cal->names = (CSA_attribute_reference *)ckalloc(idx);
- memset(cal->names, NULL, idx);
+ memset(cal->names, 0, idx);
cal->count = api_ids->count;
if (reason == appt_write) {
idx = sizeof(CSA_attribute) * cal->count;
cal->attrs = (CSA_attribute *)ckalloc(idx);
- memset(cal->attrs, NULL, idx);
+ memset(cal->attrs, 0, idx);
}
/*
* Now loop through and set the names and initialize the attributes
*/
for (idx = 0; idx < cal->count; idx++) {
- api_idx = (int)CmDataListGetData(api_ids, idx + 1);
+ api_idx = (int) (intptr_t) CmDataListGetData(api_ids, idx + 1);
cal->names[idx] = strdup(_CSA_calendar_attribute_names[api_idx]);
if (reason == appt_write)
initialize_cal_attr(api_idx, &cal->attrs[idx], reason, version);
if (reason == appt_write)
set_cal_links(cal);
- CmDataListDestroy(api_ids, NULL);
+ CmDataListDestroy(api_ids, 0);
return cal;
for (i = 0; i < cal->count; i++) {
if (cal->attrs[i].value->type == CSA_VALUE_REMINDER) {
if ((cal->attrs[i].value->item.reminder_value->lead_time == NULL) ||
- (cal->attrs[i].value->item.reminder_value->lead_time[0] == NULL)) {
+ (cal->attrs[i].value->item.reminder_value->lead_time[0] == '\0')) {
free(cal->attrs[i].name);
cal->attrs[i].name = NULL;
}
if ((reason == appt_write) && !cal_ident_index_ro(id, version)) {
size = sizeof(CSA_attribute_value);
attrs->value = (CSA_attribute_value *)ckalloc(size);
- memset(attrs->value, NULL, size);
+ memset(attrs->value, 0, size);
attrs->value->type = cal_ident_index_tag(id);
if (attrs->value->type == CSA_VALUE_REMINDER)
attrs->value->item.reminder_value = (CSA_reminder *) calloc(sizeof(CSA_reminder), 1);
if ((reason == appt_write) && !entry_ident_index_ro(id, version)) {
size = sizeof(CSA_attribute_value);
attrs->value = (CSA_attribute_value *)ckalloc(size);
- memset(attrs->value, NULL, size);
+ memset(attrs->value, 0, size);
attrs->value->type = entry_ident_index_tag(id);
if (attrs->value->type == CSA_VALUE_REMINDER)
attrs->value->item.reminder_value = (CSA_reminder *) calloc(sizeof(CSA_reminder), 1);
a_size = sizeof(CSA_attribute) * (*count);
attr_ptr = (CSA_attribute *)ckalloc(a_size);
- memset(attr_ptr, NULL, a_size);
+ memset(attr_ptr, 0, a_size);
o_size = sizeof(CSA_enum) * (*count);
op_ptr = (CSA_enum *)ckalloc(o_size);
- memset(op_ptr, NULL, o_size);
+ memset(op_ptr, 0, o_size);
initialize_entry_attr(CSA_ENTRY_ATTR_START_DATE_I, &attr_ptr[0], appt_write, version);
attr_ptr[0].value->item.string_value = malloc(BUFSIZ);