text:
/* -------------------------------------------------------------------- */
/*  ACCORDS PLATFORM                                                    */
/*  (C) 2011 by Iain James Marshall (Prologue) <ijm667@hotmail.com>     */
/* -------------------------------------------------------------------- */
/* Licensed under the Apache License, Version 2.0 (the "License"); 	*/
/* you may not use this file except in compliance with the License. 	*/
/* You may obtain a copy of the License at 				*/
/*  									*/
/*  http://www.apache.org/licenses/LICENSE-2.0 				*/
/*  									*/
/* Unless required by applicable law or agreed to in writing, software 	*/
/* distributed under the License is distributed on an "AS IS" BASIS, 	*/
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 	*/
/* implied. 								*/
/* See the License for the specific language governing permissions and 	*/
/* limitations under the License. 					*/
/* -------------------------------------------------------------------- */

/* STRUKT WARNING : this file has been generated and should not be modified by hand */
#ifndef _occievent_c_
#define _occievent_c_

#include "event.h"

/*	--------------------------------	*/
/*	o c c i _ c o r d s _ e v e n t 	*/
/*	--------------------------------	*/

/*	--------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   m a n a g e m e n t   s t r u c t u r e 	*/
/*	--------------------------------------------------------------------	*/
struct cords_event * allocate_cords_event();
struct cords_event * liberate_cords_event(struct cords_event * optr);
private pthread_mutex_t list_cords_event_control=PTHREAD_MUTEX_INITIALIZER;
private struct occi_kind_node * cords_event_first = (struct occi_kind_node *) 0;
private struct occi_kind_node * cords_event_last  = (struct occi_kind_node *) 0;
public struct  occi_kind_node * occi_first_cords_event_node() { return( cords_event_first ); }
public struct  occi_kind_node * occi_last_cords_event_node() { return( cords_event_last ); }

/*	----------------------------------------------	*/
/*	o c c i   c a t e g o r y   d r o p   n o d e 	*/
/*	----------------------------------------------	*/
private struct occi_kind_node * ll_drop_cords_event_node(struct occi_kind_node * nptr) {
	if ( nptr ) {
	if (!( nptr->previous ))
		cords_event_first = nptr->next;
	else	nptr->previous->next = nptr->next;
	if (!( nptr->next ))
		cords_event_last = nptr->previous;
	else	nptr->next->previous = nptr->previous;
		liberate_occi_kind_node( nptr );
		}
	return((struct occi_kind_node *)0);
}
private struct occi_kind_node * drop_cords_event_node(struct occi_kind_node * nptr) {
	pthread_mutex_lock( &list_cords_event_control );
	nptr = ll_drop_cords_event_node( nptr );
	pthread_mutex_unlock( &list_cords_event_control );
	return(nptr);
}

/*	--------------------------------------------------	*/
/*	o c c i   c a t e g o r y   l o c a t e   n o d e 	*/
/*	--------------------------------------------------	*/
private struct occi_kind_node * ll_locate_cords_event_node(char * id) {
	struct occi_kind_node * nptr;
	struct cords_event * pptr;
	for ( nptr = cords_event_first;
		nptr != (struct occi_kind_node *) 0;
		nptr = nptr->next ) {
		if (!( pptr = nptr->contents )) continue;
		else if (!( pptr->id )) continue;
		else if (!( strcmp(pptr->id,id) )) break;
		}
	return( nptr );
}
private struct occi_kind_node * locate_cords_event_node(char * id) {
	struct occi_kind_node * nptr;
	pthread_mutex_lock( &list_cords_event_control );
	nptr = ll_locate_cords_event_node(id);
	pthread_mutex_unlock( &list_cords_event_control );
	return( nptr );
}

/*	--------------------------------------------	*/
/*	o c c i   c a t e g o r y   a d d   n o d e 	*/
/*	--------------------------------------------	*/
private struct occi_kind_node * ll_add_cords_event_node(int mode) {
	struct occi_kind_node * nptr;
	struct cords_event * pptr;
	if (!( nptr = allocate_occi_kind_node() ))
		return( nptr );
	else	{
		if (!( nptr->contents = allocate_cords_event()))
			return( liberate_occi_kind_node(nptr) );
		if (!( pptr = nptr->contents ))
			return( liberate_occi_kind_node(nptr) );
		else if (( mode != 0 ) && (!( pptr->id = occi_allocate_uuid())))
			return( liberate_occi_kind_node(nptr) );
		else	{
			if (!( nptr->previous = cords_event_last ))
				cords_event_first = nptr;
			else	nptr->previous->next = nptr;
			cords_event_last = nptr;
			return( nptr );
			}
		}
}
private struct occi_kind_node * add_cords_event_node(int mode) {
	struct occi_kind_node * nptr;
	pthread_mutex_lock( &list_cords_event_control );
	nptr = ll_add_cords_event_node( mode );
	pthread_mutex_unlock( &list_cords_event_control );
	return(nptr);
}

/*	------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   a u t o   l o a d 	*/
/*	------------------------------------------------------------------------------------------	*/
private char*autosave_cords_event_name="cords_event.xml";
private void autoload_cords_event_nodes() {
	char * fn=autosave_cords_event_name;	struct occi_kind_node * nptr;
	struct cords_event * pptr;
	struct xml_element * document;
	struct xml_element * eptr;
	struct xml_element * vptr;
	struct xml_atribut  * aptr;
	if (!( document = document_parse_file(fn)))
		return;
	if ((eptr = document_element(document,"cords_events")) != (struct xml_element *) 0) {
		for (vptr=eptr->first; vptr != (struct xml_element *) 0; vptr=vptr->next) {
			if (!( vptr->name )) continue;
			else if ( strcmp( vptr->name, "cords_event" ) ) continue;
			else if (!( nptr = add_cords_event_node(0))) break;
			else if (!( pptr = nptr->contents )) break;
			if ((aptr = document_atribut( vptr, "id" )) != (struct xml_atribut *) 0)
				pptr->id = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "source" )) != (struct xml_atribut *) 0)
				pptr->source = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "target" )) != (struct xml_atribut *) 0)
				pptr->target = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "nature" )) != (struct xml_atribut *) 0)
				pptr->nature = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "description" )) != (struct xml_atribut *) 0)
				pptr->description = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "compliment" )) != (struct xml_atribut *) 0)
				pptr->compliment = document_atribut_string(aptr);
			if ((aptr = document_atribut( vptr, "timestamp" )) != (struct xml_atribut *) 0)
				pptr->timestamp = document_atribut_value(aptr);
			if ((aptr = document_atribut( vptr, "state" )) != (struct xml_atribut *) 0)
				pptr->state = document_atribut_value(aptr);
			}
		}
	document = document_drop( document );
	return;
}

/*	------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   a u t o   s a v e 	*/
/*	------------------------------------------------------------------------------------------	*/
public  void set_autosave_cords_event_name(char * fn) {
	autosave_cords_event_name = fn;	return;
}
public  void autosave_cords_event_nodes() {
	char * fn=autosave_cords_event_name;	struct occi_kind_node * nptr;
	struct cords_event * pptr;
	FILE * h;
	pthread_mutex_lock( &list_cords_event_control );
	if (( h = fopen(fn,"w")) != (FILE *) 0) {
	fprintf(h,"<cords_events>\n");
	for ( nptr = cords_event_first;
		nptr != (struct occi_kind_node *) 0;
		nptr = nptr->next ) {
		if (!( pptr = nptr->contents )) continue;
		fprintf(h,"<cords_event\n");
		fprintf(h," id=%c",0x0022);
		fprintf(h,"%s",(pptr->id?pptr->id:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," source=%c",0x0022);
		fprintf(h,"%s",(pptr->source?pptr->source:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," target=%c",0x0022);
		fprintf(h,"%s",(pptr->target?pptr->target:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," nature=%c",0x0022);
		fprintf(h,"%s",(pptr->nature?pptr->nature:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," description=%c",0x0022);
		fprintf(h,"%s",(pptr->description?pptr->description:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," compliment=%c",0x0022);
		fprintf(h,"%s",(pptr->compliment?pptr->compliment:""));
		fprintf(h,"%c",0x0022);
		fprintf(h," timestamp=%c",0x0022);
		fprintf(h,"%u",pptr->timestamp);
		fprintf(h,"%c",0x0022);
		fprintf(h," state=%c",0x0022);
		fprintf(h,"%u",pptr->state);
		fprintf(h,"%c",0x0022);
		fprintf(h," />\n");
		}
	fprintf(h,"</cords_events>\n");
	fclose(h);
	}
	pthread_mutex_unlock( &list_cords_event_control );
	return;
}

/*	------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   s e t   f i e l d 	*/
/*	------------------------------------------------------------------------------------------	*/
private void set_cords_event_field(
	struct occi_category * cptr,void * optr, char * nptr, char * vptr)
{
	struct cords_event * pptr;
	char prefix[1024];
	if (!( pptr = optr )) return;
	sprintf(prefix,"%s.%s.",cptr->domain,cptr->id);
	if (!( strncmp( nptr, prefix, strlen(prefix) ) )) {
		nptr += strlen(prefix);
		if (!( strcmp( nptr, "source" ) ))
			pptr->source = allocate_string(vptr);
		if (!( strcmp( nptr, "target" ) ))
			pptr->target = allocate_string(vptr);
		if (!( strcmp( nptr, "nature" ) ))
			pptr->nature = allocate_string(vptr);
		if (!( strcmp( nptr, "description" ) ))
			pptr->description = allocate_string(vptr);
		if (!( strcmp( nptr, "compliment" ) ))
			pptr->compliment = allocate_string(vptr);
		if (!( strcmp( nptr, "timestamp" ) ))
			pptr->timestamp = atoi(vptr);
		if (!( strcmp( nptr, "state" ) ))
			pptr->state = atoi(vptr);
		}
	return;
}

/*	--------------------------------------------------	*/
/*	o c c i   c a t e g o r y   f i l t e r   i n f o 	*/
/*	--------------------------------------------------	*/
private struct cords_event * filter_cords_event_info(
	struct occi_category * optr,
	struct rest_request  * rptr,
	struct rest_response * aptr) {
	struct cords_event * pptr;
		if (!( pptr = allocate_cords_event()))
		return( pptr );
	else if (!( occi_process_atributs(optr, rptr, aptr, pptr, set_cords_event_field) ))
		return( liberate_cords_event(pptr));
	else	return( pptr );
}

/*	--------------------------------------------------	*/
/*	o c c i   c a t e g o r y   f i l t e r   p a s s 	*/
/*	--------------------------------------------------	*/
private int pass_cords_event_filter(
	struct cords_event * pptr,struct cords_event * fptr) {
	if (( fptr->id )
	&&  (strlen( fptr->id ) != 0)) {
		if (!( pptr->id ))
			return(0);
		else if ( strcmp(pptr->id,fptr->id) != 0)
			return(0);
		}
	if (( fptr->source )
	&&  (strlen( fptr->source ) != 0)) {
		if (!( pptr->source ))
			return(0);
		else if ( strcmp(pptr->source,fptr->source) != 0)
			return(0);
		}
	if (( fptr->target )
	&&  (strlen( fptr->target ) != 0)) {
		if (!( pptr->target ))
			return(0);
		else if ( strcmp(pptr->target,fptr->target) != 0)
			return(0);
		}
	if (( fptr->nature )
	&&  (strlen( fptr->nature ) != 0)) {
		if (!( pptr->nature ))
			return(0);
		else if ( strcmp(pptr->nature,fptr->nature) != 0)
			return(0);
		}
	if (( fptr->description )
	&&  (strlen( fptr->description ) != 0)) {
		if (!( pptr->description ))
			return(0);
		else if ( strcmp(pptr->description,fptr->description) != 0)
			return(0);
		}
	if (( fptr->compliment )
	&&  (strlen( fptr->compliment ) != 0)) {
		if (!( pptr->compliment ))
			return(0);
		else if ( strcmp(pptr->compliment,fptr->compliment) != 0)
			return(0);
		}
	if (( fptr->timestamp ) && ( pptr->timestamp != fptr->timestamp )) return(0);
	if (( fptr->state ) && ( pptr->state != fptr->state )) return(0);
	return(1);
}

/*	----------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   r e s p o n s e 	*/
/*	----------------------------------------------------------------------------------------	*/
private struct rest_response * cords_event_occi_response(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr,
	struct cords_event * pptr)
{
	struct rest_header * hptr;
	sprintf(cptr->buffer,"occi.core.id=%s",pptr->id);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.source=%s",optr->domain,optr->id,pptr->source);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.target=%s",optr->domain,optr->id,pptr->target);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.nature=%s",optr->domain,optr->id,pptr->nature);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.description=%s",optr->domain,optr->id,pptr->description);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.compliment=%s",optr->domain,optr->id,pptr->compliment);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.timestamp=%u",optr->domain,optr->id,pptr->timestamp);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	sprintf(cptr->buffer,"%s.%s.state=%u",optr->domain,optr->id,pptr->state);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Attribute",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	if ( occi_render_links( aptr, pptr->id ) != 0)
		return( rest_html_response( aptr, 500, "Server Link Failure" ) );
	else	if (!( occi_success( aptr ) ))
		return( rest_response_status( aptr, 500, "Server Failure" ) );
	else	return( rest_response_status( aptr, 200, "OK" ) );
}

/*	----------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   g e t   i t e m 	*/
/*	----------------------------------------------------------------------------------------	*/
private struct rest_response * cords_event_get_item(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr, char * id)
{
	struct rest_header * hptr;
	struct occi_interface * iptr;
	struct occi_kind_node * nptr;
	struct cords_event * pptr;
	iptr = optr->callback;
	if (!( nptr = locate_cords_event_node(id)))
		return( rest_html_response( aptr, 404, "Not Found") );
	else if (!( pptr = nptr->contents ))
		return( rest_html_response( aptr, 404, "Not Found") );
	if (( iptr ) && (iptr->retrieve)) (*iptr->retrieve)(optr,nptr);
	autosave_cords_event_nodes();
	return( cords_event_occi_response(optr,cptr,rptr,aptr,pptr));
}

/*	------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   p o s t   l i n k 	*/
/*	------------------------------------------------------------------------------------------	*/
private struct rest_response * cords_event_post_link(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr,char * id)
{
	struct rest_header * hptr;
	struct occi_interface * iptr;
	struct occi_kind_node * nptr;
	struct cords_event * pptr;
	char * reqhost;
	if (!( nptr = locate_cords_event_node(id)))
		return( rest_html_response( aptr, 404, "Not Found") );
	else if (!( pptr = nptr->contents ))
		return( rest_html_response( aptr, 404, "Not Found") );
	else	return( rest_html_response( aptr, 400, "Bad Request") );
}

/*	--------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   p o s t   m i x i n 	*/
/*	--------------------------------------------------------------------------------------------	*/
private struct rest_response * cords_event_post_mixin(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr,char * id)
{
	struct rest_header * hptr;
	struct occi_interface * iptr;
	struct occi_kind_node * nptr;
	struct cords_event * pptr;
	char * reqhost;
	if (!( nptr = locate_cords_event_node(id)))
		return( rest_html_response( aptr, 404, "Not Found") );
	else if (!( pptr = nptr->contents ))
		return( rest_html_response( aptr, 404, "Not Found") );
	else	return( rest_html_response( aptr, 400, "Bad Request"));
}

/*	----------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   p o s t   a c t i o n 	*/
/*	----------------------------------------------------------------------------------------------	*/
private struct rest_response * cords_event_post_action(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr,char * id)
{
	struct rest_header * hptr;
	struct occi_interface * iptr;
	struct occi_action * fptr;
	struct occi_kind_node * nptr;
	struct cords_event * pptr;
	char * reqhost;
	char * mptr;
	if (!( nptr = locate_cords_event_node(id)))
		return( rest_html_response( aptr, 404, "Not Found") );
	else if (!( pptr = nptr->contents ))
		return( rest_html_response( aptr, 404, "Not Found") );
	mptr = (rptr->parameters+strlen("action="));
	for ( fptr=optr->firstact;
		fptr != (struct occi_action *) 0;
		fptr = fptr->next )
		if (!( strncmp( mptr, fptr->name, strlen( fptr->name )) ))
			return( occi_invoke_action(fptr,optr,cptr,rptr,aptr,pptr) );
	return( rest_html_response( aptr, 400, "Incorrect Action Request"));
}

/*	------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   p o s t   i t e m 	*/
/*	------------------------------------------------------------------------------------------	*/
private struct rest_response * cords_event_post_item(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr)
{
	struct rest_header * hptr;
	struct occi_interface * iptr;
	struct occi_kind_node * nptr;
	struct cords_event * pptr;
	char * reqhost;
	iptr = optr->callback;
	if (!( reqhost = rest_request_host( rptr ) ))
		return( rest_html_response( aptr, 400, "Bad Request" ) );
	if (!( nptr = add_cords_event_node(1)))
		return( rest_html_response( aptr, 500, "Server Failure") );
	else if (!( pptr = nptr->contents ))
		return( rest_html_response( aptr, 500, "Server Failure") );
	if (!( occi_process_atributs( optr, rptr,aptr, pptr, set_cords_event_field ) ))
		return( rest_html_response( aptr, 500, "Server Failure") );
	if (( iptr ) && (iptr->create)) (*iptr->create)(optr,nptr);
	autosave_cords_event_nodes();
	sprintf(cptr->buffer,"%s%s%s",reqhost,optr->location,pptr->id);
	if (!( hptr = rest_response_header( aptr, "X-OCCI-Location",cptr->buffer) ))
		return( rest_html_response( aptr, 500, "Server Failure" ) );
	else if (!( occi_success( aptr ) ))
		return( rest_response_status( aptr, 500, "Server Failure" ) );
	else	return( rest_response_status( aptr, 200, "OK" ) );
}

/*	----------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   p u t   i t e m 	*/
/*	----------------------------------------------------------------------------------------	*/
private struct rest_response * cords_event_put_item(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr,char * id)
{
	struct rest_header * hptr;
	struct occi_interface * iptr;
	struct occi_kind_node * nptr;
	struct cords_event * pptr;
	iptr = optr->callback;
	if (!( nptr = locate_cords_event_node(id)))
		return( rest_html_response( aptr, 404, "Not Found") );
	else if (!( pptr = nptr->contents ))
		return( rest_html_response( aptr, 404, "Not Found") );
	if (!( occi_process_atributs(optr,rptr,aptr, pptr, set_cords_event_field ) ))
		return( rest_html_response( aptr, 500, "Server Failure") );
	if (( iptr ) && (iptr->update)) (*iptr->update)(optr,nptr);
	autosave_cords_event_nodes();
	return( cords_event_occi_response(optr,cptr,rptr,aptr,pptr));
}

/*	------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   h e a d   i t e m 	*/
/*	------------------------------------------------------------------------------------------	*/
private struct rest_response * cords_event_head_item(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr,char * id)
{
	struct rest_header * hptr;
	struct occi_kind_node * nptr;
	struct cords_event * pptr;
	if (!( nptr = locate_cords_event_node(id)))
		return( rest_html_response( aptr, 404, "Not Found") );
	else if (!( pptr = nptr->contents ))
		return( rest_html_response( aptr, 404, "Not Found") );
	else	return( rest_html_response( aptr, 400, "Bad Request") );
}

/*	----------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   d e l e t e   i t e m 	*/
/*	----------------------------------------------------------------------------------------------	*/
private struct rest_response * cords_event_delete_item(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr, char * id)
{
	struct rest_header * hptr;
	struct occi_interface * iptr;
	struct occi_kind_node * nptr;
	struct cords_event * pptr;
	iptr = optr->callback;
	if (!( nptr = locate_cords_event_node(id)))
		return( rest_html_response( aptr, 404, "Not Found") );
	if (( iptr ) && (iptr->delete)) (*iptr->delete)(optr,nptr);
	drop_cords_event_node( nptr );
	autosave_cords_event_nodes();
	if (!( occi_success( aptr ) ))
		return( rest_response_status( aptr, 500, "Server Failure" ) );
	else	return( rest_response_status( aptr, 200, "OK" ) );
}

/*	----------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   g e t   l i s t 	*/
/*	----------------------------------------------------------------------------------------	*/
private struct rest_response * cords_event_get_list(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr)
{
	struct rest_header * hptr;
	struct occi_kind_node * sptr;
	struct cords_event * pptr;
	struct cords_event * fptr;
	char * reqhost;
	if (!( reqhost = rest_request_host( rptr ) ))
		return( rest_html_response( aptr, 400, "Bad Request" ) );
	else if (!( fptr = filter_cords_event_info( optr, rptr, aptr ) ))
		return( rest_html_response( aptr, 400, "Bad Request" ) );
	for ( sptr = cords_event_first;
		sptr != (struct occi_kind_node *) 0;
		sptr = sptr->next ) {
		if (!( pptr = sptr->contents ))
			continue;
		if (!( pass_cords_event_filter( pptr, fptr ) ))
			continue;
		sprintf(cptr->buffer,"%s%s%s",reqhost,optr->location,pptr->id);
		if (!( hptr = rest_response_header( aptr, "X-OCCI-Location",cptr->buffer) ))
			return( rest_html_response( aptr, 500, "Server Failure" ) );
		}
	if (!( occi_success( aptr ) ))
		return( rest_response_status( aptr, 500, "Server Failure" ) );
	else	return( rest_response_status( aptr, 200, "OK" ) );
}

/*	--------------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   d e l e t e   a l l 	*/
/*	--------------------------------------------------------------------------------------------	*/
private struct rest_response * cords_event_delete_all(
	struct occi_category * optr, struct rest_client * cptr,
	struct rest_request * rptr, struct rest_response * aptr)
{
	struct rest_header * hptr;
	struct occi_interface * iptr;
	struct occi_kind_node * nptr;
	struct occi_kind_node * sptr;
	struct cords_event * pptr;
	struct cords_event * fptr;
	iptr = optr->callback;
	if (!( fptr = filter_cords_event_info( optr, rptr, aptr ) ))
		return( rest_html_response( aptr, 400, "Bad Request" ) );
	nptr=cords_event_first;
	while (nptr != (struct occi_kind_node *) 0) {
		if ((!( pptr = nptr->contents ))
		||  (!( pass_cords_event_filter( pptr, fptr ) ))) {
			nptr = nptr->next;
			continue;
			}
		else	{
			if (( iptr ) && (iptr->delete)) { (*iptr->delete)(optr,nptr); }
			sptr = nptr->next;
			drop_cords_event_node( nptr );
			nptr = sptr;
			}
		}
	autosave_cords_event_nodes();
	if (!( occi_success( aptr ) ))
		return( rest_response_status( aptr, 500, "Server Failure" ) );
	else	return( rest_response_status( aptr, 200, "OK" ) );
}

/*	------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   g e t 	*/
/*	------------------------------------------------------------------------------	*/
private struct rest_response * occi_cords_event_get(void * vptr, struct rest_client * cptr, struct rest_request * rptr)
{
	struct rest_response * aptr;
	struct rest_header   * hptr;
	struct occi_category * optr;
	char * ctptr;
	char * mptr;
	if (!( hptr = rest_resolve_header( rptr->first, "Content-Type" ) ))
		ctptr = "text/occi";
	else	ctptr = hptr->value;
	if (!( optr = vptr ))
		return( rest_bad_request(vptr,cptr,rptr) );
	if(!(aptr = rest_allocate_response( cptr )))
		return( aptr );
	else if (!(strcmp( rptr->object, optr->location ) ))
		return( cords_event_get_list( optr, cptr, rptr, aptr ) );
	else if (!(strncmp( rptr->object, optr->location, strlen(optr->location) ) ))
		return( cords_event_get_item( optr, cptr, rptr, aptr,rptr->object+strlen(optr->location) ) );
	else	return( rest_html_response( aptr, 400, "Bad Request") );
}

/*	--------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   h e a d 	*/
/*	--------------------------------------------------------------------------------	*/
private struct rest_response * occi_cords_event_head(void * vptr, struct rest_client * cptr, struct rest_request * rptr)
{
	struct rest_response * aptr;
	struct rest_header   * hptr;
	struct occi_category * optr;
	char * ctptr;
	char * mptr;
	if (!( hptr = rest_resolve_header( rptr->first, "Content-Type" ) ))
		ctptr = "text/occi";
	else	ctptr = hptr->value;
	if (!( optr = vptr ))
		return( rest_bad_request(vptr,cptr,rptr) );
	if(!(aptr = rest_allocate_response( cptr )))
		return( aptr );
	else if (!(strncmp( rptr->object, optr->location, strlen(optr->location) ) ))
		return( cords_event_head_item( optr, cptr, rptr, aptr,rptr->object+strlen(optr->location) ) );
	else	return( rest_html_response( aptr, 400, "Bad Request") );
}

/*	--------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   p o s t 	*/
/*	--------------------------------------------------------------------------------	*/
private struct rest_response * occi_cords_event_post(void * vptr, struct rest_client * cptr, struct rest_request * rptr)
{
	struct rest_response * aptr;
	struct rest_header   * hptr;
	struct occi_category * optr;
	char * ctptr;
	char * mptr;
	if (!( hptr = rest_resolve_header( rptr->first, "Content-Type" ) ))
		ctptr = "text/occi";
	else	ctptr = hptr->value;
	if (!( optr = vptr ))
		return( rest_bad_request(vptr,cptr,rptr) );
	if(!(aptr = rest_allocate_response( cptr )))
		return( aptr );
	else if (!( strcmp( rptr->object, optr->location ) ))
		return( cords_event_post_item( optr, cptr, rptr, aptr ) );
	else if ( strncmp( rptr->object, optr->location,strlen(optr->location)) != 0)
		return( rest_html_response( aptr, 400, "Bad Request") );
	else if (!( rptr->parameters ))
		return( rest_html_response( aptr, 400, "Bad Request") );
	else if (!( strncmp( rptr->parameters, "action=", strlen("action=")) ))
		return( cords_event_post_action( optr, cptr, rptr, aptr,rptr->object+strlen(optr->location) ) );
	else if (!( strncmp( rptr->parameters, "mixin=", strlen("mixin=")) ))
		return( cords_event_post_mixin( optr, cptr, rptr, aptr,rptr->object+strlen(optr->location) ) );
	else if (!( strncmp( rptr->parameters, "link=", strlen("link=")) ))
		return( cords_event_post_link( optr, cptr, rptr, aptr,rptr->object+strlen(optr->location) ) );
	else	return( rest_html_response( aptr, 400, "Bad Request") );
}

/*	------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   p u t 	*/
/*	------------------------------------------------------------------------------	*/
private struct rest_response * occi_cords_event_put(void * vptr, struct rest_client * cptr, struct rest_request * rptr)
{
	struct rest_response * aptr;
	struct rest_header   * hptr;
	struct occi_category * optr;
	char * ctptr;
	char * mptr;
	if (!( hptr = rest_resolve_header( rptr->first, "Content-Type" ) ))
		ctptr = "text/occi";
	else	ctptr = hptr->value;
	if (!( optr = vptr ))
		return( rest_bad_request(vptr,cptr,rptr) );
	if(!(aptr = rest_allocate_response( cptr )))
		return( aptr );
	else if (!(strncmp( rptr->object, optr->location, strlen(optr->location) ) ))
		return( cords_event_put_item( optr, cptr, rptr, aptr,rptr->object+strlen(optr->location) ) );
	else	return( rest_html_response( aptr, 400, "Bad Request") );
}

/*	------------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   m e t h o d   d e l e t e 	*/
/*	------------------------------------------------------------------------------------	*/
private struct rest_response * occi_cords_event_delete(void * vptr, struct rest_client * cptr, struct rest_request * rptr)
{
	struct rest_response * aptr;
	struct rest_header   * hptr;
	struct occi_category * optr;
	char * ctptr;
	char * mptr;
	if (!( hptr = rest_resolve_header( rptr->first, "Content-Type" ) ))
		ctptr = "text/occi";
	else	ctptr = hptr->value;
	if (!( optr = vptr ))
		return( rest_bad_request(vptr,cptr,rptr) );
	if(!(aptr = rest_allocate_response( cptr )))
		return( aptr );
	else if (!(strcmp( rptr->object, optr->location ) ))
		return( cords_event_delete_all( optr, cptr, rptr, aptr ) );
	else if (!(strncmp( rptr->object, optr->location, strlen(optr->location) ) ))
		return( cords_event_delete_item( optr, cptr, rptr, aptr,rptr->object+strlen(optr->location) ) );
	else	return( rest_html_response( aptr, 400, "Bad Request") );
}

/*	--------------------------------------------------------------------------------	*/
/*	o c c i   c a t e g o r y   r e s t   i n t e r f a c e   r e d i r e c t i o n 	*/
/*	--------------------------------------------------------------------------------	*/
private void	redirect_occi_cords_event_mt( struct rest_interface * iptr )
{
	iptr->get = occi_cords_event_get;
	iptr->post = occi_cords_event_post;
	iptr->put = occi_cords_event_put;
	iptr->delete = occi_cords_event_delete;
	iptr->head = occi_cords_event_head;
	return;
}

/*	------------------------------------	*/
/*	c r u d   d e l e t e   a c t i o n 	*/
/*	------------------------------------	*/
private struct rest_response * delete_action_cords_event(struct occi_category * optr,
struct rest_client * cptr,
struct rest_request * rptr,
struct rest_response * aptr,
void * vptr )
{
	aptr = liberate_rest_response( aptr );
	return( occi_cords_event_delete(optr,cptr,rptr));
}

/*	------------------------------------------	*/
/*	o c c i   c a t e g o r y   b u i l d e r 	*/
/*	------------------------------------------	*/
/* occi category rest instance builder for : occi_cords_event */
public struct occi_category * occi_cords_event_builder(char * a,char * b) {
	char * c="http://scheme.compatibleone.fr/scheme/compatible#";
	char * d="kind";
	char * e="http://scheme.ogf.org/occi/resource#";
	char * f="CompatibleOne OCCI resource cords_event";
	struct occi_category * optr;
	if (!( optr = occi_create_category(a,b,c,d,e,f) )) { return(optr); }
	else {
		redirect_occi_cords_event_mt(optr->interface);
		if (!( optr = occi_add_attribute(optr, "source",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "target",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "nature",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "description",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "compliment",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "timestamp",0,0) ))
			return(optr);
		if (!( optr = occi_add_attribute(optr, "state",0,0) ))
			return(optr);
		if (!( optr = occi_add_action( optr,"DELETE","",delete_action_cords_event)))
			return( optr );
		autoload_cords_event_nodes();
		return(optr);
	}

}

/*	------------------------------------------------	*/
/*	c o r d s _ e v e n t _ o c c i _ h e a d e r s 	*/
/*	------------------------------------------------	*/
public struct rest_header *  cords_event_occi_headers(struct cords_event * sptr)
{
	struct rest_header * first=(struct rest_header *) 0;
	struct rest_header * last=(struct rest_header *) 0;
	struct rest_header * hptr=(struct rest_header *) 0;
	char buffer[8192];
	if (!( sptr )) return(0);
	if (!( hptr = allocate_rest_header()))
		return(hptr);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("Category")))
		return(first);
	sprintf(buffer,"cords_event; scheme='http://scheme.compatibleone.fr/scheme/compatible#'; class='kind';\r\n");
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_event.source='%s'\r\n",(sptr->source?sptr->source:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_event.target='%s'\r\n",(sptr->target?sptr->target:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_event.nature='%s'\r\n",(sptr->nature?sptr->nature:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_event.description='%s'\r\n",(sptr->description?sptr->description:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_event.compliment='%s'\r\n",(sptr->compliment?sptr->compliment:""));
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_event.timestamp='%u'\r\n",sptr->timestamp);
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	if (!( hptr = allocate_rest_header()))
		return(first);
		else	if (!( hptr->previous = last))
			first = hptr;
		else	hptr->previous->next = hptr;
		last = hptr;
	if (!( hptr->name = allocate_string("X-OCCI-Attribute")))
		return(first);
	sprintf(buffer,"occi.cords_event.state='%u'\r\n",sptr->state);
	if (!( hptr->value = allocate_string(buffer)))
		return(first);
	return(first);

}

#endif	/* _occievent_c_ */


text:
require 'puppet/provider/package'
require 'uri'

# Ruby gems support.
Puppet::Type.type(:rvm_gem).provide(:gem) do
  desc 'Ruby Gem support using RVM.'

  has_feature :versionable
  has_command(:rvmcmd, '/usr/local/rvm/bin/rvm') do
    environment HOME: ENV['HOME']
  end

  def ruby_version
    resource[:ruby_version]
  end

  def rubygems_version
    command = gembinary + ['-v']
    execute(command)
  end

  def gembinary
    [command(:rvmcmd), ruby_version, 'do', 'gem']
  end

  def gemlist(hash)
    command = gembinary + ['list']

    command << if hash[:local]
                 '--local'
               else
                 '--remote'
               end

    if (name = hash[:justme])
      command << '^' + name + '$'
    end

    # use proxy if proxy_url is set
    if resource[:proxy_url] && !resource[:proxy_url].empty?
      command << '--http-proxy' << resource[:proxy_url]
    end

    list = []
    begin
      list = execute(command).split("\n").map do |set|
        if (gemhash = self.class.gemsplit(set))
          gemhash[:provider] = :gem
          gemhash
        end
      end.compact
    rescue Puppet::ExecutionFailure => detail
      Puppet.debug "`rvmcmd` command failed with #{detail}"
    end

    return list.shift if hash[:justme]
    list
  end

  def self.gemsplit(desc)
    desc = desc.gsub('default: ', '')

    case desc
    when %r{^\*\*\*}, %r{^\s*$}, %r{^\s+} then return nil
    when %r{gem: not found} then nil
    when %r{^(\S+)\s+\((\d+.*)\)}
      name = Regexp.last_match(1)
      version = Regexp.last_match(2).split(%r{,\s*})
      {
        name: name,
        ensure: version
      }
    else
      Puppet.warning "Could not match #{desc}"
      nil
    end
  end

  def install(useversion = true)
    command = gembinary + ['install']
    command << '-v' << resource[:ensure] if (!resource[:ensure].is_a? Symbol) && useversion
    # Dependencies are now installed by default
    # command << "--include-dependencies"

    # use proxy if proxy_url is set
    if resource[:proxy_url] && !resource[:proxy_url].empty?
      command << '--http-proxy' << resource[:proxy_url]
    end

    if (source = resource[:source])
      begin
        uri = URI.parse(source)
      rescue => detail
        raise "Invalid source '#{uri}': #{detail}"
      end

      case uri.scheme
      when nil
        # no URI scheme => interpret the source as a local file
        command << source
      when %r{file}i
        command << uri.path
      when 'puppet'
        # we don't support puppet:// URLs (yet)
        raise Puppet::Error, 'puppet:// URLs are not supported as gem sources'
      else
        # interpret it as a gem repository
        command << '--source' << source.to_s << resource[:name]
      end
    elsif Gem::Version.new(rubygems_version) < Gem::Version.new('3.0.0')
      command << '--no-rdoc' << '--no-ri' << resource[:name] # Deprecated options (backwards compatible)
    else
      command << '--no-document' << resource[:name]
    end

    # makefile opts,
    # must be last
    command << '--' << resource[:withopts] if resource[:withopts]

    output = execute(command)
    # Apparently some stupid gem versions don't exit non-0 on failure
    raise "Could not install: #{output.chomp}" if output.include?('ERROR')
  end

  def latest
    # This always gets the latest version available.
    hash = gemlist(justme: resource[:name])

    hash[:ensure][0]
  end

  def query
    gemlist(justme: resource[:name], local: true)
  end

  def uninstall
    execute(gembinary + ['uninstall', '-x', '-a', resource[:name]])
  end

  def update
    install(false)
  end
end

redpajama_set_name: RedPajamaGithub


text:
/*	$OpenBSD: ipx_usrreq.c,v 1.5 1997/01/18 17:53:54 mickey Exp $	*/

/*-
 *
 * Copyright (c) 1996 Michael Shalayeff
 * Copyright (c) 1995, Mike Mitchell
 * Copyright (c) 1984, 1985, 1986, 1987, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	@(#)ipx_usrreq.c
 *
 * from FreeBSD Id: ipx_usrreq.c,v 1.5 1996/03/11 15:13:57 davidg Exp
 */

#include <sys/param.h>
#include <sys/queue.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/errno.h>
#include <sys/stat.h>
#include <sys/proc.h>
#include <vm/vm.h>
#include <sys/sysctl.h>

#include <net/if.h>
#include <net/route.h>

#include <netinet/in.h>

#include <netipx/ipx.h>
#include <netipx/ipx_pcb.h>
#include <netipx/ipx_if.h>
#include <netipx/ipx_var.h>
#include <netipx/ipx_error.h>
#include <netipx/ipx_ip.h>

#include <machine/stdarg.h>

/*
 * IPX protocol implementation.
 */

int noipxRoute;

int ipxsendspace = IPXSNDQ;
int ipxrecvspace = IPXRCVQ;

/*
 *  This may also be called for raw listeners.
 */
void
#if __STDC__
ipx_input(struct mbuf *m, ...)
#else
ipx_input(m, va_alist)
	struct mbuf *m;
	va_decl
#endif
{
	register struct ipxpcb *ipxp;
	register struct ipx *ipx = mtod(m, struct ipx *);
	struct ifnet *ifp = m->m_pkthdr.rcvif;
	struct sockaddr_ipx ipx_ipx;
	va_list	ap;

	va_start(ap, m);
	ipxp = va_arg(ap, struct ipxpcb *);
	va_end(ap);

	if (ipxp == NULL)
		panic("No ipxpcb");
	/*
	 * Construct sockaddr format source address.
	 * Stuff source address and datagram in user buffer.
	 */
	bzero(&ipx_ipx, sizeof(ipx_ipx));
	ipx_ipx.sipx_len = sizeof(ipx_ipx);
	ipx_ipx.sipx_family = AF_IPX;
	ipx_ipx.sipx_addr = ipx->ipx_sna;
	if (ipx_neteqnn(ipx->ipx_sna.ipx_net, ipx_zeronet) && ifp) {
		register struct ifaddr *ifa;

		for (ifa = ifp->if_addrlist.tqh_first;
		     ifa; ifa = ifa->ifa_list.tqe_next) {
			if (ifa->ifa_addr->sa_family == AF_IPX) {
				ipx_ipx.sipx_addr.ipx_net =
					IA_SIPX(ifa)->sipx_addr.ipx_net;
				break;
			}
		}
	}
	ipxp->ipxp_rpt = ipx->ipx_pt;
	if ( ! (ipxp->ipxp_flags & IPXP_RAWIN) ) {
		m->m_len -= sizeof (struct ipx);
		m->m_pkthdr.len -= sizeof (struct ipx);
		m->m_data += sizeof (struct ipx);
	}
	if (sbappendaddr(&ipxp->ipxp_socket->so_rcv, sipxtosa(&ipx_ipx), m,
	    (struct mbuf *)0) == 0)
		goto bad;
	sorwakeup(ipxp->ipxp_socket);
	return;
bad:
	m_freem(m);
}

void
ipx_abort(ipxp)
	struct ipxpcb *ipxp;
{
	struct socket *so = ipxp->ipxp_socket;

	ipx_pcbdisconnect(ipxp);
	soisdisconnected(so);
}
/*
 * Drop connection, reporting
 * the specified error.
 */
/* struct ipxpcb * DELETE THIS */
void
ipx_drop(ipxp, errno)
	register struct ipxpcb *ipxp;
	int errno;
{
	struct socket *so = ipxp->ipxp_socket;

	/*
	 * someday, in the xerox world
	 * we will generate error protocol packets
	 * announcing that the socket has gone away.
	 */
	/*if (TCPS_HAVERCVDSYN(tp->t_state)) {
		tp->t_state = TCPS_CLOSED;
		(void) tcp_output(tp);
	}*/
	so->so_error = errno;
	ipx_pcbdisconnect(ipxp);
	soisdisconnected(so);
}

int
#if __STDC__
ipx_output(struct mbuf *m0, ...)
#else
ipx_output(m0, va_alist)
	struct mbuf *m0;
	va_decl
#endif
{
	register struct mbuf *m;
	register struct ipx *ipx;
	struct ipxpcb *ipxp;
	register struct socket *so;
	register int len = 0;
	register struct route *ro;
	struct mbuf *mprev = NULL;
	va_list	ap;

	va_start(ap, m0);
	ipxp = va_arg(ap, struct ipxpcb *);
	va_end(ap);

	/*
	 * Calculate data length.
	 */
	for (m = m0; m; m = m->m_next) {
		mprev = m;
		len += m->m_len;
	}
	/*
	 * Make sure packet is actually of even length.
	 */

	if (len & 1) {
		m = mprev;
		if ((m->m_flags & M_EXT) == 0 &&
			(m->m_len + m->m_data < &m->m_dat[MLEN])) {
			m->m_len++;
		} else {
			struct mbuf *m1 = m_get(M_DONTWAIT, MT_DATA);

			if (m1 == 0) {
				m_freem(m0);
				return (ENOBUFS);
			}
			m1->m_len = 1;
			* mtod(m1, char *) = 0;
			m->m_next = m1;
		}
		m0->m_pkthdr.len++;
	}

	/*
	 * Fill in mbuf with extended IPX header
	 * and addresses and length put into network format.
	 */
	m = m0;
	if (ipxp->ipxp_flags & IPXP_RAWOUT) {
		ipx = mtod(m, struct ipx *);
	} else {
		M_PREPEND(m, sizeof (struct ipx), M_DONTWAIT);
		if (m == 0)
			return (ENOBUFS);
		ipx = mtod(m, struct ipx *);
		ipx->ipx_tc = 0;
		ipx->ipx_pt = ipxp->ipxp_dpt;
		ipx->ipx_sna = ipxp->ipxp_laddr;
		ipx->ipx_dna = ipxp->ipxp_faddr;
		len += sizeof (struct ipx);
	}

	ipx->ipx_len = htons((u_short)len);

	if (ipxcksum) {
		ipx->ipx_sum = 0;
		len = ((len - 1) | 1) + 1;
		ipx->ipx_sum = ipx_cksum(m, len);
	} else
		ipx->ipx_sum = 0xffff;

	/*
	 * Output datagram.
	 */
	so = ipxp->ipxp_socket;
	if (so->so_options & SO_DONTROUTE)
		return (ipx_outputfl(m, (struct route *)0,
		    (so->so_options & SO_BROADCAST) | IPX_ROUTETOIF));
	/*
	 * Use cached route for previous datagram if
	 * possible.  If the previous net was the same
	 * and the interface was a broadcast medium, or
	 * if the previous destination was identical,
	 * then we are ok.
	 *
	 * NB: We don't handle broadcasts because that
	 *     would require 3 subroutine calls.
	 */
	ro = &ipxp->ipxp_route;
#ifdef ancient_history
	/*
	 * I think that this will all be handled in ipx_pcbconnect!
	 */
	if (ro->ro_rt) {
		if(ipx_neteq(ipxp->ipxp_lastdst, ipx->ipx_dna)) {
			/*
			 * This assumes we have no GH type routes
			 */
			if (ro->ro_rt->rt_flags & RTF_HOST) {
				if (!ipx_hosteq(ipxp->ipxp_lastdst, ipx->ipx_dna))
					goto re_route;

			}
			if ((ro->ro_rt->rt_flags & RTF_GATEWAY) == 0) {
				register struct ipx_addr *dst =
						&satoipx_addr(ro->ro_dst);
				dst->ipx_host = ipx->ipx_dna.ipx_host;
			}
			/*
			 * Otherwise, we go through the same gateway
			 * and dst is already set up.
			 */
		} else {
		re_route:
			RTFREE(ro->ro_rt);
			ro->ro_rt = (struct rtentry *)0;
		}
	}
	ipxp->ipxp_lastdst = ipx->ipx_dna;
#endif /* ancient_history */
	if (noipxRoute)
		ro = 0;
	return (ipx_outputfl(m, ro, so->so_options & SO_BROADCAST));
}

/* ARGSUSED */
int
ipx_ctloutput(req, so, level, name, value)
	int req, level;
	struct socket *so;
	int name;
	struct mbuf **value;
{
	register struct mbuf *m;
	struct ipxpcb *ipxp = sotoipxpcb(so);
	int mask, error = 0;
	/*extern long ipx_pexseq;*/ /*XXX*//*JRE*/

	if (ipxp == NULL)
		return (EINVAL);

	switch (req) {

	case PRCO_GETOPT:
		if (value==NULL)
			return (EINVAL);
		m = m_get(M_DONTWAIT, MT_DATA);
		if (m==NULL)
			return (ENOBUFS);
		switch (name) {

		case SO_ALL_PACKETS:
			mask = IPXP_ALL_PACKETS;
			goto get_flags;

		case SO_HEADERS_ON_INPUT:
			mask = IPXP_RAWIN;
			goto get_flags;

		case SO_HEADERS_ON_OUTPUT:
			mask = IPXP_RAWOUT;
		get_flags:
			m->m_len = sizeof(short);
			*mtod(m, short *) = ipxp->ipxp_flags & mask;
			break;

		case SO_DEFAULT_HEADERS:
			m->m_len = sizeof(struct ipx);
			{
				register struct ipx *ipx = mtod(m, struct ipx *);
				ipx->ipx_len = 0;
				ipx->ipx_sum = 0;
				ipx->ipx_tc = 0;
				ipx->ipx_pt = ipxp->ipxp_dpt;
				ipx->ipx_dna = ipxp->ipxp_faddr;
				ipx->ipx_sna = ipxp->ipxp_laddr;
			}
			break;

		case SO_SEQNO:
			m->m_len = sizeof(long);
			*mtod(m, long *) = ipx_pexseq++;
			break;

		default:
			error = EINVAL;
		}
		*value = m;
		break;

	case PRCO_SETOPT:
		switch (name) {
			int *ok;

		case SO_ALL_PACKETS:
			mask = IPXP_ALL_PACKETS;
			goto set_head;

		case SO_HEADERS_ON_INPUT:
			mask = IPXP_RAWIN;
			goto set_head;

		case SO_HEADERS_ON_OUTPUT:
			mask = IPXP_RAWOUT;
		set_head:
			if (value && *value) {
				ok = mtod(*value, int *);
				if (*ok)
					ipxp->ipxp_flags |= mask;
				else
					ipxp->ipxp_flags &= ~mask;
			} else error = EINVAL;
			break;

		case SO_DEFAULT_HEADERS:
			{
				register struct ipx *ipx
				    = mtod(*value, struct ipx *);
				ipxp->ipxp_dpt = ipx->ipx_pt;
			}
			break;
#ifdef IPXIP
		case SO_IPXIP_ROUTE:
			error = ipxip_route(*value);
			break;
#endif /* IPXIP */
#ifdef IPXTUNNEL
		case SO_IPXTUNNEL_ROUTE:
			error = ipxtun_route(*value);
			break;
#endif
		default:
			error = EINVAL;
		}
		if (value && *value)
			m_freem(*value);
		break;
	}
	return (error);
}

/*ARGSUSED*/
int
ipx_usrreq(so, req, m, nam, control)
	struct socket *so;
	int req;
	struct mbuf *m, *nam, *control;
{
	struct ipxpcb *ipxp = sotoipxpcb(so);
	int error = 0;

	if (req == PRU_CONTROL)
                return (ipx_control(so, (int)m, (caddr_t)nam,
			(struct ifnet *)control));
	if (control && control->m_len) {
		error = EINVAL;
		goto release;
	}
	if (ipxp == NULL && req != PRU_ATTACH) {
		error = EINVAL;
		goto release;
	}
	switch (req) {

	case PRU_ATTACH:
		if (ipxp != NULL) {
			error = EINVAL;
			break;
		}
		error = ipx_pcballoc(so, &ipxcbtable);
		if (error)
			break;
		error = soreserve(so, ipxsendspace, ipxrecvspace);
		if (error)
			break;
		break;

	case PRU_DETACH:
		if (ipxp == NULL) {
			error = ENOTCONN;
			break;
		}
		ipx_pcbdetach(ipxp);
		break;

	case PRU_BIND:
		error = ipx_pcbbind(ipxp, nam);
		break;

	case PRU_LISTEN:
		error = EOPNOTSUPP;
		break;

	case PRU_CONNECT:
		if (!ipx_nullhost(ipxp->ipxp_faddr)) {
			error = EISCONN;
			break;
		}
		error = ipx_pcbconnect(ipxp, nam);
		if (error == 0)
			soisconnected(so);
		break;

	case PRU_CONNECT2:
		error = EOPNOTSUPP;
		break;

	case PRU_ACCEPT:
		error = EOPNOTSUPP;
		break;

	case PRU_DISCONNECT:
		if (ipx_nullhost(ipxp->ipxp_faddr)) {
			error = ENOTCONN;
			break;
		}
		ipx_pcbdisconnect(ipxp);
		soisdisconnected(so);
		break;

	case PRU_SHUTDOWN:
		socantsendmore(so);
		break;

	case PRU_SEND:
	{
		struct ipx_addr laddr;
		int s = 0;

		if (nam) {
			laddr = ipxp->ipxp_laddr;
			if (!ipx_nullhost(ipxp->ipxp_faddr)) {
				error = EISCONN;
				break;
			}
			/*
			 * Must block input while temporarily connected.
			 */
			s = splnet();
			error = ipx_pcbconnect(ipxp, nam);
			if (error) {
				splx(s);
				break;
			}
		} else {
			if (ipx_nullhost(ipxp->ipxp_faddr)) {
				error = ENOTCONN;
				break;
			}
		}
		error = ipx_output(m, ipxp);
		m = NULL;
		if (nam) {
			ipx_pcbdisconnect(ipxp);
			splx(s);
			ipxp->ipxp_laddr.ipx_host = laddr.ipx_host;
			ipxp->ipxp_laddr.ipx_port = laddr.ipx_port;
		}
	}
		break;

	case PRU_ABORT:
		ipx_pcbdetach(ipxp);
		sofree(so);
		soisdisconnected(so);
		break;

	case PRU_SOCKADDR:
		ipx_setsockaddr(ipxp, nam);
		break;

	case PRU_PEERADDR:
		ipx_setpeeraddr(ipxp, nam);
		break;

	case PRU_SENSE:
		/*
		 * stat: don't bother with a blocksize.
		 */
		return (0);

	case PRU_SENDOOB:
	case PRU_FASTTIMO:
	case PRU_SLOWTIMO:
	case PRU_PROTORCV:
	case PRU_PROTOSEND:
		error =  EOPNOTSUPP;
		break;

	case PRU_CONTROL:
	case PRU_RCVD:
	case PRU_RCVOOB:
		return (EOPNOTSUPP);	/* do not free mbuf's */

	default:
		panic("ipx_usrreq");
	}
release:
	if (control != NULL)
		m_freem(control);
	if (m != NULL)
		m_freem(m);
	return (error);
}

/*ARGSUSED*/
int
ipx_raw_usrreq(so, req, m, nam, control)
	struct socket *so;
	int req;
	struct mbuf *m, *nam, *control;
{
	int error = 0;
	struct ipxpcb *ipxp = sotoipxpcb(so);
	/*extern struct ipxpcb ipxrawpcb;*//*XXX*//*JRE*/

	switch (req) {

	case PRU_ATTACH:

		if (!(so->so_state & SS_PRIV) || (ipxp != NULL)) {
			error = EINVAL;
			break;
		}
		error = ipx_pcballoc(so, &ipxrawcbtable);
		if (error)
			break;
		error = soreserve(so, ipxsendspace, ipxrecvspace);
		if (error)
			break;
		ipxp = sotoipxpcb(so);
		ipxp->ipxp_faddr.ipx_host = ipx_broadhost;
		ipxp->ipxp_flags = IPXP_RAWIN | IPXP_RAWOUT;
		break;
	default:
		error = ipx_usrreq(so, req, m, nam, control);
	}
	return (error);
}

int
ipx_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
	int *name;
	u_int namelen;
	void *oldp;
	size_t *oldlenp;
	void *newp;
	size_t newlen;
{
	/* All sysctl names at this level are terminal. */
	if (namelen != 1)
		return (ENOTDIR);

	switch (name[0]) {
	case IPXCTL_RECVSPACE:
		return (sysctl_int(oldp, oldlenp, newp, newlen,
			&ipxrecvspace));
	case IPXCTL_SENDSPACE:
		return (sysctl_int(oldp, oldlenp, newp, newlen,
			&ipxsendspace));
	default:
		return (ENOPROTOOPT);
	}
	/* NOT REACHED */
}


text:
Sequel.migration do
  up do
    alter_table :entity_ids do
      set_column_allow_null(:entity_descriptor_id)
    end
  end

  down do
    alter_table :entity_ids do
      set_column_not_allow_null(:entity_descriptor_id)
    end
  end
end


text:
module("baidu.ui.Suggestion.Suggestion$smartCover");

test("hide and show a select", function() {
	stop();
	var te = testingElement, sugg, input = te.dom[0], options = {
		onshow : function() {
			setTimeout(function(){
				equals(select.style.visibility, "hidden", "The select element is hidden");
				if (baidu.browser.ie) {
					equal(sugg.getMain().lastChild.style.width,
							sugg.getMain().offsetWidth + 'px');
					equal(sugg.getMain().lastChild.style.height,
							sugg.getMain().offsetHeight + 'px');
				}
				sugg.hide();
			},0);
		},
		onhide : function() {
			setTimeout(function(){
				equals(select.style.visibility, "", "The select element is shown");
				sugg.dispose();
				start();
			},0);
		}
	};

	var select = document.createElement('select');
	select.options[select.options.length] = new Option('content_a', 'value_a');
	document.body.appendChild(select);
	te.dom.push(select);
	sugg = new baidu.ui.Suggestion(options);
	sugg.render(input);
	baidu.ui.smartCover.options.hideSelect = true;
	sugg.show('a', [ 'ab', 'ac' ]);

});

test("hide and show 2 selects", function() {
	expect(4);
	stop();
	var te = testingElement, input = te.dom[0], sugg, options = {
		onshow : function() {
			setTimeout(function(){
				equals(select.style.visibility, "hidden", "The select element is hidden");
				equals(select1.style.visibility, "hidden", "The select element is hidden");
				sugg.hide();
			},0);
		},
		onhide : function() {
			setTimeout(function(){
				equals(select.style.visibility, "", "The select element is shown");
				equals(select1.style.visibility, "", "The select element is shown");
				start();
			},0);
		}
	};

	var select = document.createElement('select');
	select.options[select.options.length] = new Option('content_a', 'value_a');
	var select1 = document.createElement('select');
	select1.options[select1.options.length] = new Option('content_a', 'value_a');
	document.body.appendChild(select);
	document.body.appendChild(select1);
	te.dom.push(select);
	te.dom.push(select1);

	sugg = new baidu.ui.Suggestion(options);
	sugg.render(input);
	baidu.ui.smartCover.options.hideSelect = true;
	te.obj.push(sugg);
	sugg.show('a', [ 'ab', 'ac' ]);
});


text: Convert an amount of seconds to be easily read by an English human


text:
import json

from ui import db
from django.core.management.base import BaseCommand

class Command(BaseCommand):
    args = '<bibid>'
    help = 'get the bibliographic data for a given bibid'

    def handle(self, *args, **options):
        if len(args) >= 1:
            item = db.get_item(args[0])
            print json.dumps(item, indent=2)


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>Boost.Locale: Related Pages</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>

<link href="navtree.css" rel="stylesheet" type="text/css"/>

<link href="doxygen.css" rel="stylesheet" type="text/css" />

Boost.Locale

Main Page

Related Pages

Modules

Namespaces

Classes

Files

Examples

Related Pages

Here is a list of all related documentation pages:

© Copyright 2009-2012 Artyom Beilis,  Distributed under the Boost Software License, Version 1.0.


text:
package com.helpsumo.api.ticketing.ticket.Activities;

import android.app.AlertDialog;
import android.content.ContentValues;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.Toast;

import com.helpsumo.api.ticketing.R;
import com.helpsumo.api.ticketing.ticket.Adapter.ArticleList;
import com.helpsumo.api.ticketing.ticket.ClassObjects.ArticleCategory;
import com.helpsumo.api.ticketing.ticket.ClassObjects.ArticleSubcategory;
import com.helpsumo.api.ticketing.ticket.ClassObjects.Articledetails;
import com.helpsumo.api.ticketing.ticket.Database.ContentProvider.ArticleContentProvider;
import com.helpsumo.api.ticketing.ticket.Database.ContentProvider.CommonContentProvider;
import com.helpsumo.api.ticketing.ticket.Database.Table.ArticleTable;
import com.helpsumo.api.ticketing.ticket.Database.Table.CommonTable;
import com.helpsumo.api.ticketing.ticket.utills.AppConstants;
import com.helpsumo.api.ticketing.ticket.utills.NetworkFunction;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

public class Article extends AppCompatActivity {
    ArrayList<ArticleCategory> ArticleCategorydata = new ArrayList<ArticleCategory>();
    ArrayList<ArticleSubcategory> ArticleSubCategorydata = new ArrayList<ArticleSubcategory>();
    ArrayList<Articledetails> artdetail = new ArrayList<>();
    Spinner category, subcategory;
    String categoryid, subcategoryid;

    RelativeLayout progressview;
    SharedPreferences articleCategoryupdatetime;
    SharedPreferences Articleupdatetime;
    static SharedPreferences ApiKey;
    static SharedPreferences Useremail;
    ListView articlelist;
    ArrayList<String> cat = new ArrayList<>();
    ArrayList<String> subcat = new ArrayList<>();
    ArrayList<String> arrayarticleid = new ArrayList<>();
    public final MediaType JSON = MediaType.parse("application/json; charset=utf-8");

    @Override
    protected void onCreate(Bundle savedInstansestate) {
        super.onCreate(savedInstansestate);
        setContentView(R.layout.article);
        Intent i = getIntent();
        final String apikey = i.getStringExtra("Apikey");
        category = (Spinner) findViewById(R.id.category);
        subcategory = (Spinner) findViewById(R.id.subcategory);
        articlelist = (ListView) findViewById(R.id.articleslist);
        progressview = (RelativeLayout) findViewById(R.id.listprogressview);
        articleCategoryupdatetime = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
        String updatetime = articleCategoryupdatetime.getString("articleCategoryupdatetime", "");
        Useremail = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
       // String useremail = Useremail.getString("Useremail", "");
        ApiKey = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
        Articleupdatetime = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
        String articleupdatetime = Articleupdatetime.getString("Articleupdatetime", "");

        String mail = Useremail.getString("Useremail", "");
        if (mail.equals("")) {
            if(apikey.length()==0) {
                AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
                dialogBuilder.setMessage("Invalid ApiKey.");
                dialogBuilder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                    }
                });
                AlertDialog b = dialogBuilder.create();
                b.setCanceledOnTouchOutside(false);
                b.show();
            }else {
                AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
                LayoutInflater inflater = this.getLayoutInflater();
                final View dialogView = inflater.inflate(R.layout.emailview, null);
                dialogBuilder.setView(dialogView);
                final EditText edt = (EditText) dialogView.findViewById(R.id.input_mail);
                final EditText nam = (EditText) dialogView.findViewById(R.id.input_name);
                nam.setVisibility(View.GONE);
                dialogBuilder.setTitle("Enter you Email Id..");
                dialogBuilder.setPositiveButton("Done", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        String mail = edt.getText().toString();
                        SharedPreferences.Editor editor1 = Useremail.edit();
                        editor1.putString("Useremail", mail);
                        editor1.apply();
                        AppConstants.apikey = apikey;
                        SharedPreferences.Editor editor2 = ApiKey.edit();
                        editor2.putString("ApiKey", apikey);
                        editor2.apply();
                        Intent i = new Intent(Article.this, Article.class);
                        startActivity(i);
                    }
                });
                AlertDialog b = dialogBuilder.create();
                b.setCanceledOnTouchOutside(false);
                b.show();
            }
        } else {
            String[] projection = {ArticleTable.ID, ArticleTable.ARTICLE_ID, ArticleTable.ARTICLE_LIKE, ArticleTable.ARTICLE_UNLIKE, ArticleTable.CATEGORY_ID, ArticleTable.SUBCATEGORY_ID, ArticleTable.TITLE,
                    ArticleTable.DATE, ArticleTable.RATING, ArticleTable.DESCRIPTION, ArticleTable.TOTALVIEWS, ArticleTable.STATUS, ArticleTable.COMMENT_COUNT};
            String orderBy = ArticleTable.ID + " ASC";
            Cursor c = getContentResolver().query(ArticleContentProvider.CONTENT_URI, projection, null, null, orderBy);
            assert c != null;
            if (c.moveToFirst()) {
                do {
                    arrayarticleid.add(c.getString(c.getColumnIndex(ArticleTable.ARTICLE_ID)));
                } while (c.moveToNext());
            }
            c.close();
            String apky = ApiKey.getString("ApiKey","");
            Log.e("sdf","sdf"+apky);
            String time = articleCategoryupdatetime.getString("articleCategoryupdatetime", "");
            Map<String, String> map1 = new HashMap<>();
            map1.put("apikey", apky);
            map1.put("action", "list");
            map1.put("modified_date", time);
            if (NetworkFunction.isOnline(getApplicationContext())) {
                SpinnerValueFromServer spin = new SpinnerValueFromServer();
                spin.execute(map1);
            } else {
                addview();
            }
            Map<String, String> map = new HashMap<String, String>();
            map.put("apikey", apky);
            map.put("action", "list");
            map.put("email" ,mail);
            map.put("modified_date", articleupdatetime);
            progressview.setVisibility(View.VISIBLE);
            if (NetworkFunction.isOnline(getApplicationContext())) {
                LoadArticle load = new LoadArticle();
                load.execute(map);
            } else {
                viewArticle();
            }
            category.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
                    categoryid = ArticleCategorydata.get(pos).getCatgryid();
                    if (categoryid.equals("0")) {
                        subcat.clear();
                        String[] projectionjob = {
                                CommonTable.COLUMN_ID, CommonTable.COLUMN_NAME, CommonTable.COLUMN_SERVERID, String.valueOf(CommonTable.COLUMN_TYPE)};
                        String orderBy = CommonTable.COLUMN_ID + " ASC";
                        Cursor cursor = getContentResolver().query(CommonContentProvider.CONTENT_URI, projectionjob, CommonTable.COLUMN_PARENT_ID + " = ?", new String[]{"1"}, orderBy);
                        subcat.clear();
                        ArticleSubCategorydata.clear();
                        if (cursor != null && cursor.moveToFirst()) {
                            do {
                                ArticleSubcategory ls = new ArticleSubcategory();
                                ls.setSubcatgryidId(cursor.getString(cursor.getColumnIndex(CommonTable.COLUMN_SERVERID)));
                                ls.setSubcatgryame(cursor.getString(cursor.getColumnIndex(CommonTable.COLUMN_NAME)));
                                subcat.add(cursor.getString(cursor.getColumnIndex(CommonTable.COLUMN_NAME)));
                                ArticleSubCategorydata.add(ls);
                            }
                            while (cursor.moveToNext());
                        }
                        ArrayAdapter<String> priorAdapter = new ArrayAdapter<String>(Article.this, android.R.layout.simple_spinner_item, subcat);
                        priorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                        subcategory.setAdapter(priorAdapter);
                    } else {
                        ArticleSubCategorydata.clear();
                        String[] projectionjob = {
                                CommonTable.COLUMN_ID, CommonTable.COLUMN_NAME, CommonTable.COLUMN_SERVERID, String.valueOf(CommonTable.COLUMN_TYPE)};
                        String orderBy = CommonTable.COLUMN_ID + " ASC";
                        Cursor cursor = getContentResolver().query(CommonContentProvider.CONTENT_URI, projectionjob, CommonTable.COLUMN_PARENT_ID + " = ?", new String[]{categoryid}, orderBy);
                        subcat.clear();
                        if (cursor != null && cursor.moveToFirst()) {
                            do {
                                ArticleSubcategory ls = new ArticleSubcategory();
                                ls.setSubcatgryidId(cursor.getString(cursor.getColumnIndex(CommonTable.COLUMN_SERVERID)));
                                ls.setSubcatgryame(cursor.getString(cursor.getColumnIndex(CommonTable.COLUMN_NAME)));
                                subcat.add(cursor.getString(cursor.getColumnIndex(CommonTable.COLUMN_NAME)));
                                ArticleSubCategorydata.add(ls);
                            }
                            while (cursor.moveToNext());
                        }
                    }
                    ArrayAdapter<String> priorAdapter = new ArrayAdapter<String>(Article.this, android.R.layout.simple_spinner_item, subcat);
                    priorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                    subcategory.setAdapter(priorAdapter);
                }

                @Override
                public void onNothingSelected(AdapterView<?> arg0) {
                }
            });
            subcategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
                    try {
                        subcategoryid = ArticleSubCategorydata.get(pos).getSubcatgryid();
                        if (subcategoryid.equals("0")) {
                            artdetail.clear();
                            String[] projection = {ArticleTable.ID, ArticleTable.ARTICLE_ID, ArticleTable.ARTICLE_LIKE, ArticleTable.ARTICLE_UNLIKE, ArticleTable.CATEGORY_ID, ArticleTable.ARTICLE_LIKE_FLAG, ArticleTable.SUBCATEGORY_ID, ArticleTable.TITLE,
                                    ArticleTable.DATE, ArticleTable.RATING, ArticleTable.TOTALVIEWS, ArticleTable.DESCRIPTION, ArticleTable.STATUS, ArticleTable.COMMENT_COUNT};
                            String orderBy = ArticleTable.ID + " ASC";
                            Cursor c = getContentResolver().query(ArticleContentProvider.CONTENT_URI, projection, null, null, orderBy);
                            assert c != null;
                            if (c.moveToFirst()) {
                                do {
                                    Articledetails ls = new Articledetails();
                                    ls.setArtid(c.getString(c.getColumnIndex(ArticleTable.ARTICLE_ID)));
                                    ls.setArthead((c.getString(c.getColumnIndex(ArticleTable.TITLE))));
                                    ls.setArtdescrip(c.getString(c.getColumnIndex(ArticleTable.DESCRIPTION)));
                                    ls.setArtdate(c.getString(c.getColumnIndex(ArticleTable.DATE)));
                                    ls.setArtrating(c.getString(c.getColumnIndex(ArticleTable.RATING)));
                                    ls.setArtcomment(c.getString(c.getColumnIndex(ArticleTable.COMMENT_COUNT)));
                                    ls.setArtstatus(c.getString(c.getColumnIndex(ArticleTable.STATUS)));
                                    artdetail.add(ls);
                                } while (c.moveToNext());
                            }
                            c.close();
                            ArticleList adapter = new ArticleList(Article.this, artdetail);
                            articlelist.setAdapter(adapter);
                        } else {
                            artdetail.clear();
                            String[] projection = {ArticleTable.ID, ArticleTable.ARTICLE_ID, ArticleTable.ARTICLE_LIKE, ArticleTable.ARTICLE_UNLIKE, ArticleTable.ARTICLE_LIKE_FLAG, ArticleTable.CATEGORY_ID, ArticleTable.SUBCATEGORY_ID, ArticleTable.TITLE,
                                    ArticleTable.DATE, ArticleTable.RATING, ArticleTable.TOTALVIEWS, ArticleTable.DESCRIPTION, ArticleTable.STATUS, ArticleTable.COMMENT_COUNT};
                            String orderBy = ArticleTable.ID + " ASC";
                            Cursor c = getContentResolver().query(ArticleContentProvider.CONTENT_URI, projection, ArticleTable.SUBCATEGORY_ID + " =?", new String[]{subcategoryid}, orderBy);
                            assert c != null;
                            if (c.moveToFirst()) {
                                do {
                                    Articledetails ls = new Articledetails();
                                    ls.setArtid(c.getString(c.getColumnIndex(ArticleTable.ARTICLE_ID)));
                                    ls.setArthead((c.getString(c.getColumnIndex(ArticleTable.TITLE))));
                                    ls.setArtdescrip(c.getString(c.getColumnIndex(ArticleTable.DESCRIPTION)));
                                    ls.setArtdate(c.getString(c.getColumnIndex(ArticleTable.DATE)));
                                    ls.setArtrating(c.getString(c.getColumnIndex(ArticleTable.RATING)));
                                    ls.setArtcomment(c.getString(c.getColumnIndex(ArticleTable.COMMENT_COUNT)));
                                    ls.setArtstatus(c.getString(c.getColumnIndex(ArticleTable.STATUS)));
                                    artdetail.add(ls);
                                } while (c.moveToNext());
                            }
                            c.close();
                            ArticleList adapter = new ArticleList(Article.this, artdetail);
                            articlelist.setAdapter(adapter);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                @Override
                public void onNothingSelected(AdapterView<?> arg0) {
                }
            });
        }
    }

    public class SpinnerValueFromServer extends AsyncTask<Map<String, String>, Void, Boolean> {
        @SafeVarargs
        @Override
        protected final Boolean doInBackground(Map<String, String>... maps) {
            try {
                Map<String, String> paramMap = maps[0];
                JSONObject jsonObject = new JSONObject();
                try {
                    jsonObject.put("apikey", paramMap.get("apikey"));
                    jsonObject.put("action", paramMap.get("action"));
                    jsonObject.put("modified_date", paramMap.get("modified_date"));
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                JSONArray jsonArray = new JSONArray();
                jsonArray.put(jsonObject);
                JSONObject ParentObj = new JSONObject();
                try {
                    ParentObj.put("Current Location", jsonArray);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                String jsonStr = jsonObject.toString();
                System.out.println("jsonString: " + jsonStr);
                String url = AppConstants.url + "article_categories";
                String response = doPostRequest(url, jsonStr);
                if (response != null) {
                    Log.e("article", "response: " + response.replaceAll("\\s", " "));
                    String catid = "", catname = "", catstatus = "", catparentid = "";
                    JSONObject obj = new JSONObject(response);
                    if (obj.has("ERROR")) {
                        final String toastmsg = obj.getString("ERROR");
                        Article.this.runOnUiThread(new Runnable() {
                            public void run() {
                                Toast.makeText(getApplicationContext(), toastmsg, Toast.LENGTH_LONG).show();
                            }
                        });
                        return false;
                    } else {
                        JSONObject listPathObject = obj.getJSONObject("response");
                        JSONArray array = listPathObject.getJSONArray("ARTICLE_CATEGORY_SUBCATEGORY");
                        if (array.length() == 0) {
                        } else {
                            int b = getContentResolver().delete(CommonContentProvider.CONTENT_URI, CommonTable.COLUMN_TYPE + "= ?", new String[]{"5"});
                            int b1 = getContentResolver().delete(CommonContentProvider.CONTENT_URI, CommonTable.COLUMN_TYPE + "= ?", new String[]{"6"});
                            ContentValues valu = new ContentValues();
                            valu.put(CommonTable.COLUMN_TYPE, 5);
                            valu.put(CommonTable.COLUMN_SERVERID, "0");
                            valu.put(CommonTable.COLUMN_NAME, "Please Select");
                            valu.put(CommonTable.COLUMN_STATUS, "");
                            valu.put(CommonTable.COLUMN_PARENT_ID, "1");
                            getContentResolver().insert(CommonContentProvider.CONTENT_URI, valu);

                            ContentValues val = new ContentValues();
                            val.put(CommonTable.COLUMN_TYPE, 6);
                            val.put(CommonTable.COLUMN_SERVERID, "0");
                            val.put(CommonTable.COLUMN_NAME, "Please Select");
                            valu.put(CommonTable.COLUMN_PARENT_ID, "1");
                            val.put(CommonTable.COLUMN_STATUS, "");
                            getContentResolver().insert(CommonContentProvider.CONTENT_URI, val);

                            for (int i = 0; i < array.length(); i++) {
                                JSONObject jobj = array.getJSONObject(i);
                                catid = jobj.getString("category_id");
                                catname = jobj.getString("category_title");
                                catstatus = jobj.getString("status");
                                catparentid = jobj.getString("parent_id");

                                if (catparentid.equals("0")) {
                                    ContentValues values = new ContentValues();
                                    values.put(CommonTable.COLUMN_TYPE, 5);
                                    values.put(CommonTable.COLUMN_SERVERID, catid);
                                    values.put(CommonTable.COLUMN_NAME, catname);
                                    values.put(CommonTable.COLUMN_STATUS, catstatus);
                                    values.put(CommonTable.COLUMN_PARENT_ID, catparentid);
                                    getContentResolver().insert(CommonContentProvider.CONTENT_URI, values);
                                } else {
                                    ContentValues values = new ContentValues();
                                    values.put(CommonTable.COLUMN_TYPE, 6);
                                    values.put(CommonTable.COLUMN_SERVERID, catid);
                                    values.put(CommonTable.COLUMN_NAME, catname);
                                    values.put(CommonTable.COLUMN_STATUS, catstatus);
                                    values.put(CommonTable.COLUMN_PARENT_ID, catparentid);
                                    getContentResolver().insert(CommonContentProvider.CONTENT_URI, values);
                                }
                            }
                        }
                        String time = listPathObject.getString("CurrentDateTime");
                        SharedPreferences.Editor editor = articleCategoryupdatetime.edit();
                        editor.putString("articleCategoryupdatetime", time);
                        editor.apply();
                    }
                }
                return true;
            } catch (Exception e) {
                return false;
            }
        }

        @Override
        protected void onPostExecute(final Boolean success) {
            if (success) {
                addview();
            } else {
            }
        }
    }

    public class LoadArticle extends AsyncTask<Map<String, String>, Void, Boolean> {
        @SafeVarargs
        @Override
        protected final Boolean doInBackground(Map<String, String>... maps) {
            try {
                Map<String, String> paramMap = maps[0];
                JSONObject jsonObject = new JSONObject();
                try {
                    jsonObject.put("apikey", paramMap.get("apikey"));
                    jsonObject.put("action", paramMap.get("action"));
                    jsonObject.put("email",paramMap.get("email"));
                    jsonObject.put("modified_date", paramMap.get("modified_date"));
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                JSONArray jsonArray = new JSONArray();
                jsonArray.put(jsonObject);
                JSONObject ParentObj = new JSONObject();
                try {
                    ParentObj.put("Current Location", jsonArray);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                String jsonStr = jsonObject.toString();
                System.out.println("jsonString: " + jsonStr);
                String url = AppConstants.url + "article";
                String response = doPostRequest(url, jsonStr);
                if (response != null) {
                    Log.e("response", "article: " + response.replaceAll("\\s", " "));
                    JSONObject obj = new JSONObject(response);
                    if (obj.has("ERROR")) {
                        final String toastmsg = obj.getString("ERROR");
                        Article.this.runOnUiThread(new Runnable() {
                            public void run() {
                                Toast.makeText(getApplicationContext(), toastmsg, Toast.LENGTH_LONG).show();
                                progressview.setVisibility(View.GONE);
                            }
                        });
                        return false;
                    } else {
                        JSONObject listPathObject = obj.getJSONObject("response");
                        JSONArray array = listPathObject.getJSONArray("ARTICLE");
                        try {
                            for (int i = 0; i < array.length(); i++) {
                                String artid = "", artcat = "", artsub = "", arttitle = "", artdescrp = "",
                                        arttotalview = "", like = "", unlike = "",likeflag = "", commentcount = "", artdate = "";
                                JSONObject jObject = array.getJSONObject(i);
                                Iterator<String> keys = jObject.keys();
                                while (keys.hasNext()) {
                                    String key = keys.next();
                                    key.replaceAll("\\s", " ");
                                    String value = jObject.getString(key);
                                    if (key.equalsIgnoreCase("article_id")) {
                                        artid = value;
                                    } else if (key.equalsIgnoreCase("category_id")) {
                                        artcat = value;
                                    } else if (key.equalsIgnoreCase("subcategory_id")) {
                                        artsub = value;
                                    } else if (key.equalsIgnoreCase("article_title")) {
                                        arttitle = value;
                                    } else if (key.equalsIgnoreCase("article_description")) {
                                        artdescrp = value;
                                    } else if (key.equalsIgnoreCase("totalviews")) {
                                        arttotalview = value;
                                    } else if (key.equalsIgnoreCase("like")) {
                                        like = value;
                                    } else if (key.equalsIgnoreCase("unlike")) {
                                        unlike = value;
                                    } else if (key.equalsIgnoreCase("modified_at")) {
                                        artdate = value;
                                    } else if (key.equalsIgnoreCase("comment")) {
                                        commentcount = value;
                                    } else if (key.equalsIgnoreCase("check")) {
                                        likeflag = value;

                                    }
                                }
                                if (arrayarticleid.contains(artid)) {
                                    ContentValues values = new ContentValues();
                                    values.put(ArticleTable.ARTICLE_ID, artid);
                                    values.put(ArticleTable.CATEGORY_ID, artcat);
                                    values.put(ArticleTable.SUBCATEGORY_ID, artsub);
                                    values.put(ArticleTable.TITLE, arttitle);
                                    values.put(ArticleTable.DESCRIPTION, artdescrp);
                                    values.put(ArticleTable.STATUS, "");
                                    values.put(ArticleTable.ARTICLE_LIKE, like);
                                    values.put(ArticleTable.ARTICLE_UNLIKE, unlike);
                                    int lik = Integer.parseInt(like);
                                    int unlik = Integer.parseInt(unlike);
                                    float sum = lik + unlik;
                                    if (sum == 0) {
                                        values.put(ArticleTable.RATING, sum);
                                    } else {
                                        float average = ((lik / sum) * 5);
                                        BigDecimal bd = new BigDecimal(Float.toString(average));
                                        bd = bd.setScale(1, BigDecimal.ROUND_HALF_UP);
                                        values.put(ArticleTable.RATING, String.valueOf(bd));
                                    }
                                    values.put(ArticleTable.TOTALVIEWS, arttotalview);
                                    values.put(ArticleTable.COMMENT_COUNT, commentcount);
                                    values.put(ArticleTable.DATE, artdate);
                                    values.put(ArticleTable.ARTICLE_LIKE_FLAG, likeflag);
                                    getContentResolver().update(ArticleContentProvider.CONTENT_URI, values, ArticleTable.ARTICLE_ID + " =?", new String[]{artid});
                                } else {
                                    ContentValues values = new ContentValues();
                                    values.put(ArticleTable.ARTICLE_ID, artid);
                                    values.put(ArticleTable.CATEGORY_ID, artcat);
                                    values.put(ArticleTable.SUBCATEGORY_ID, artsub);
                                    values.put(ArticleTable.TITLE, arttitle);
                                    values.put(ArticleTable.DESCRIPTION, artdescrp);
                                    values.put(ArticleTable.STATUS, "");
                                    values.put(ArticleTable.ARTICLE_LIKE, like);
                                    values.put(ArticleTable.ARTICLE_UNLIKE, unlike);
                                    int lik = Integer.parseInt(like);
                                    int unlik = Integer.parseInt(unlike);
                                    float sum = lik + unlik;
                                    if (sum == 0) {
                                        values.put(ArticleTable.RATING, sum);
                                    } else {
                                        float average = ((lik / sum) * 5);
                                        BigDecimal bd = new BigDecimal(Float.toString(average));
                                        bd = bd.setScale(1, BigDecimal.ROUND_HALF_UP);
                                        values.put(ArticleTable.RATING, String.valueOf(bd));
                                    }
                                    values.put(ArticleTable.TOTALVIEWS, arttotalview);
                                    values.put(ArticleTable.COMMENT_COUNT, commentcount);
                                    values.put(ArticleTable.DATE, artdate);
                                    values.put(ArticleTable.ARTICLE_LIKE_FLAG, likeflag);
                                    getContentResolver().insert(ArticleContentProvider.CONTENT_URI, values);
                                }
                            }
                            String date = listPathObject.getString("CurrentDateTime");
                            SharedPreferences.Editor editor = Articleupdatetime.edit();
                            editor.putString("Articleupdatetime", date);
                            editor.apply();
                        } catch (Exception e) {
                            e.printStackTrace();
                            return false;
                        }
                    }
                }
                return true;
            } catch (Exception e) {
                return false;
            }
        }

        @Override
        public void onPostExecute(final Boolean success) {
            if (success) {
                viewArticle();
            } else {
            }
        }
    }

    void addview() {
        String[] projectionjob = {
                CommonTable.COLUMN_ID, CommonTable.COLUMN_NAME, CommonTable.COLUMN_SERVERID, String.valueOf(CommonTable.COLUMN_TYPE)};
        String orderBy = CommonTable.COLUMN_ID + " ASC";
        Cursor cursor = getContentResolver().query(CommonContentProvider.CONTENT_URI, projectionjob, CommonTable.COLUMN_TYPE + " = ?", new String[]{"5"}, orderBy);
        if (cursor != null && cursor.moveToFirst()) {
            do {
                ArticleCategory ls = new ArticleCategory();
                ls.setCatgryidId(cursor.getString(cursor.getColumnIndex(CommonTable.COLUMN_SERVERID)));
                ls.setCatgryame(cursor.getString(cursor.getColumnIndex(CommonTable.COLUMN_NAME)));
                cat.add(cursor.getString(cursor.getColumnIndex(CommonTable.COLUMN_NAME)));
                ArticleCategorydata.add(ls);
            }
            while (cursor.moveToNext());
        }
        ArrayAdapter<String> departAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, cat);
        departAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        category.setAdapter(departAdapter);
    }

    public void viewArticle() {
        artdetail.clear();
        String[] projection = {ArticleTable.ID, ArticleTable.ARTICLE_ID, ArticleTable.ARTICLE_UPDATE_TIME, ArticleTable.CATEGORY_ID, ArticleTable.ARTICLE_LIKE, ArticleTable.ARTICLE_UNLIKE, ArticleTable.SUBCATEGORY_ID, ArticleTable.TITLE,
                ArticleTable.DATE, ArticleTable.RATING, ArticleTable.ARTICLE_LIKE_FLAG, ArticleTable.TOTALVIEWS, ArticleTable.DESCRIPTION, ArticleTable.STATUS, ArticleTable.COMMENT_COUNT};
        String orderBy = ArticleTable.ID + " ASC";
        Cursor c = getContentResolver().query(ArticleContentProvider.CONTENT_URI, projection, null, null, orderBy);
        assert c != null;
        if (c.moveToFirst()) {
            do {
                Articledetails ls = new Articledetails();
                ls.setArtid(c.getString(c.getColumnIndex(ArticleTable.ARTICLE_ID)));
                ls.setArthead((c.getString(c.getColumnIndex(ArticleTable.TITLE))));
                ls.setArtdescrip(c.getString(c.getColumnIndex(ArticleTable.DESCRIPTION)));
                ls.setArtdate(c.getString(c.getColumnIndex(ArticleTable.DATE)));
                ls.setArtrating(c.getString(c.getColumnIndex(ArticleTable.RATING)));
                ls.setArtcomment(c.getString(c.getColumnIndex(ArticleTable.COMMENT_COUNT)));
                ls.setArtstatus(c.getString(c.getColumnIndex(ArticleTable.STATUS)));
                artdetail.add(ls);
            } while (c.moveToNext());
        }
        c.close();
        ArticleList adapter = new ArticleList(Article.this, artdetail);
        articlelist.setAdapter(adapter);
        progressview.setVisibility(View.GONE);
    }

    String doPostRequest(String url, String json) throws IOException {
        OkHttpClient client = new OkHttpClient();
        RequestBody body = RequestBody.create(JSON, json);
        Request request = new Request.Builder().url(url).post(body).build();
        Response response = client.newCall(request).execute();
        return response.body().string();
    }
}


text:
package org.sstudio.bulldozer.exceptions

private[bulldozer] final class JsonTypeNotSupported(message: String) extends Exception(message)


text:
<?php

namespace Stichoza\GoogleTranslate\Tests;

use Stichoza\GoogleTranslate\TranslateClient;

class TranslationTest extends \PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        $this->tr = new TranslateClient();
    }

    public function testTranslationEquality()
    {
        $resultOne = TranslateClient::translate('en', 'ka', 'Hello');
        $resultTwo = $this->tr->setSource('en')->setTarget('ka')->translate('Hello');

        $this->assertEquals($resultOne, $resultTwo, 'გამარჯობა');
    }

    public function testArrayTranslation()
    {
        $this->tr->setSource('en')->setTarget('ka');

        $resultCat = $this->tr->translate('cat');
        $resultDog = $this->tr->translate('dog');
        $resultFish = $this->tr->translate('fish');

        $arrayResults = $this->tr->translate(['cat', 'dog', 'fish']);
        $arrayZesults = TranslateClient::translate('en', 'ka', ['cat', 'dog', 'fish']);

        $this->assertEquals($resultCat, $arrayResults[0], 'კატა');
        $this->assertEquals($resultDog, $arrayResults[1], 'ძაღლი');
        $this->assertEquals($resultFish, $arrayResults[2], 'თევზი');

        $this->assertEquals($resultCat, $arrayZesults[0], 'კატა');
        $this->assertEquals($resultDog, $arrayZesults[1], 'ძაღლი');
        $this->assertEquals($resultFish, $arrayZesults[2], 'თევზი');
    }

    public function testRawResponse()
    {
        $rawResult = $this->tr->getResponse('cat');

        $this->assertTrue(is_array($rawResult), 'Method getResponse() should return an array.');
    }
}