<commit_before>/* libquvi
 * Copyright (C) 2012  <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

/** @file get.c */

#include "config.h"

#include <glib.h>

#include "quvi.h"
/* -- */
#include "_quvi_s.h"

static void _get(_quvi_t q, QuviInfo info, ...)
{
  gpointer *vp = NULL;
  gdouble *dp = NULL;
  gchar **sp = NULL;
  glong *lp = NULL;
  gint type = 0;
  va_list arg;

  va_start(arg, info);
  type = QUVI_INFO_TYPE_MASK & (gint) info;

  switch (type)
    {
    case QUVI_INFO_TYPE_DOUBLE:
      dp = va_arg(arg, gdouble*);
      break;
    case QUVI_INFO_TYPE_STRING:
      sp = va_arg(arg, gchar**);
      break;
    case QUVI_INFO_TYPE_LONG:
      lp = va_arg(arg, glong*);
      break;
    case QUVI_INFO_TYPE_VOID:
      vp = va_arg(arg, gpointer*);
      break;
    default:
      break;
    }
  va_end(arg);

  switch (info)
    {
    case QUVI_INFO_RESPONSE_CODE:
      if (lp != NULL)
        *lp = q->status.resp_code;
      break;
    case QUVI_INFO_ERROR_CODE:
      if (lp != NULL)
        *lp = q->status.rc;
      break;
    case QUVI_INFO_CURL_HANDLE:
      if (vp != NULL)
        *vp = q->handle.curl;
      break;
    default:
      break;
    }
}

/** @brief Return information about the library handle
@sa @ref getting_started
@ingroup lib
*/
void quvi_get(quvi_t handle, QuviInfo info, ...)
{
  _quvi_t q = (_quvi_t) handle;
  gpointer p = NULL;
  va_list arg;

  /* If G_DISABLE_CHECKS is defined then the check is not performed. */
  g_return_if_fail(handle != NULL);

  va_start(arg, info);
  p = va_arg(arg, gpointer);
  va_end(arg);

  _get(q, info, p);
}

/* vim: set ts=2 sw=2 tw=72 expandtab: */<commit_msg>quvi_get: Default to QUVI_INFO_RESPONSE_CODE<commit_after>/* libquvi
 * Copyright (C) 2012  <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

/** @file get.c */

#include "config.h"

#include <glib.h>

#include "quvi.h"
/* -- */
#include "_quvi_s.h"

static void _get(_quvi_t q, QuviInfo info, ...)
{
  gpointer *vp = NULL;
  gdouble *dp = NULL;
  gchar **sp = NULL;
  glong *lp = NULL;
  gint type = 0;
  va_list arg;

  va_start(arg, info);
  type = QUVI_INFO_TYPE_MASK & (gint) info;

  switch (type)
    {
    case QUVI_INFO_TYPE_DOUBLE:
      dp = va_arg(arg, gdouble*);
      break;
    case QUVI_INFO_TYPE_STRING:
      sp = va_arg(arg, gchar**);
      break;
    case QUVI_INFO_TYPE_LONG:
      lp = va_arg(arg, glong*);
      break;
    case QUVI_INFO_TYPE_VOID:
      vp = va_arg(arg, gpointer*);
      break;
    default:
      break;
    }
  va_end(arg);

  switch (info)
    {
    case QUVI_INFO_RESPONSE_CODE:
    default:
      if (lp != NULL)
        *lp = q->status.resp_code;
      break;
    case QUVI_INFO_ERROR_CODE:
      if (lp != NULL)
        *lp = q->status.rc;
      break;
    case QUVI_INFO_CURL_HANDLE:
      if (vp != NULL)
        *vp = q->handle.curl;
      break;
    }
}

/** @brief Return information about the library handle
@sa @ref getting_started
@ingroup lib
*/
void quvi_get(quvi_t handle, QuviInfo info, ...)
{
  _quvi_t q = (_quvi_t) handle;
  gpointer p = NULL;
  va_list arg;

  /* If G_DISABLE_CHECKS is defined then the check is not performed. */
  g_return_if_fail(handle != NULL);

  va_start(arg, info);
  p = va_arg(arg, gpointer);
  va_end(arg);

  _get(q, info, p);
}

/* vim: set ts=2 sw=2 tw=72 expandtab: */
{'fraction_non_alphanumeric': 0.11101658868566568, 'fraction_numerical': 0.00893236920459379, 'mean_word_length': 2.864420706655711, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4350504', 'n_tokens_mistral': 1705, 'n_tokens_neox': 1654, 'n_words': 540}