Skip to content
Snippets Groups Projects
Select Git revision
  • 2ff4568a14bd728e6ba2a308082d0a9d1a8619a7
  • master default protected
  • docs
  • devel
  • error_code_changes
  • error_codes
  • refactor_network_status
  • consistency_changes
  • activate_sim_functionality
  • refactor_zte_profiles
  • dongle_netlink
  • profile_error_handling
  • some_suggestions
  • refactor_fixes_suggestions
  • refactor
  • tmp
  • zte-mf823
  • dongle_refactor
  • zte-mf823_suggestions3
  • zte-mf823_suggestion2
  • hilink-e3372h_dynamic_obj
21 results

common.h

  • user avatar
    Jakob Olsson authored
    2ff4568a
    History
    common.h 1.49 KiB
    #ifndef COMMON_H
    #define COMMON_H
    
    #include <stdlib.h>
    #include <stdio.h>
    #include <stdbool.h>
    #include <unistd.h>
    #include <getopt.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <signal.h>
    #include <time.h>
    #include <limits.h>
    #include <libubox/list.h>
    
    #include "libmobile.h"
    #include <json-c/json.h>
    #include <string.h>
    #include <libubox/blobmsg.h>
    #include <libubus.h>
    
    int debug;
    
    #define debug_print(...)                  \
    	do                                    \
    	{                                     \
    		if (debug)                        \
    			fprintf(stderr, __VA_ARGS__); \
    	} while (0)
    /**
     * Function: print_to_ubus
     *
     * Prints a json_object pointer's json structure to ubus.
     *
     * Parameters:
     * 		parsed_response - A struct json_object pointer to json structure to be printed to ubus.
     * 		ctx - Ubus context containing connection.
     * 		req - Information for from the ubus request.
     *
     * Returns:
     * 		0 On success.
     * 		-1 On failure.
     */
    int print_to_ubus(struct json_object *parsed_response, struct ubus_context *ctx, struct ubus_request_data *req);
    
    /**
     * Function: json_to_blob
     *
     * Parses a json_object pointer to a corresponding blob buffer.
     *
     * Parameters:
     * 		response - json_object pointer to be replicated in a blob buffer.
     * 		bb - The blob buffer to hold the results.
     *
     * Returns:
     *		Blob buffer containing the replicated json_object.
     */
    struct blob_buf json_to_blob(struct json_object *response, struct blob_buf bb);
    
    void set_debug(int debug_arg);
    #endif