## Handling a photos search result

If a photos search from flickcurl_photos_search_params() returns a flickcurl_photos_list object then there will be a result available to use. This structure contains the format name of the result, the number of photos and the photos objects themselves (for a SPR) or the raw content bytes (for XML / other format results). The SPR format name is "xml".

The following code fragment takes a search result in the variable `photos_list` and prints it out if a standard photo list or raw content are returned. Otherwise it prints an error.

      if(photos_list->photos) {
        int i;

        /* if the result is SPR - print out the URLs of the photos */
        printf("Search returned %d photos\n", photos_list->photos_count);
        for(i = 0; i < photos_list->photos_count; ++i) {
          printf("  Result #%d has ID %s\n", i, photos_list->photos[i]->id);
        }

      } else if(photos_list->content) {

        /* if the result is raw content - print it out */
        fprintf(stderr, "Search returned %d bytes of content in format %s\n",
                photos_list->content_length, photos_list->format);
        fwrite(photos_list->content, 1, photos_list->content_length, stdout);

      } else {

        /* if the result is something else - throw an error */
        fprintf(stderr, "Search returned neither photos nor raw content\n");
      }