ret_t cherokee_dwriter_null (cherokee_dwriter_t *w) { ENSURE_VALID_STATE; ENSURE_NOT_KEY; ADD_SEP; ADD_WHITE; add_null (w); ADD_END; ADD_NEW_LINE; return ret_ok; }
/** * Convert string from one encoding to another, making error checking etc * * @param src pointer to source string (multibyte or singlebyte) * @param srclen length of the source string in bytes * @param dest pointer to destination string (multibyte or singlebyte) * @param destlen maximal length allowed for string * @returns the number of bytes occupied in the destination **/ static size_t convert_string_internal(charset_t from, charset_t to, void const *src, size_t srclen, void *dest, size_t destlen) { size_t i_len, o_len; size_t retval; const char* inbuf = (const char*)src; char* outbuf = (char*)dest; char* o_save = outbuf; atalk_iconv_t descriptor; /* Fixed based on Samba 3.0.6 */ if (srclen == (size_t)-1) { if (from == CH_UCS2) { srclen = (strlen_w((const ucs2_t *)src)) * 2; } else { srclen = strlen((const char *)src); } } lazy_initialize_conv(); descriptor = conv_handles[from][to]; if (descriptor == (atalk_iconv_t)-1 || descriptor == (atalk_iconv_t)0) { return (size_t) -1; } i_len=srclen; o_len=destlen; retval = atalk_iconv(descriptor, &inbuf, &i_len, &outbuf, &o_len); if(retval==(size_t)-1) { const char *reason="unknown error"; switch(errno) { case EINVAL: reason="Incomplete multibyte sequence"; break; case E2BIG: reason="No more room"; break; case EILSEQ: reason="Illegal multibyte sequence"; break; } LOG(log_debug, logtype_default,"Conversion error: %s",reason); return (size_t)-1; } /* Terminate the string */ return add_null( to, o_save, o_len, destlen -o_len); }
ret_t cherokee_dwriter_string (cherokee_dwriter_t *w, const char *s, int len) { ENSURE_VALID_STATE; ADD_SEP; ADD_WHITE; if (unlikely (s == NULL)) { add_null (w); goto out; } cherokee_buffer_add_str (OUT, "\""); escape_string (w->tmp, s, len, w->lang); cherokee_buffer_add (OUT, w->tmp->buf, w->tmp->len); cherokee_buffer_add_str (OUT, "\""); out: ADD_END; ADD_NEW_LINE; return ret_ok; }
//very special case void visitNullPointer() { count++; add_edge(s.top(), count); add_null(count); }
int evresp_(char *sta, char *cha, char *net, char *locid, char *datime, char *units, char *file, float *freqs, int *nfreqs_in, float *resp, char *rtype, char *verbose, int *start_stage, int *stop_stage, int *stdio_flag, int lsta, int lcha, int lnet, int llocid, int ldatime, int lunits, int lfile, int lrtype, int lverbose, int useTotalSensitivityFlag) { struct response *first = (struct response *)NULL; double *dfreqs; int i,j, nfreqs, start, stop, flag; /* add null characters to end of input string arguments (remove trailing spaces first */ add_null(sta, lsta-1, 'a'); add_null(cha, lcha-1, 'a'); add_null(net, lnet-1, 'a'); add_null(locid, llocid-1, 'a'); add_null(datime, ldatime-1, 'a'); add_null(units, lunits-1, 'a'); add_null(file, lfile-1, 'a'); add_null(rtype, lrtype-1, 'a'); add_null(verbose, lverbose-1, 'a'); nfreqs = *nfreqs_in; start = *start_stage; stop = *stop_stage; flag = *stdio_flag; dfreqs = alloc_double(nfreqs); for(i = 0; i < nfreqs; i++) dfreqs[i] = freqs[i]; /* then call evresp */ first = evresp(sta, cha, net, locid, datime, units, file, dfreqs, nfreqs, rtype, verbose, start, stop, flag, useTotalSensitivityFlag); /* free up the frequency vector */ free(dfreqs); /* check the output. If no response found, return 1, else if more than one response found, return -1 */ if(first == (struct response *)NULL) { return(1); } else if(first->next != (struct response *)NULL) { free_response(first); return(-1); } /* if only one response found, convert from complex output vector into multiplexed real output for FORTRAN (real1, imag1, real2, imag2, ..., realN, imagN) */ for(i = 0, j = 0; i < nfreqs; i++) { resp[j++] = (float) first->rvec[i].real; resp[j++] = (float) first->rvec[i].imag; } /* free up dynamically allocated space */ free_response(first); /* and return to FORTRAN program */ return(0); }