PTErr_t initAttrib (PTRefNum_t PTRefNum) { PTErr_t errnum = KCP_SUCCESS; KpInt32_t attrSize, year; KpChar_t attrBuf[KCM_MAX_ATTRIB_VALUE_LENGTH+1], yearStr[10]; kpTm_t currentTime; /* If the copyright string isn't there, then generate it */ attrSize = KCM_MAX_ATTRIB_VALUE_LENGTH; errnum = PTGetAttribute (PTRefNum, KCM_COPYRIGHT, &attrSize, attrBuf); if (errnum == KCP_INVAL_PTA_TAG) { KpGetLocalTime(¤tTime); /* get the current time, which has the current year */ year = currentTime.year + 1900; /* add 1900 to get the actual year */ KpItoa (year, yearStr); strcpy (attrBuf, FUT_COPYRIGHT_PREFIX); /* make the copyright string. */ strcat (attrBuf, yearStr); strcat (attrBuf, FUT_COPYRIGHT_SUFFIX); errnum = PTSetAttribute (PTRefNum, KCM_COPYRIGHT, attrBuf); } return errnum; }
/* Generate attributes which must be in each PT */ static PTErr_t generateAttr (PTRefNum_t PTRefNumR) { PTErr_t PTErr; KpChar_t attrStr[KCM_MAX_ATTRIB_VALUE_LENGTH+1]; kpTm_t Date; KpGetLocalTime (&Date); /* get the current date and time */ KpItoa ((KpInt32_t) (1900 + Date.year), attrStr); /* start with year */ addIntStr ((KpInt32_t)Date.mon, attrStr); /* month */ addIntStr ((KpInt32_t)Date.mday, attrStr); /* day */ addIntStr ((KpInt32_t)Date.hour, attrStr); /* hour */ addIntStr ((KpInt32_t)Date.min, attrStr); /* minute */ addIntStr ((KpInt32_t)Date.sec, attrStr); /* second */ PTErr = PTSetAttribute (PTRefNumR, KCM_CREATE_TIME, attrStr); /* write time to destination PT */ if (PTErr == KCP_SUCCESS) { KpItoa (KCM_COMPOSED_CLASS, attrStr); PTErr = PTSetAttribute (PTRefNumR, KCM_CLASS, attrStr); /* set composition state to composed */ } return (PTErr); }